SA-MP Forums Archive
How to use sscanf to split a SQL row? - 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: How to use sscanf to split a SQL row? (/showthread.php?tid=230056)



How to use sscanf to split a SQL row? - DaneAMattie - 22.02.2011

Hello people,


I have an SQL Row received like this: INT|STRING|INT|INT|INT|blablabla many more int's

So how do i use sscanf (or any other way) to get a certain value of that sql string between a '|' like the int after the 5th '|'


Re: How to use sscanf to split a SQL row? - [L3th4l] - 22.02.2011

pawn Код:
sscanf(query, "p<|>s[50]if", string, int, float)..



Re: How to use sscanf to split a SQL row? - Sergei - 22.02.2011

sscanf(yourresultline,"p<|>is[64],iii", ... )


Re: How to use sscanf to split a SQL row? - DaneAMattie - 22.02.2011

Quote:
Originally Posted by Sergei
Посмотреть сообщение
sscanf(yourresultline,"p<|>is[64],iii", ... )
can you explain why the [64]?


Re: How to use sscanf to split a SQL row? - Hal - 22.02.2011

Quote:
Originally Posted by DaneAMattie
Посмотреть сообщение
can you explain why the [64]?
it follows the s which represents strings

s[stringsize]

check the sscanf topic for more info


Re: How to use sscanf to split a SQL row? - DaneAMattie - 22.02.2011

Quote:
Originally Posted by Hal
Посмотреть сообщение
it follows the s which represents strings

s[stringsize]

check the sscanf topic for more info
oke i did this:

Код:
sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii",
							  "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9);
but when i do a sendclientmessage it asks to add an array so i did (new Wapen1[5]; and SendClientMessage(playerid,COLOR_RED,Wapen1[4]); etc) now i see the client message as empty so its not filled with any value :S


Re: How to use sscanf to split a SQL row? - Hal - 22.02.2011

Quote:
Originally Posted by DaneAMattie
Посмотреть сообщение
oke i did this:

Код:
sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii",
							  "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9);
but when i do a sendclientmessage it asks to add an array so i did (new Wapen1[5]; and SendClientMessage(playerid,COLOR_RED,Wapen1[4]); etc) now i see the client message as empty so its not filled with any value :S
You dont need to put the string value where you call it, only in the new

SendClientMessage(playerid, COLOR_RED, Wapen);


Re: How to use sscanf to split a SQL row? - DaneAMattie - 23.02.2011

i have this:

pawn Код:
new Wapen1[35];
new Wapen2[35];
etc.


sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii", "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");

        SendClientMessageToAll(COLOR_RED, tmpSQLResult);//This result thing works but the split results not so
        SendClientMessageToAll(COLOR_RED, Wapen1);// this one is empty :(



Re: How to use sscanf to split a SQL row? - WackoX - 24.02.2011

Use explode.


Re: How to use sscanf to split a SQL row? - DaneAMattie - 24.02.2011

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Use explode.
.... how is this supposed to helping me?