/givecash Help - 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: /givecash Help (
/showthread.php?tid=430534)
/givecash Help -
Areax - 14.04.2013
Hello!
I have a new command /givecash for players, so players can do /givecash [playerid] [amount] to give his cash to someone...But it doesn't work -.-
Can someone fix it?
Code:
PHP код:
CMD:givecash(playerid, params[])
{
new targetid, cash, string[160];
if(sscanf(params, "u", targetid, cash))return SendClientMessage(playerid, -1, "Usage: /givecash [playerid] [amount]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, -1, "ERROR: This Player is Not Connected.");
GivePlayerMoney(targetid, cash);
if(GetPlayerMoney(playerid) <= cash )return SendClientMessage(playerid, -1, "ERROR: You Don't Have Enough Money");
format(string, sizeof(string), "[INFO]: %s Has Given $%d Cash To %s", GetName(playerid), cash, GetName(targetid));
SendClientMessageToAll(-1, string);
return 1;
}
I get no errors or warnings...Thanks for your help
Re: /givecash Help -
RajatPawar - 14.04.2013
pawn Код:
if(sscanf(params, "ui", targetid, cash))
Re: /givecash Help -
[MG]Dimi - 14.04.2013
pawn Код:
if(sscanf(params, "ui", targetid, cash)) return
Re: /givecash Help -
M3mPHi$_S3 - 14.04.2013
PHP код:
CMD:givecash(playerid, params[])
{
new targetid, cash, string[160];
if(sscanf(params, "ui", targetid, cash))return SendClientMessage(playerid, -1, "Usage: /givecash [playerid] [amount]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, -1, "ERROR: This Player is Not Connected.");
GivePlayerMoney(targetid, cash);
if(GetPlayerMoney(playerid) <= cash )return SendClientMessage(playerid, -1, "ERROR: You Don't Have Enough Money");
format(string, sizeof(string), "[INFO]: %s Has Given $%d Cash To %s", GetName(playerid), cash, GetName(targetid));
SendClientMessageToAll(-1, string);
return 1;
}
Re: /givecash Help -
[MG]Dimi - 14.04.2013
I just realized your command doesn't make sense. First you give money and then you check does he actually have that amount & you never take money from him.
pawn Код:
CMD:givecash(playerid, params[])
{
new targetid, cash, string[160];
if(sscanf(params, "ui", targetid, cash)) return SendClientMessage(playerid, -1, "Usage: /givecash [playerid] [amount]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "ERROR: This Player is Not Connected.");
if(GetPlayerMoney(playerid) < cash ) return SendClientMessage(playerid, -1, "ERROR: You Don't Have Enough Money");
GivePlayerMoney(playerid, -cash);
GivePlayerMoney(targetid, cash);
format(string, sizeof(string), "[INFO]: %s Has Given $%d Cash To %s", GetName(playerid), cash, GetName(targetid));
SendClientMessageToAll(-1, string);
return 1;
}
Re: /givecash Help -
Isolated - 14.04.2013
Also, adding onto what Dimi is saying, do you know how much spam you will receive from people giving out 1$ at a time? It'll be constant.
Re: /givecash Help -
Areax - 14.04.2013
Thanks guys
Re: /givecash Help -
[MG]Dimi - 14.04.2013
Also to point out, make sure you check is cash > 0