DWORD CWeapon::getActiveWeapon(DWORD dwPlayer) { DWORD dwWeaponHandle; g_pHack->readMemory((void*)(dwPlayer + 0xD28), &dwWeaponHandle, sizeof(dwWeaponHandle), NULL); if (dwWeaponHandle != -1) { DWORD dwEntityListAddress = g_pHack->m_dwClient + 0x2A2300 + 0x266B94; DWORD dwEntityList; g_pHack->readMemory((void*)(dwEntityListAddress), &dwEntityList, sizeof(dwEntityList), NULL); DWORD dwTemp = dwWeaponHandle; dwTemp &= 0xFFF; dwTemp += dwTemp; DWORD dwX = dwEntityList + dwTemp * 8 + 4; dwWeaponHandle >>= 0xC; DWORD dwValueX; g_pHack->readMemory((void*)(dwX + 0x4), &dwValueX, sizeof(dwValueX), NULL); if (dwWeaponHandle == dwValueX) { g_pHack->readMemory((void*)(dwX), &m_dwBaseAddress, sizeof(m_dwBaseAddress), NULL); return m_dwBaseAddress; } } m_dwBaseAddress = NULL; return m_dwBaseAddress; } int CWeapon::getWeaponId(void) { if (!m_dwBaseAddress) return 0; DWORD dwVTable = 0; g_pHack->readMemory((void*)m_dwBaseAddress, &dwVTable, sizeof(dwVTable), NULL); DWORD dwGetWeaponIdFunc = 0; g_pHack->readMemory((void*)(dwVTable + 0x58C), &dwGetWeaponIdFunc, sizeof(dwGetWeaponIdFunc), NULL); int iWeaponID = 0; g_pHack->readMemory((void*)(dwGetWeaponIdFunc + 0x1), &iWeaponID, sizeof(iWeaponID), NULL); return iWeaponID; } char* CWeapon::getWeaponAlias(int iWeaponID) { DWORD dwWeaponListAddress = g_pHack->m_dwClient + 0x2A2300 + 0x2761B0; for (int i = 0; i < 0x26; i++) { int iWeaponIDinArray = 0; g_pHack->readMemory((void*)(dwWeaponListAddress+8*i), &iWeaponIDinArray, sizeof(iWeaponIDinArray), NULL); if (iWeaponID == iWeaponIDinArray) { dwWeaponListAddress += 0x4; DWORD dwWeaponNameAddress = 0; g_pHack->readMemory((void*)(dwWeaponListAddress+8*i), &dwWeaponNameAddress, sizeof(dwWeaponNameAddress), NULL); char cLetter = 1; DWORD dwCurPos = dwWeaponNameAddress; int iLength = 0; while (cLetter != NULL) { g_pHack->readMemory((void*)dwCurPos, &cLetter, sizeof(cLetter), NULL); iLength++; dwCurPos++; } char *pcWeaponName = new char[iLength]; g_pHack->readMemory((void*)dwWeaponNameAddress, pcWeaponName, iLength, NULL); return pcWeaponName; } } return NULL; }
Announcement
Collapse
No announcement yet.
[CSS] weapon id + alias [external]
Collapse
X
-
[CSS] weapon id + alias [external]
Code:Tags: None
-
Re: [CSS] weapon id + alias [external]
That's seriously fucking ugly but gj at doing it.lolmaoman: Germans are born with a lifetime x22 login engraved into their birth certificates. True story.
-
Re: [CSS] weapon id + alias [external]
better and more readable code
PHP Code:dword GetClientEntityFromHandle ( dword handle )
{
dword offset, info[2];
if ( handle == -1 )
return 0;
offset = handle & ENT_ENTRY_MASK;
offset = (offset * 0x10) + 0x4;
if ( !hl2.readmem ( hl2.table.g_pEntityList, sizeof(dword) * 2, info, offset ) )
return 0;
if ( info[1] != (handle >> 12) ) // compare serial number
return 0;
return info[0];
}
PHP Code:if ( !hl2.readmem<dword> ( pl->dwBase, &hActiveWeapon, 0xD70 ) )
return false;
pl->weapon = GetClientEntityFromHandle ( hActiveWeapon );
PHP Code:int GetWeaponID ( dword vmt )
{
byte id;
dword tmp;
if ( vmt ) {
// get the address of this weapon's GetWeaponID vfunc
if ( hl2.readmem<dword> ( vmt, &tmp, 0x594 ) ) {
// read second byte for return value (it's always a static integer)
if ( hl2.readmem<byte> ( tmp, &id, 0x1 ) )
return (int)id;
}
}
return WEAPON_BASE;
}
PHP Code:void WeaponIDToAlias ( int iWeaponID, char* alias )
{
dword src, i, offset, tmp[ 2 ];
if ( !alias )
return;
strcpy ( alias, "none" );
if ( (iWeaponID < WEAPON_BASE) || (iWeaponID >= WEAPON_MAX) )
return;
// get the weaponid index
src = hl2.table.s_WeaponAliasInfo - 0x4;
for ( i = 0; i < WEAPON_MAX; i++ ) {
// read the string and ID for this index
offset = i * 0x8;
if ( !hl2.readmem ( src, sizeof(dword) * 2, tmp, offset ) )
return;
// compare
if ( tmp[0] == iWeaponID )
break;
}
// read the string
if ( !hl2.readstr ( (char*)tmp[1], alias ) )
strcpy ( alias, "none" );
}
PHP Code:bool IsPlayer ( dword vmt )
{
byte ret;
dword tmp;
if ( vmt ) {
// get address of IsPlayer virtual
if ( hl2.readmem<dword> ( vmt, &tmp, 0x1F8 ) ) {
// read return value
if ( hl2.readmem<byte> ( tmp, &ret, 0x1 ) )
return (ret == 1); // if false then it will be xor al, al
}
}
return false;
}
Last edited by phallus; 09-03-2013, 06:23 PM.
Comment
Comment