It's quite easy to convert a script from using client-side money to server-side money.
Everywhere the script reads
PHP код:
GetPlayerMoney(playerid)
Replace it with
PHP код:
Player_GetMoney(playerid)
Then, everywhere you have
PHP код:
GivePlayerMoney(playerid, amount)
Replace it by
PHP код:
Player_GiveMoney(playerid, amount)
Add this to your script as well:
PHP код:
Player_GiveMoney(playerid, amount)
{
PlayerMoney[playerid] = PlayerMoney[playerid] + amount;
}
Player_GetMoney(playerid)
{
return PlayerMoney[playerid];
}
PHP код:
forward MoneyTimer();
public MoneyTimer()
{
for (new playerid; playerid < MAX_PLAYERS; playerid++)
{
If (IsPlayerConnected(playerid)
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerMoney[playerid]);
}
}
}
And add this to OnGameModeInit:
PHP код:
SetTimer("MoneyTimer", 500, true);
And on top of your script, add this:
PHP код:
new PlayerMoney[MAX_PLAYERS];
This will store all money on the server inside the PlayerMoney array, The money-hackers don't have direct access to that array, so it's safe from hacking.
The timer is there to auto-update every player's money on their screen.
Your script can just add the value to your account (PlayerMoney array), the timer does the rest (updating the value on the client's screen every half a second).
Even if they hack money on their client and would be able to freeze the money-readout on their screen, the server will use the value stored in the array.
Even if they could freeze their readout on the client to $1 billion, while the server holds only $100 in the array, they still can't buy that house for $100000.
So it doesn't matter if they hack their client's money-readout, there is no need to GetPlayerMoney somewhere to check if they're hacking and banning them for it.