10.12.2016, 19:28
Make a sscanf before the strcmp to check for even more parameters, but make it optional so it doesn't have to be included.
(https://sampforum.blast.hk/showthread.php?tid=570927)
So simply:
Quote:
Originally Posted by The Great Emmet_
EVERY format specifier (that is, everything except '', {} and p) now has an optional equivalent - this is just their letter capitalised, so for example the old "z" optional string specifier is now "S" (there is still "z" and, for completeness, "Z", but both give warnings). In addition to optional specifiers, there are also now default values:
|
So simply:
Code:
new subcmd[10], subcmdval[128]; if (sscanf(params, "s[10]S()[128]", subcmd, subcmdval)) { //Return something if user doesn't put it anything for "s[10]"! } if (strcmp(subcmd, "kick", true)) { new targetid; if (sscanf(subcmdval, "u", targetid)) { //Return something if user did "/cmd kick" but didn't put any value afterwards! } // Continue what happens if id was given }