Using sscanf 2.0...
#1

Quote:
Originally Posted by SAWC™
pawn Код:
Text(text[])
{
  new string[7][128];
  text = "this is a simple text| split into 2..."
  if(sscanf(text, "p<|>s[128]s[128]S(string[2])[128]S(string[3])[128]S(string[4])[128]S(string[5])[128]S(string[6])[128]")) printf(text);
  else for(new i = 0; i < 7; i ++) if(strlen(string[i]) > 0) SendClientMessageToAll(color, string[i]);
  return 1;
}
prints:
Код:
this is a simple text
split into 2...
string[2]
string[3]
string[4]
string[5]
string[6]
And I want it to print only the first 2 lines, how can I do it?
I know it should be posted at sscanf 2.0 topic but nobody is replying there, can somebody help fixing/teaching me how to use it in the right way?
Reply
#2

pawn Код:
Text(text[])
{
    new
        string[7][128];
    sscanf(text, "p<|>S(-1)[128]S(-1)[128]S(-1)[128]S(-1)[128]S(-1)[128]S(-1)[128]S(-1)[128]", string[0], string[1], string[2], string[3], string[4], string[5], string[6]);
    for(new i; i < sizeof string; i++) if(strval(string[i]) != -1) print(string[i]); //SendClientMessageToAll(color, string[i]);
    return 1;
}

public OnFilterScriptInit()
{
    Text("this is a simple text | split into 2...");
    return 1;
}
Delimiter one character.: No p<|n>
Reply
#3

That's not the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)