sscanf & sscanf
#1

How i would need to use scannf

First of all, using zcmd, Y-Less`s sscanf.

So i am converting a command.

In command i need to check if there is paramater as string.

and after that i`m using switch to check that string and if its right then i need to another checking - only for integrier

hope you all understood

So how it should look like:

pawn Код:
command line
{
    new name[15];
    if(sscanf(params, "s[15]", name)) return blablabla
    switch(name)
    {
         case 'buy':
         {
              //there i need another check ;S
          }
         case 'give':
         {
             // for example there i need 2 integriers need to use sscanf again for fast and stable code?
          }
}
So should i use sscanf again? or i can somehow put it all togather in one.

So this discussion is not only about ******`s sscanf.
Reply
#2

Sure you can use it twice. If each command has the same parameters you can get away with using it only once. You can change the sscanf line to include more parameters.
pawn Код:
sscanf(params, "s[15]ddd", name, numberOne, numberTwo, numberThree); // Three extra numbers
You seem like you have a basic grip on sscanf, maybe I misunderstood your question?

Edit: Also note that sscanf will not modify (or remove any part of) the original params string. So inside the case statements you will need to processing the original string again, but you can throw it away instead of storing it. You can use a quiet parameter by changing the sscanf string to "{s[15]}"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)