SA-MP Forums Archive
[HELP]Little doubt with sscanf. - 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)
+--- Thread: [HELP]Little doubt with sscanf. (/showthread.php?tid=304237)



[HELP]Little doubt with sscanf. - [DOG]irinel1996 - 17.12.2011

Hi!
I have a little doubt with sscanf, I tried solve it by myself, but unfortunatly I couldn't.
Well, I have this:
pawn Код:
if(strcmp(x_nr,"Cuenta",true) == 0)
And I want "convert" it to sscanf, I tried something like this, but it doesn't work.
pawn Код:
if(!sscanf(params, "Cuenta", "s", opcion))
I never tried something like that in sscanf, and I don't know if it's possible make this.

NOTE: I'm using ZCMD, this is for a "/help [Option]" command.

Well, thank you all.

Best regards!


Re: [HELP]Little doubt with sscanf. - Ash. - 17.12.2011

What is actually supposed to do? To get data from any input string, you need to use sscanf specifiers (of which are described on the main post in the topic about sscanf).

https://sampforum.blast.hk/showthread.php?tid=120356


Re: [HELP]Little doubt with sscanf. - Calgon - 17.12.2011

You're not using sscanf properly.

You can't use sscanf to replace strcmp, you use it to split strings. But you only have one string, so there's no point in splitting it.

pawn Код:
CMD:help(playerid, params[]) {
   if(!strcmp(params, "Cuenta")) {
      // Your code here.
   }
   return 1;
}
The 'params' variable holds everything that's typed after the command, if there's just one thing, then you might as well just use 'params' directly, like I've done in the code example above.


Respuesta: [HELP]Little doubt with sscanf. - [DOG]irinel1996 - 17.12.2011

I thought I can do it with sscanf, hehe...
I already know use strcmp. But thank you!

Best regards!


Re: [HELP]Little doubt with sscanf. - Calgon - 17.12.2011

You can do it with sscanf, but it's pointless. You only have a single string. It's wise to use sscanf to split multiple variables, and you clearly didn't know about the 'params' with strcmp in zcmd.


Respuesta: Re: [HELP]Little doubt with sscanf. - [DOG]irinel1996 - 17.12.2011

Quote:
Originally Posted by Calgon
Посмотреть сообщение
You can do it with sscanf, but it's pointless. You only have a single string. It's wise to use sscanf to split multiple variables, and you clearly didn't know about the 'params' with strcmp in zcmd.
I could make it with strcmp by myself, but I thought with sscanf it's more optimized. lol
Thanks anyway.
pawn Код:
//I know about strcmp in zcmd. ;)
COMMAND:help (playerid, params[])
{
    if(isnull(params))
    {
        //info about help options. xd
        return 1;
    }
    if(strcmp(params,"lol1",true) == 0)
    {
       //lalala
    }
    else if(strcmp(params,"lol2",true) == 0)
    {
        //lsgds
    }
    else if(strcmp(params,"lol3",true) == 0)
    {
        //aham xd
    }
    else SendClientMessage(playerid,-1,"etc... etc...");
    return 1;
}
//xD