Sscanf or strtok?? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sscanf or strtok?? (
/showthread.php?tid=238351)
Sscanf or strtok?? -
sim_sima - 11.03.2011
What is the best include for multi-parameter cmds?
Sscanf or strtok?
Respuesta: Sscanf or strtok?? -
Code8976Man - 11.03.2011
SSCANF
Re: Sscanf or strtok?? -
Calgon - 11.03.2011
sscanf. strtok is slow and outdated.
Re: Sscanf or strtok?? -
omer5198 - 11.03.2011
Quote:
Originally Posted by Calg00ne
sscanf. strtok is slow and outdated.
|
i am using strtok... but everyone says that sscanf is better... the problem is that i dont know how to use sscanf and nobody do a tutorial about it
Re: Sscanf or strtok?? -
Gh0sT_ - 11.03.2011
sscanf..
no tut? Look any tut about zcmd.
Re: Sscanf or strtok?? -
antonio112 - 11.03.2011
It ain`t that hard ... I`ll give you an example:
Let`s say a /slap command.
pawn Код:
new tempname;
if ( sscanf( params, "u", tempname ) )
return SendClientMessage( playerid, -1, "Usage: /slap <PlayerID>");
Now, you can use as many params as you want.
'u' means a playerid. If you want a string, use
's[128]' ( 128 is the string length )
I`ll give you another example. A /kick playerid reason command.
pawn Код:
new tempname, reason[ 128 ];
if ( sscanf( params, "us[128]", tempname, reason ) )
return SendClientMessage( playerid, -1, "Usage: /kick <PlayerID> [reason]");
See the difference? You need to use the string length, otherwise it won`t work.
Now, next, let`s say you want an integer. Just use
'i'. For floats use
'f'
A /sethealth playerid command example.
pawn Код:
new tempname, Float:temphealth;
if ( sscanf( params, "uf", tempname, temphealth ) )
return SendClientMessage( playerid, -1, "Usage: /sethealth <PlayerID> [Health] ");
Get it? It ain`t that hard. Hope I helped.
And to be On Topic,
sscanf is better.
Re: Sscanf or strtok?? -
Hashski - 11.03.2011
ZCMD and sscanf, They're easy once you know how.
Re: Sscanf or strtok?? -
admantis - 11.03.2011
Quote:
Originally Posted by omer5198
i am using strtok... but everyone says that sscanf is better... the problem is that i dont know how to use sscanf and nobody do a tutorial about it
|
must be joking
Re: Sscanf or strtok?? -
Montis123 - 11.03.2011
Sscanf very good and fast.
Re: Sscanf or strtok?? -
Medal Of Honor team - 11.03.2011
SSCANF IS EASY AND WELL FUNCTIONED