03.02.2015, 15:43
Just use a timer to update the client's money every second by the value stored on the server.
When you give a player some money, use something like this:
Somewhere in your script:
OnGameModeInit:
Then this timer will run for all players.
Even when a hacker hacks his client to display $1000000 and freeze the value, it won't do him any good.
This timer overwrites his money displayed onscreen.
Even if they manage to freeze it permanently, use the value stored on the server to buy everything in your script.
If the server holds $100, while they have hacked their client to display $1000000, they won't be able to buy anything more expensive than $100 as the server knows he has only $100.
Then it doesn't matter if they hack money, and you don't need to ban them either.
And there is no need to use GetPlayerMoney anywhere in your script to even check if they're hacking.
The only thing they would be able to buy with hacked money, is a soda can out of the drinking machines.
And that alone won't ruin your server.
When you give a player some money, use something like this:
pawn Код:
GivePlayerMoneyEx(playerid, amount)
{
Money[playerid] = Money[playerid] + amount;
}
pawn Код:
// This timer runs every second
forward GlobalTimer1000();
public GlobalTimer1000()
{
// Loop through all players and only run the timer for each player who's connected
for (new playerid; playerid < MAX_PLAYERS; playerid++)
if (IsPlayerConnected(playerid) == 1)
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Money[playerid]);
}
}
pawn Код:
SetTimer("GlobalTimer1000", 1000, true);
Even when a hacker hacks his client to display $1000000 and freeze the value, it won't do him any good.
This timer overwrites his money displayed onscreen.
Even if they manage to freeze it permanently, use the value stored on the server to buy everything in your script.
If the server holds $100, while they have hacked their client to display $1000000, they won't be able to buy anything more expensive than $100 as the server knows he has only $100.
Then it doesn't matter if they hack money, and you don't need to ban them either.
And there is no need to use GetPlayerMoney anywhere in your script to even check if they're hacking.
The only thing they would be able to buy with hacked money, is a soda can out of the drinking machines.
And that alone won't ruin your server.