SA-MP Forums Archive
Getting strings of a table - 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: Getting strings of a table (/showthread.php?tid=92051)



Getting strings of a table - woot - 18.08.2009

Alright .. this is how my table looks like, and a row just to test shit.


pawn Код:
new ID = 0, Float:Spawn_X, Float: Spawn_Y, Float: Spawn_Z, Fee, Till, Owner[24], Name[128];
        sscanf( line , "p|ifffiiss" , ID, Spawn_X, Spawn_Y, Spawn_Z, Fee, Till, Owner, Name);
        printf("[BIZ] %s (ID: %i | Owner: %s) set up!", Name, ID, Owner);
The string "Name" is empty, while "Owner" contains "Noone LV Rent-a-Car"

Anyone a clue on how to prevent that? Pretty annoying


Re: Getting strings of a table - dice7 - 18.08.2009

Try something like this
pawn Код:
new string[128];
sscanf( line , "p|ifffiiz" , ID, Spawn_X, Spawn_Y, Spawn_Z, Fee, Till, string);
sscanf( string, "p|sz", Owner, Name);
or

pawn Код:
sscanf( line , "ifffiisz" , ID, Spawn_X, Spawn_Y, Spawn_Z, Fee, Till, Owner, Name);



Re: Getting strings of a table - MenaceX^ - 18.08.2009

Try strmid.


Re: Getting strings of a table - woot - 18.08.2009

@dice7: Nope, p| is required since it splits everything with a "|" (needed with mysql rows)
"z" is an optionable string, didn't work either, same outcome with the 2 methodes ..

@MenaceX^: If you got any example, sure, like never used strmid and the wiki doesn't really help. I guess I'd have to totally re-write it then with all that strval strfloat and shit, which I really hate and just bugs for me, lol.

EDIT: I tried using explode and split, both just comes up with empty values, (strings empty, values are 0)

http://pastebin.com/d19e23ea


Re: Getting strings of a table - woot - 18.08.2009

Fixed, i didn't need to split it using p| , works now. :3

/lock