Help - 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: Help - Command (
/showthread.php?tid=483927)
Help - Command -
Fjclip99 - 28.12.2013
Hello. I need some help to make a command.
The comand is /get mats [amount].
Now lets say that 1 mats is 5 dollars. and i buy it 200, that is 200 X 5 = 1000 dollars. How can i make so that it will take the right amount of money depending on how many mats you buy...
Thanks 4 help and sorry for my engilsh :P
Re: Help - Command - Emmet_ - 29.12.2013
Something like this would work:
pawn Код:
CMD:get(playerid, params[])
{
new
str[64],
name[24],
amount;
if (sscanf(params, "s[24]d", name, amount))
return SendClientMessage(playerid, -1, "Usage: /get <name> <amount>");
if (!strcmp(name, "mats", true))
{
if (amount < 1 || amount > 100000)
return 1;
new price = amount * 5;
if (GetPlayerMoney(playerid) < price)
return SendClientMessage(playerid, -1, "You don't have enough money.");
GivePlayerMoney(playerid, -price);
PlayerInfo[playerid][pMats] += amount;
format(str, sizeof(str), "You have purchased %d materials for $%d.", amount, price);
SendClientMessage(playerid, -1, str);
}
return 1;
}
Adjust it to your needs.
Re: Help - Command -
Fjclip99 - 29.12.2013
Thanks, it works
You are awsome :P