Need Help - 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: Need Help (
/showthread.php?tid=243219)
Need Help -
Rokzlive - 22.03.2011
Ok, ive never worked with sscanf so i tried to make a loadvehicles stock using the only way i could think of. I tried this but i did not work at all, can someone convert it to sscanf?
pawn Код:
stock LoadVehicles()
{
new Query[255];
for(new id; id < MA; id++)
{
format(Query, sizeof(Query), "SELECT * FROM vehicles WHERE id= %d", id);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows())
mysql_fetch_field("Model", vehicledata[id][Model]);
mysql_fetch_field("x", vehicledata[id][POS][0]);
mysql_fetch_field("y", vehicledata[id][POS][1]);
mysql_fetch_field("z", vehicledata[id][POS][2]);
mysql_fetch_field("a", vehicledata[id][POS][3]);
mysql_fetch_field("Owner", vehicledata[id][Owner]);
mysql_fetch_field("Forsale", vehicledata[id][Forsale]);
mysql_fetch_field("Price", vehicledata[id][Price]);
new Color1 = random(126); new Color2 = random(126);
CreateVehicle(vehicledata[id][Model],vehicledata[id][POS][0],vehicledata[id][POS][1],vehicledata[id][POS][2],vehicledata[id][POS][3],Color1,Color2, 60*10000);
}
}
Re: Need Help -
Rokzlive - 22.03.2011
Plz help i really dont know how.
Re: Need Help -
Cameltoe - 22.03.2011
Quote:
Originally Posted by Rokzlive
Plz help i really dont know how.
|
I believe the query should be formated like this :
pawn Код:
format(Query, sizeof(Query), "SELECT field1, field2 etc here FROM vehicles WHERE id= %d", id);
Re: Need Help -
Rokzlive - 22.03.2011
But then how do i set what it gets to the variable. For example how do i assign what name it pulls from owner and set it to vehicledata[vehicleid][Owner]?
Re: Need Help -
Cameltoe - 22.03.2011
pawn Код:
mysql_fetch_row(Query, "|");
sscanf(Query, "p<|> i(int) s[string length](string) f(float)", vars here);