Function Hook Problem/Question
#1

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(playeridamount)
{
    
ResetPlayerMoney(playerid);
    return 
GivePlayerMoney(playeridamount);

in my anticheat include (posted next to "inc_1", called "inc_2") for exemple i have this
PHP код:
stock S_Cheat_GivePlayerMoney(playeridmoney)
{
    if(
GetPlayerCheatStatus(CHEAT_PLAYER_MONEY) == trueS_PlayerInfo[playerid][PLAYER_MONEY]=GetPlayerMoney(playerid)+money;
    return 
GivePlayerMoney(playeridmoney);
}
#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(playeridamount);

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(playeridamount)
{
    if(
GetPlayerCheatStatus(CHEAT_PLAYER_MONEY) == trueS_PlayerInfo[playerid][PLAYER_MONEY]=amount;
    return 
SetPlayerMoney(playeridamount);
}
#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> 
Reply
#2

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 .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)