sscanf and zcmd question about commands with multi parameters
#3

Quote:
Originally Posted by Y_Leѕѕ
In that case you would need to do:

sscanf(params, "ssz", option, item, params);
sscanf(params, "is", gunid, amount);

That will store anything remaining in the string back in the string.

Quote:
Originally Posted by Dujma
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?
Not quite. As I said sscanf returns 0 if the parameters were correct. If it doesn't return 0 the values of the variables passed are undefined - so your isnull check may fail, but it may not - in which case you will be trying to do code on variables which are empty.
Thank you for your replies.

EDIT: Never mind... Tnx again...
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: 1 Guest(s)