Originally Posted by
Nubzgetkillz
I get what you guys are saying, and I want to learn new stuff once you do learn new stuff you feel good.
So that is why I try to be less of a leecher, and try to learn more about C++ language.
Your past hack releases are great and have the look of a good coder. Even though I have only seen screenshots
so people could be doing:
Code:
int hacks [] = {f1, f2, f3, f4, f5};
sorry if i am typing random shit.
If you're using C++ you can just use the 'bool' type:
Code:
#include "CAHacks.h"
.... // More code in your program
HRESULT WINAPI EndScene(LPDIRECT3DDEVICE9 pDevice)
{
static bool bMenu = false; // a static variable holds it's state throughout
// each invocation of the method.
static int menu_length = sizeof(menus) / sizeof(menus[0]); // Calculate the number of menus in the menu array.
if(GetAsyncKeyState(VK_INSERT) & 1)
bMenu = !bMenu; // This will toggle bMenu, if it was true, now it's false
// and vice-versa.
if(bMenu) // Is the menu open?
{
static int menu_selection = 0; // start at menu index 0
// Yep...
if(GetAsyncKeyState(VK_UP) & 1) // If the up-key is down then we're
// decrementing the menu index.
if(menu_selection > 0)
menu_selection--;
else if(GetAsyncKeyState(VK_DOWN) & 1) // If the up key isn't down,
// but the down key is, we're
// incrementing the menu index
if(menu_select < (menu_length - 1))
menu_selection++;
else if((GetAsyncKeyState(VK_LEFT) & 1) || (GetAsyncKeyState(VK_RIGHT) & 1))
menus[menu_selection].bActivated = !menus[menu_selection].bActivated; // Toggle whether that hack is activated.
}
// Now just iterate through the menus turning off/on whatever is off/on
char buf[1024]; // Use this buffer to send commands.
for(int x = 0; x < menu_length; x++)
{
CAHack cur = menus[x];
if(cur.szConsoleCommand) == NULL) // If the command is null, just call the helper function and continue.
{
cur.lpfnHack(pDevice, cur.bActivated);
continue; // Go on to the next element in our array.
}
sprintf_s(buf, 1024, "%s %s", cur.szConsoleCommand, cur.bActivated ?cur.szActivatedValue : cur.szDefaultValue);
RunConsoleCommand(buf);
}
}
The CAHack struct is defined as so:
Code:
typedef void (* Hack_T)(LPDIRECT3DDEVICE9 pDevice, bool activated);
// Prototypes:
void SuperBullets(LPDIRECT3DDEVICE9, bool);
struct CAHack
{
const char* szDisplayName; // The name showed on the menu.
const char* szConsoleCommand; // The console command, or NULL
const char* szDefaultValue; // The value when the command is off.
const char* szActivatedValue; // The value when the command is on.
bool bActivated; // Is the hack activated?
Hack_T lpfnHack; // If the szConsoleCommand is NULL, we call this function.
}
CAHack menus[] =
{
{ "Show FPS", "ShowFps", "0", "1", false, NULL }
{ "Super Bullets", NULL, NULL, NULL, false, &SuperBullets }
}
void SuperBullets(LPDIRECT3DDEVICE9 pDevice, bool activated)
{
if(activated)
Nop(SUPER_BULLETS_ADDR, "\x90\x90\x90", 3);
else
Nop(SUPER_BULLETS_ADDR, "\x0F\x94\xC0", 3);
}
Forgive me if some of that has errors, I typed it up in the quick reply haha, but you should get a general idea of a better way to do it.
NOTE: In no way am I saying this is the best way, nor am I saying I'm a great programmer. I'm just trying to shed some light to the part of the community that is left in the dark.