Best Anti-Money Hack Method (Server Sided Money) Discussion
#1

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

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

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

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 
Reply
#5

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

I'd do as said by Abagail.
Reply
#7

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
Reply
#8

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

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
Reply
#10

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); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)