18.07.2011, 02:20
Okay, let me show you something...
You will notice that you do not need to add the exclamation point (!) before calling sscanf. Above would be the proper way to use sscanf.
In your given code example, using sscanf for such a thing is worthless. You could easily use the in-built isnull function which is inside the ZCMD include. An example:
Okay, let's answer your questions:
1) That would most likely give you an error when you attempt to compile- it is pointless to change the length of the params variable.
2) Again, doing such would be pointless simply because you don't need to use sscanf there.
3) I believe strcmp is actually faster than using sscanf because it's already an in-built function. Also keep in mind that you cannot use the sscanf syntax with strcmp- it doesn't pick up on the differences between u, i/d, s, etc... When using strcmp it is to compare two strings, sscanf is used to extract data from a string.
I hope this has answered your questions. I would recommend reading the sscanf release thread before attempting to use it inside your mode.
pawn Code:
CMD:something(playerid, params[])
{
new id, value1, value2; // defining the variables for sscanf
if(!IsPlayerAdmin(playerid))
return false;
if(sscanf(params, "udd", id, value1, value2))
return // Send syntax message.
// More stuff here...
return 1;
}
In your given code example, using sscanf for such a thing is worthless. You could easily use the in-built isnull function which is inside the ZCMD include. An example:
pawn Code:
if(isnull(params)) // do something, the params are null (empty)
Okay, let's answer your questions:
1) That would most likely give you an error when you attempt to compile- it is pointless to change the length of the params variable.
2) Again, doing such would be pointless simply because you don't need to use sscanf there.
3) I believe strcmp is actually faster than using sscanf because it's already an in-built function. Also keep in mind that you cannot use the sscanf syntax with strcmp- it doesn't pick up on the differences between u, i/d, s, etc... When using strcmp it is to compare two strings, sscanf is used to extract data from a string.
I hope this has answered your questions. I would recommend reading the sscanf release thread before attempting to use it inside your mode.