Solved❓ Issue with grabbing current weapon ID

Posts 1–3 of 3 · Page 1 of 1
❓ Issue with grabbing current weapon ID
I'm writing my first internal hack right now and I'm trying to grab the weapon ID but I'm not getting the desired output. I'm sure I've messed up in more places than one, but all the guides I found that showed how to do this were for external cheats which shouldn't be hard to put into external but I'm a bit dumb, so bear with me.


Code:
// offsets
offsets.dwEntityList = 0x4D07DD4;
offsets.dwLocalPlayer = 0xCF5A4C;
offsets.m_hActiveWeapon = 0x2EF8;
offsets.m_iItemDefinitionIndex = 0x2FAA;

// client
uintptr_t pLocalPlayer = client + offsets.dwLocalPlayer;
uintptr_t pGlowObjectManager = client + offsets.dwGlowObjectManager;
uintptr_t pEntityList = client + offsets.dwEntityList;

Code:
DWORD weaponHandle = pLocalPlayer + offsets.m_hActiveWeapon;
DWORD entityID = weaponHandle & 0xFFF;
DWORD temp = client + pEntityList + (entityID - 1) * 0x10;
int weaponID = temp + offsets.m_iItemDefinitionIndex;
Any help will be greatly appreciated. If you're really helpful there's $5 in PayPal, Bitcoin, Ethereum, or LiteCoin with your name on it.
After spending another two hours tinkering with my code I realized what I was doing wrong. I was adding the pointers themselves rather than the values the pointers were pointing to. My corrected (and simplified) code is the following for anyone who has a similar issue in the future:


Code:
int weapon = *(int*)(LocalPlayer + offsets.m_hActiveWeapon);
int weaponEntity = *(int*)(client + offsets.dwEntityList + ((weapon & 0xFFF) - 1) * 0x10);
int weapondID = *(int*)(weaponEntity + offsets.m_iItemDefinitionIndex);
Problem solved, closed.
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us