SA-MP Forums Archive
Best Anti-Money Hack Method (Server Sided Money) Discussion - 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)
+---- Forum: Discussion (https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Best Anti-Money Hack Method (Server Sided Money) Discussion (/showthread.php?tid=623736)



Best Anti-Money Hack Method (Server Sided Money) Discussion - Dorito - 04.12.2016

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.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Amads - 04.12.2016

Don't use default money system, create your own.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Abagail - 04.12.2016

The easiest way is to store players money in a variable, and update it when it changes(also should set the actual game money too when updating so the player sees the correct amount). If the players money gamewise isn't whats set, they might be hacking(you should also consider things such as lag or desync). Using this method, if you use your own variable for everything dealing with money in the script, they won't be able to do anything with money they hack.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Dignity - 04.12.2016

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:
OnPlayerMoneyChange playerid ) {
    new 
string 64 ] ;
    if ( 
AC_GetPlayerMoney playerid ) != GetPlayerMoney playerid ) ) {
        
format stringsizeof ( string ), "ANTICHEAT: Serverside money: %d | Clientside money: %d"AC_GetPlayerMoney playerid ), GetPlayerMoney playerid ) );
        
SendClientMessage playeridANTICHEAT_COLOURstring ) ;
    }
    return 
true ;
}
AC_GetPlayerMoney playerid ) {
    
OnPlayerMoneyChange playerid ) ;
    return 
antiCheat_playerMoney playerid ] ;
}
AC_GivePlayerMoney playeridamount ) {
    
antiCheat_playerMoney playerid ] += amount ;
    
OnPlayerMoneyChange playerid ) ; // Anti cheat
    
    
return GivePlayerMoney playeridamount );
}
#define GivePlayerMoney     AC_GivePlayerMoney 



Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Stinged - 04.12.2016

Quote:
Originally Posted by Dignity
View Post
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:
OnPlayerMoneyChange playerid ) {
    new 
string 64 ] ;
    if ( 
AC_GetPlayerMoney playerid ) != GetPlayerMoney playerid ) ) {
        
format stringsizeof ( string ), "ANTICHEAT: Serverside money: %d | Clientside money: %d"AC_GetPlayerMoney playerid ), GetPlayerMoney playerid ) );
        
SendClientMessage playeridANTICHEAT_COLOURstring ) ;
    }
    return 
true ;
}
AC_GetPlayerMoney playerid ) {
    
OnPlayerMoneyChange playerid ) ;
    return 
antiCheat_playerMoney playerid ] ;
}
AC_GivePlayerMoney playeridamount ) {
    
antiCheat_playerMoney playerid ] += amount ;
    
OnPlayerMoneyChange playerid ) ; // Anti cheat
    
    
return GivePlayerMoney playeridamount );
}
#define GivePlayerMoney     AC_GivePlayerMoney 
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.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Logic_ - 04.12.2016

I'd do as said by Abagail.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Dignity - 04.12.2016

Quote:
Originally Posted by Stinged
View Post
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.
Hey, thanks man. Didn't really test it yet, so it was just a draft. I'll edit it


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - Vince - 04.12.2016

You should only really be checking if client side money is more than what it should be. Doesn't really matter if it's less. If the default shops or the vending machines are active in your server then the anti-cheat will notice an anomaly and it will flag the player as a cheater.


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - SickAttack - 07.12.2016

The best method would definitely be:
1. Save the amount of money the player has in an array
2. Hook the native functions so it uses the array
3. Update the player's money on their HUD to the value the array holds
4. Don't include a detection, just set the displayed value on the player's HUD to the value the array holds when the player's money changes


Re: Best Anti-Money Hack Method (Server Sided Money) Discussion - theYiin - 17.12.2016

PHP Code:
PlayerMoney(playeridamount = -1) {
  static 
money[MAX_PLAYERS];
  if(
amount != -1) {
    
money[playerid] = amount;
    
GivePlayerMoney(playeridamount GetPlayerMoney(playerid));
  }
  return 
money[playerid];
}
// set
PlayerMoney(playerid5000);
// get
new amountOfMoneyPlayerHas PlayerMoney(playerid);