Function Hook Problem/Question - 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: Function Hook Problem/Question (
/showthread.php?tid=404204)
Function Hook Problem/Question -
xX_Simon_Xx - 02.01.2013
for exemple i have a my include (eg. called "inc_1") in my gm whit a lot of function/macros and so on
i have for exemple this stock
PHP код:
stock SetPlayerMoney(playerid, amount)
{
ResetPlayerMoney(playerid);
return GivePlayerMoney(playerid, amount);
}
in my anticheat include (posted next to "inc_1", called "inc_2") for exemple i have this
PHP код:
stock S_Cheat_GivePlayerMoney(playerid, money)
{
if(GetPlayerCheatStatus(CHEAT_PLAYER_MONEY) == true) S_PlayerInfo[playerid][PLAYER_MONEY]=GetPlayerMoney(playerid)+money;
return GivePlayerMoney(playerid, money);
}
#if defined _ALS_GivePlayerMoney
#undef GivePlayerMoney
#else
#define _ALS_GivePlayerMoney
#endif
#define GivePlayerMoney S_Cheat_GivePlayerMoney
Now if in my gm i do this
PHP код:
#include <inc_1>
#include <inc_2>
public OnSomeCallBackCall(playerid,...)
{
SetPlayerMoney(playerid, amount);
}
SetPlayerMoney work but "S_Cheat_GivePlayerMoney" isn't called why??
for fix this issue i have to do this in my anticheat
PHP код:
stock S_Cheat_SetPlayerMoney(playerid, amount)
{
if(GetPlayerCheatStatus(CHEAT_PLAYER_MONEY) == true) S_PlayerInfo[playerid][PLAYER_MONEY]=amount;
return SetPlayerMoney(playerid, amount);
}
#if defined _ALS_SetPlayerMoney
#undef SetPlayerMoney
#else
#define _ALS_SetPlayerMoney
#endif
#define SetPlayerMoney S_Cheat_SetPlayerMoney
It's the only solution in addition to this
PHP код:
#include <inc_2>
#include <inc_1>
Re: Function Hook Problem/Question - rjjj - 02.01.2013
The directive
#define replaces only codes which are below it
.
Thus, the
SetPlayerMoney's definition would be compiled with a call to the standard version of
GivePlayerMoney.
I hope that I have helped
.