Correct layout for a /pay command? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Correct layout for a /pay command? (
/showthread.php?tid=321663)
Correct layout for a /pay command? -
Luis- - 27.02.2012
pawn Код:
CMD:pay(playerid, params[])
{
new ID, amount;
if(sscanf(params, "ui", ID, amount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: {FFFFFF}/pay [ID] [Amount]");
if(amount > PlayerInfo[playerid][pCash])
return SendClientMessage(playerid, COLOR_WHITE, "ERROR: You don't have this much!");
if(amount < 0)
return SendClientMessage(playerid, COLOR_WHITE, "ERROR: Can't go below 0!");
if(ID == INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_WHITE, "ERROR: This ID is not connected!");
PlayerInfo[ID][pCash] += amount;
PlayerInfo[playerid][pCash] -= amount;
GivePlayerMoney(ID, PlayerInfo[ID][pCash]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
return 1;
}
It just gives me money as well as the other player.
Re: Correct layout for a /pay command? -
Walsh - 27.02.2012
Instead of doing this.
pawn Код:
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
It would seem more logical to do.
pawn Код:
GivePlayerMoney(playerid, -amount);
Since you want to subtract what they are paying instead of their total money.