View Single Post
thatguyzp
Junior Member
Join Date: Mar 2009
Old 12-17-2012 , 13:40   Re: Metamod respawn problem.
Reply With Quote #3

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

Last edited by thatguyzp; 12-17-2012 at 13:44.
thatguyzp is offline