SA-MP Forums Archive
hooking native function in a filterscript - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: hooking native function in a filterscript (/showthread.php?tid=441719)



hooking native function in a filterscript - ZoZZ - 04.06.2013

i was making a filterscript for a gamemode i needed to hook PlayerSpectatePlayer in the filterscript but it just doesnt work .. when i type /spec [id] (which is a command in the main gamemode) it doesnt print "hooking"

pawn Код:
// this is in filterscript
stock _ALT_PlayerSpectatePlayer(playerid, targetplayerid, mode = SPECTATE_MODE_NORMAL)
{
    print("hooking")
    specID[playerid] = targetplayerid;
    return PlayerSpectatePlayer(playerid, targetplayerid, mode);
}

#if defined _ALS_PlayerSpectatePlayer
    #undef PlayerSpectatePlayer
#else
    #define _ALS_PlayerSpectatePlayer
#endif
#define PlayerSpectatePlayer _ALT_PlayerSpectatePlayer
please note that i dont have the source code of the main gamemode thats why i use a filterscript


Re: hooking native function in a filterscript - SuperViper - 04.06.2013

You can't hook a function in a filterscript because defines don't apply cross-script whereas includes are actual addons to the gamemode, not a separate script.