Sscanf or strtok??
#1

What is the best include for multi-parameter cmds?
Sscanf or strtok?
Reply
#2

SSCANF
Reply
#3

sscanf. strtok is slow and outdated.
Reply
#4

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
Reply
#5

sscanf..

no tut? Look any tut about zcmd.
Reply
#6

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.
Reply
#7

ZCMD and sscanf, They're easy once you know how.
Reply
#8

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
Reply
#9

Sscanf very good and fast.
Reply
#10

SSCANF IS EASY AND WELL FUNCTIONED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)