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



sscanf - triple string problems. - JaKe Elite - 01.12.2012

I'm having problem with triple strings..

If type

[code]
/test (string1)hey hey hey (string2)Ok (string3)No

it will show as

"Word: hey, Selection: hey, Selection2: hey"

I won't give original code however. I need the solution to fix it.

Here is the code (example)

pawn Код:
new string1[128], string2[128], string3[128];
if(sscanf(params, "s[128]s[128]s[128]", string1, string2, string3)) return SetPlayerHealth(playerid, 0.0);



Re: sscanf - triple string problems. - ReneG - 01.12.2012

There is hardly anything you can do. Without the p<> specifier, samp-sscanf automatically splits strings into the passed variables by spaces. sscanf won't know when to start/stop searching for the next string when it sees
Код:
hey hey hey hey hey hey hey hey hey
You'll have to do whatever you're doing another way.


Re: sscanf - triple string problems. - JaKe Elite - 01.12.2012

So i've to p<> ??


Re: sscanf - triple string problems. - Nordic - 01.12.2012

pawn Код:
new string[] = "hey hey hey,whats,up";
new str1[42], str2[42], str3[42];
sscanf(string, "p<,>s[42]s[42]s[42]", str1, str2, str3);
printf("%s | %s | %s", str1, str2, str3);
you get this

Код:
hey hey hey | whats | up
u gotta assign some other symbol to split that hopefully this helped.


Re: sscanf - triple string problems. - JaKe Elite - 01.12.2012

How can i split it when inside of CMD (zcmd)


Re: sscanf - triple string problems. - Nordic - 01.12.2012

It's the same, you replace the variable "string" with "params"

pawn Код:
CMD:test(playerid, params[])
{
    new str1[42], str2[42], str3[42];
    sscanf(params, "p<,>s[42]s[42]s[42]", str1, str2, str3);
    printf("%s | %s | %s", str1, str2, str3);
    return 1;
}
and in game you just type /test hey hey hey,whats,up