23.02.2016, 22:52
PHP код:
public OnGameModeInit()
{
SetTimer("MoneyTimer", 1000, true);
return 1;
}
forward MoneyTimer();
public MoneyTimer()
{
for (new playerid; playerid < MAX_PLAYERS; playerid++)
{
if (IsPlayerConnected(playerid))
{
// Update the player's money on the client with the value stoed on the server
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerData[playerid][pMoney]);
}
}
return 1;
}
Just use a timer with interval of 1 second and let that timer update the client's money with the value stored on the server.
Why even check if the player is cheating? When you have server-sided money, that cheat is useless anyway.
If your script uses the value stored on the server to buy anything on your server, they can cheat as much as they want and get nowhere.
Even if they manage to freeze the displayed money on their client and set it to $2 billion, your server knows they only have $1000 for example.
Your script won't let them buy something that's being sold for $150000.
It would be funny to have $2 billion on their screen and they wanna buy a house worth $150000 and they get the message: "you don't have enough money". Because the server only holds $1000 in their account.
They will only fool themselves by displaying fake money on their own screen.
Never use GetPlayerMoney and you'll be fine.
And using OnPlayerUpdate for such a thing is overkill.

