SA-MP Forums Archive
sscanf help needed.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: sscanf help needed.. (/showthread.php?tid=118998)



sscanf help needed.. - SiJ - 06.01.2010

Hey,
Few weeks ago I've asked for a help getting this:
new GangNames [ 4 ] [ 20 ] =
{
"Gang Name 1",
"Gang Name 2",
"Gang Name 3",
"Gang Name 4"
};

from a file (using dini) which returns
"Gang Name 1, Gang Name 2, Gang Name 3, Gang Name 4"

Someone said, that it is possible using this:
pawn Код:
new Gangs[4][256];
sscanf(dini_Get("Gangs.info","Gangs"), "ssss", Gangs[0], Gangs[1], Gangs[2], Gangs[3]);
But this returns:
Gangs[0] = "Gang"
Gangs[1] = "Name"
Gangs[2] = "1,"
Gangs[3] = " Gang Name 2, Gang Name 3, Gang Name 4"

How can I make it to split strings where , is, but not on every space..?



Re: sscanf help needed.. - woot - 06.01.2010

Using p and your splitting character. So:

pawn Код:
new Gangs[4][256];
sscanf(dini_Get("Gangs.info","Gangs"), "p,ssss", Gangs[0], Gangs[1], Gangs[2], Gangs[3]);



Re: sscanf help needed.. - SiJ - 06.01.2010

Thanks..