Code:
void CHook::PlayerKilled() {
edict_t *pEdict = CREATE_ENTITY();
CALL_GAME_ENTITY(PLID, "player", &pEdict->v);
if (pEdict->pvPrivateData == NULL) {
REMOVE_ENTITY(pEdict);
return;
}
void **vtable = *((void***)(((char*)pEdict->pvPrivateData) + 0x94));
REMOVE_ENTITY(pEdict);
if(vtable == NULL)
return;
int **ivtable = (int **)vtable;
gHook.pKilled = (void *)ivtable[16];
mprotect(&ivtable[16], sizeof(int*), PROT_READ | PROT_WRITE);
ivtable[16] = (int *)PlayerKilled_Hook;
}
Using linux only so I'm using hard code.
It seems to work fine (used clientprintall to display who killed who, and it prints out correctly, even with bots)
Activating the hook in serveractivate_post