Sure! First off, you'll need
sscanf and
ZCMD.
Then put this ontop of your script:
pawn Код:
#include <ZCMD>
#include <sscanf2>
Now, you'll need to actually do some research on the sscanf topic to learn about operators and such, but it's well worth learning.
Here's a basic "shell" for a ZCMD command:
pawn Код:
COMMAND:pay(playerid, params[])
{
return 1;
}
Now we will add the code, starting with the beginning of the sscanf "declaration" i wanna call it, but it's obviously not, i just can't think of the word at the moment considering it's 8 AM.
pawn Код:
COMMAND:pay(playerid, params[])
{
new
PlayerBeingPaid,
AmountBeingPaidToPlayer;
if(sscanf(params, "ui", PlayerBeingPaid, AmountBeingPaidToPlayer))
//What happens if they don't use the correct syntax; Usage message?
return SendClientMessage(playerid, -1, "{FFFFFF}USAGE: /Pay [Player ID] [Amount]");
//The rest of your code - What happens if they do use the correct syntax?
if(GetPlayerMoney(playerid) >= AmountBeingPaidToPlayer) //Do they have enough money? If so, continue.
{
GivePlayerMoney(PlayerBeingPaid, AmountBeingPaidToPlayer);
GivePlayerMoney(playerid, -AmountBeingPaidToPlayer);
}
//If not - Error message
else return SendClientMessage(playerid, -1, "{FFFFFF}ERROR: You don't have enough money!");
return 1;
}
I hope i've actually taught you something.