Quote:
Originally Posted by dusk
so how is it different from sscanf
|
Sscanf splits the parameters, if you only have a one-parameter command (which you do), you don't need sscanf. Using params directly is better in that case, as it's faster - you don't need to split.
Also to make it clear: "isnull" isn't a "method" for making multi-parameter commands. Isnull is a function that checks if the string that the player entered is empty. Isnull is just a check, nothing else.
Why would you use sscanf when you can just directly use "params"?
Here's a little example, a command with sscanf:
pawn Код:
CMD:asd(playerid, params[]) {
new string[128];
if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, -1, "You haven't entered anything after '/asd'");
printf("%s", string);
return 1;
}
In that command, we created a string variable, after that sscanf took out the string part from params[] - but it didn't have to, because there's nothing to take out as it's only string.
We're pretty much splitting params from params.
You could just do it this way:
pawn Код:
CMD:asd(playerid, params[]) {
if(isnull(params)) return SendClientMessage(playerid, -1, "You haven't entered anything after '/asd'");
printf("%s", params);
return 1;
}
We just printed the params because we don't have to split anything from it anyway.