sscanf and zcmd question about commands with multi parameters
#2

Quote:
Originally Posted by Y_Leѕѕ
You need to check params is null, nothing else. sscanf will return a non null value if it fails (i.e. if they enter the wrong parameters).
Last few days I was looking at commands that use sscanf and I always see this condition:

pawn Code:
if (sscanf(params, "s", string)) SendClientMessage(playerid, COLOR_SOMETHING, "Usage: /command <string>");
But I will not need that in my every command because there will be 2-3-4 or more parameters and I don't want it to always return the same message.

So if the player types only for example "/safe" it will return message like "USAGE: /safe <option>" and if the player types "/safe put" it will return message "USAGE: /safe put <item>".

So this command in first post is written just fine?

And one more question... Can I use sscanf more that one time in one command?
Like if on second parameter there is one more parameter but only when I type "gun".

Example

Code:
/safe put gun gunid amount

and

/safe put drugs amount
So first it would be

pawn Code:
sscanf(params, "ss", option, item);
but under the "gun" check can I add this:

pawn Code:
sscanf(params, "is", gunid, amount);
and under the "drugs" check something like this

pawn Code:
sscanf(params, "s", amount);

And if I can do that should this part be changed sscanf(params, ...) or it stays that way?
Reply


Messages In This Thread
sscanf and zcmd question about commands with multi parameters - by Dujma - 20.11.2009, 18:02
Re: sscanf and zcmd question about commands with multi parameters - by Dujma - 20.11.2009, 18:18
Re: sscanf and zcmd question about commands with multi parameters - by Dujma - 20.11.2009, 18:54
Re: sscanf and zcmd question about commands with multi parameters - by Dabombber - 21.11.2009, 01:24

Forum Jump:


Users browsing this thread: 2 Guest(s)