money 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: money help (
/showthread.php?tid=237077)
money help -
tanush - 08.03.2011
How can i make people cant give others negative cash!
. And how i make this work if the player is near by
pawn Код:
COMMAND:givecash(playerid, params[])
{
new player, amount,name1[24], name2[24], string[128];
if(!sscanf(params, "ui",player,amount))
{
if(playerid != player)
{
if(GetPlayerMoney(playerid) >= amount)
{
GetPlayerName(playerid, name1, 24);
GetPlayerName(player, name2, 24);
format(string, sizeof(string), "You gaved $%d to %s.",amount,name2);
SendClientMessage(playerid, 0xFF9900AA, string);
format(string, sizeof(string), "%s gave you $%d!", name1, amount);
SendClientMessage(player, 0xFF9900AA, string);
GivePlayerMoney(playerid, -amount);
GivePlayerMoney(player, amount);
}
else return SendClientMessage(playerid, 0xAA3333AA,"You don't have that much.");
}
else return SendClientMessage(playerid, 0xAA3333AA,"You can't pay to yourself.");
}
else return SendClientMessage(playerid, 0xFF9900AA,"Usage: /givecash [ID] [Amount]");
return 1;
}
Re: money help -
admantis - 08.03.2011
try this
pawn Код:
COMMAND:givecash(playerid, params[])
{
new player, amount,name1[24], name2[24], string[128];
if(!sscanf(params, "ui",player,amount))
{
if(playerid != player)
{
if(GetPlayerMoney(playerid) >= amount && amount > 0)
{
new Float:dpX, Float:dpY, Float:dpZ;
GetPlayerPos(player, dpX, dpY, dpZ);
if (!IsPlayerInRangeOfPoint(playerid, 3, dpX, dpY, dpZ) return SendClientMessage(playerid, 0xAA3333AA, "This player is not near you");
GetPlayerName(playerid, name1, 24);
GetPlayerName(player, name2, 24);
format(string, sizeof(string), "You gaved $%d to %s.",amount,name2);
SendClientMessage(playerid, 0xFF9900AA, string);
format(string, sizeof(string), "%s gave you $%d!", name1, amount);
SendClientMessage(player, 0xFF9900AA, string);
GivePlayerMoney(playerid, -amount);
GivePlayerMoney(player, amount);
}
else return SendClientMessage(playerid, 0xAA3333AA,"You don't have that much.");
}
else return SendClientMessage(playerid, 0xAA3333AA,"You can't pay to yourself.");
}
else return SendClientMessage(playerid, 0xFF9900AA,"Usage: /givecash [ID] [Amount]");
return 1;
}
Re: money help -
tanush - 08.03.2011
you made a mistake with
pawn Код:
if (!IsPlayerInRangeOfPoint(playerid, 3, dpX, dpY, dpZ) return SendClientMessage(playerid, 0xAA3333AA, "This player is not near you");
cause u put one barack after playerinpoint.
thanks man
Re: money help -
admantis - 08.03.2011
Yeah sorry I missed a parentesis.Glad it worked.