The point of using variables in this case is to not allow players to fake it, if a player cheats money, using GetPlayerMoney you will get the amount of money they cheated so a simple solution is to do something like this
new playerMoney[MAX_PLAYERS] = { 0, ...};
stock Player_GiveMoney(playerid, money) {
if (!IsPlayerConnected(playerid)) {
return 0;
}
playerMoney[playerid] += money;
return 1;
}
stock Player_SetMoney(playerid, money) {
if (!IsPlayerConnected(playerid)) {
return 0;
}
playerMoney[playerid] = money;
return 1;
}
stock Player_GetMoney(playerid) {
if (!IsPlayerConnected(playerid)) {
return 0;
}
return playerMoney[playerid];
}
as @peak mantle said, if you want to change the actual money in the hud you will also have to use the native functions in there, but just for display, and if you want to check if a player has the right amount of money you just do
new price = 500;
if (Player_GetMoney(playerid) < price) {
// code
}