Two string parameters(sscanf)
#1

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

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

Now it kept saying the usage ones.

EDIT: Console says "sscanf error: System not initialised."
Reply
#4

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

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

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

Alright. Thanks for the help. REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)