Split() problem - 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: Split() problem (
/showthread.php?tid=186135)
Split() problem -
baske007 - 27.10.2010
Hi everyone,
I have a little problem with Split().
Why isn't this script working?
When I remove the split line, I see the test line in the server window. When I test it like this the test line doesnt even show.
pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
new data[256], field[3][32];
mysql_query("SELECT x, y, z FROM vehicles");
mysql_store_result();
while (mysql_fetch_row(data, "|"))
{
split(data, field, '|');
print("testline");
}
}
Thanks in advance
Re: Split() problem -
baske007 - 27.10.2010
For some reason the edit button doesn't work :S
I added the x y and z mysqlf in the database. I also tried just getting 2 text variables, but it just doesnt split them, and I dont see the testline :S
Re: Split() problem -
baske007 - 28.10.2010
-Bumpie-
Re: Split() problem -
Cameltoe - 28.10.2010
Quote:
Originally Posted by baske007
-Bumpie-
|
Use Sscanf.
pawn Код:
enum vInfo
{
Id,
Float:x,Float:y,Float:z,Float:a,
} // Make sure the database is structured like this too. ID ( Auto inc. ) - x - y - z -a. otherwise it won't work.
new VehicleInfo[MAX_VEHICLE][vInfo];
forward LoadVehicles();
public LoadVehicles()
{
for(new i; i < MAX_VEHICLES; i++)
{
new FetchLine[200];
mysql_query("SELECT * FROM vehicles WHERE id = %d");
mysql_store_result();
if(mysql_fetch_row(FetchLine,"|"))
{
printf("%s", FetchLine); // Debugging......
sscanf(FetchLine, "p<|>e<iffff>", VehicleInfo[i]);
printf("%s", FetchLine); // Debugging......
}
}
}