Raised This Month: $66 Target: $400
 16% 

Metamod respawn problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thatguyzp
Junior Member
Join Date: Mar 2009
Old 12-17-2012 , 01:34   Metamod respawn problem.
Reply With Quote #1

I've hooked player::killed, however I'm having an issue with respawning the player on death.

Code:
void PlayerKilled_Hook(void *victim, entvars_t *attacker, int gib) {
    //pre

    reinterpret_cast<int (*)(void *, entvars_t *, int)>(gHook.pKilled)(victim, attacker, gib);

    //post
    *((int *)(*(entvars_t **)victim)->pContainingEntity->pvPrivateData + m_iNumRespawn) = 0;
}
It works for the first person that dies, then doesn't after that.

I'm testing right now with bots, so maybe that's whats messing it up?
thatguyzp is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-17-2012 , 09:58   Re: Metamod respawn problem.
Reply With Quote #2

Show more of your code. How are you hooking that function?
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
thatguyzp
Junior Member
Join Date: Mar 2009
Old 12-17-2012 , 14: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 14:44.
thatguyzp is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2012 , 19:27   Re: Metamod respawn problem.
Reply With Quote #4

Set that offset to 0 is not enough to make the game respawn player.

In Post Kill you can just set pev->deadflag to DEAD_RESPAWNABLE and it gonna respawn players.
__________________
- tired and retired -
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:47.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode