04.12.2016, 15:54
The title says it all and this goes out to all you experienced scripters, what's the best way to make a anti-money hack and how would you implement it.
OnPlayerMoneyChange ( playerid ) {
new string [ 64 ] ;
if ( AC_GetPlayerMoney ( playerid ) != GetPlayerMoney ( playerid ) ) {
format ( string, sizeof ( string ), "ANTICHEAT: Serverside money: %d | Clientside money: %d", AC_GetPlayerMoney ( playerid ), GetPlayerMoney ( playerid ) );
SendClientMessage ( playerid, ANTICHEAT_COLOUR, string ) ;
}
return true ;
}
AC_GetPlayerMoney ( playerid ) {
OnPlayerMoneyChange ( playerid ) ;
return antiCheat_playerMoney [ playerid ] ;
}
AC_GivePlayerMoney ( playerid, amount ) {
antiCheat_playerMoney [ playerid ] += amount ;
OnPlayerMoneyChange ( playerid ) ; // Anti cheat
return GivePlayerMoney ( playerid, amount );
}
#define GivePlayerMoney AC_GivePlayerMoney
Since you saved me from creating my own thread, I'll hijack it with a question and also a possible example.
Would this be a viable anti cheat? Please tell me why not if it's not. PHP Code:
|
AC_GivePlayerMoney will give false warnings.
The order goes like this: variable change OnPlayerMoneyChange GivePlayerMoney So basically, you're calling the anticheat before giving the actual money. Which means the variable != the money, because you haven't given the money yet. |
PlayerMoney(playerid, amount = -1) {
static money[MAX_PLAYERS];
if(amount != -1) {
money[playerid] = amount;
GivePlayerMoney(playerid, amount - GetPlayerMoney(playerid));
}
return money[playerid];
}
// set
PlayerMoney(playerid, 5000);
// get
new amountOfMoneyPlayerHas = PlayerMoney(playerid);