07.06.2015, 20:51
The easiest approach to sub or multi parameter commands is sscanf which is a string splitter. It takes a string apart based on a given range of specifiers(such as d, i, s, etc.)
I know you're not asking for code, but let's apart this example based on your command:
Basically the "ud" are the specifiers.
"u" - the playerID / partofname
"d" - an integer value
sscanf returns 1 if the string didn't contain the inputs, or was formatted incorrectly according to the specifiers. 0 is returned when it is able to split the strings.
I know you're not asking for code, but let's apart this example based on your command:
pawn Код:
CMD:givemoney(playerid, params[])
{
new giveplayerid, cash; // we need to define the inputs using sscanf
if(sscanf(params, "ud", giveplayerid, cash)) return SendClientMessage(playerid, -1, "USAGE: /givemoney [playerid] [cash]");
GivePlayerCash(giveplayerid, cash);
return 1;
}
"u" - the playerID / partofname
"d" - an integer value
sscanf returns 1 if the string didn't contain the inputs, or was formatted incorrectly according to the specifiers. 0 is returned when it is able to split the strings.