The method of doing this is really simple.
You might want to make this on your OnPlayerUpdate: Easy way of stopping money hacks
pawn Код:
if(GetPlayerMoney(playerid) != Player[playerid][Money])
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Player[playerid][Money]);
}
if(GetPlayerScore(playerid) != Player[playerid][Level])
{
SetPlayerScore(playerid, 0);
SetPlayerScore(playerid, Player[playerid][Level]);
}]
Change the variables, obviously.
Then, rather than your method you can do this:
pawn Код:
if(PlayerInfo[playerid][pCash] < 500) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
PlayerInfo[playerid][pRenting] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Enjoy your ride!");
PlayerInfo[playerid][pCash] -= 500;
Using the -= operator we can take a value away from a variable.
Don't do this, an exception will occur:
pawn Код:
PlayerInfo[playerid][pCash] - 500;