sscanf - triple string problems.
#1

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

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

So i've to p<> ??
Reply
#4

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)