SA-MP Forums Archive
Two string parameters(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: Two string parameters(sscanf) (/showthread.php?tid=544803)



Two string parameters(sscanf) - Metroplex - 04.11.2014

If I'd put two string parameters next to each other, the strlen of the first one will be zero, for such an unknown reason.
pawn Код:
new name[24], tag[3], string1[128];
    if(sscanf(params,"ss",name,tag)) return SPM(playerid, "USAGE: /createfaction [name] [tag]");
    if(strlen(name) < 5 || strlen(name) > 24) { format(string1, sizeof(string1), "%d",strlen(name)); return SPM(playerid, string1); }
    if(strlen(tag) != 3) return SPM(playerid, "ERROR: Faction tags consists only of 3 characters!");
//more code
Alright, I will tell you my bitmasking technique.

Command | Effect
/createfaction..........................returns the string length(0)
/createfaction Test...................returns the string length(4) as well
/createfaction Testi..................shows the SPM(playerid, "ERROR: Faction tags consists only of 3 characters!");
/createfaction Testing TST.........returns the string length as zero


Re: Two string parameters(sscanf) - DavidBilla - 04.11.2014

It's supposed to be "s[24]s[3]"


Re: Two string parameters(sscanf) - Metroplex - 04.11.2014

Now it kept saying the usage ones.

EDIT: Console says "sscanf error: System not initialised."


Re: Two string parameters(sscanf) - DavidBilla - 04.11.2014

You could use the 'p' specifier
Example:
sscanf(params,"p<.>s[24]s[3]",name,tag)

But in this case, the player has to use
/createfaction [name].[tag]

Anything that comes after the '.' will be considered as the tag. You can change the dot to any other special characters too.


Re: Two string parameters(sscanf) - Metroplex - 04.11.2014

How do I do it without the p<.> then?


Re: Two string parameters(sscanf) - DavidBilla - 04.11.2014

Try < >
But if that's the case, you cannot use spaces in between the name string.


Re: Two string parameters(sscanf) - Metroplex - 04.11.2014

Alright. Thanks for the help. REP+