example
pawn Код:
CMD:getmoney(playerid, params[])
{
new amount;
if (sscanf(params, "i", amount) ) return SendClientMessage(playerid, -1, "Usage: /getmoney <amount>");
GivePlayerMoney(playerid, amount);
return 1;
}
In this example sscanf will extract the integer(amount) from the string(params)
Read more about sscanf here
https://github.com/Y-Less/sscanf/wik...nners-Tutorial
-----------
Edit:
PS: in the previous example you can just use strval(params), I just provided a simple example,
for example if you want to make a /givemoney (playerid/playername) (amount) CMD , sscanf will be very useful:
pawn Код:
CMD:givemoney(playerid, params[])
{
if (IsPlayerAdmin(playerid))
{
new id,amount;
new string[2][128], name[2][MAX_PLAYER_NAME+1];
if (sscanf(params, "ui", id, amount)) SendClientMessage (playerid, 0xFFFFFFFF, "Usage: /givemoney [Player ID] [Amount]");
else if (id == INVALID_PLAYER_ID ) SendClientMessage (playerid, 0xFF0000AA, "Invalid ID");
else if (amount == 0) SendClientMessage(playerid, 0xFF0000AA, "Amount can't be 0$");
else
{
GivePlayerMoney(id, amount);
GetPlayerName(playerid, name[0], sizeof(name[]));
GetPlayerName(id, name[1], sizeof(name[]));
format(string[0], sizeof(string[]), "You have recieved %i$ from %s",amount, name[0]);
format(string[1], sizeof(string[]), "You have given %s %i$",name[1],amount);
SendClientMessage(playerid, 0xFFFFFFF, string[0]);
SendClientMessage(id, 0xFFFFFFF, string[1]);
}
}
return 1;
}