loading cars from mysql - 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: loading cars from mysql (
/showthread.php?tid=245693)
loading cars from mysql -
THE_KNOWN - 01.04.2011
Код:
[17:20:11] ---------------------------
[17:20:11] MySQL Debugging activated (04/01/11)
[17:20:11] ---------------------------
[17:20:11]
[17:20:11] >> mysql_query( Connection handle: 1 )
[17:20:11] CMySQLHandler::Query(SELECT * FROM `orgvehs`) - Successfully executed.
[17:20:11] >> mysql_store_result( Connection handle: 1 )
[17:20:11] CMySQLHandler::StoreResult() - Result was stored.
[17:20:11] >> mysql_retrieve_row( Connection handle: 1 )
[17:20:11] >> mysql_num_rows( Connection handle: 1 )
[17:20:11] CMySQLHandler::NumRows() - Returned 3 row(s)
[17:20:11] >> mysql_fetch_row_format( Connection handle: 1 )
[17:20:11] CMySQLHandler::FetchRow() - Return: 1|415|-296.60815|1575.80066|75.13008|135.73683|0|0|265
[17:20:11] >> mysql_retrieve_row( Connection handle: 1 )
[17:20:11] >> mysql_retrieve_row( Connection handle: 1 )
[17:20:11] >> mysql_free_result( Connection handle: 1 )
[17:20:11] CMySQLHandler::FreeResult() - Result was successfully free'd.
[17:20:11] ---------------------------
[17:20:11] MySQL Debugging de-activated
[17:20:11] ---------------------------
Код:
stock LoadOvehs()
{
mysql_debug(1);
new query[128];
format(query,128,"SELECT * FROM `orgvehs`");
mysql_query(query);
mysql_store_result();
while(mysql_retrieve_row())
{
new field[13][128],c1,c2;
if(mysql_num_rows() == 0) continue;
mysql_fetch_row_format(query, "|");
explode(query, field, "|");
new mdl,vidid,Float:x,Float:y,Float:z,Float:r;
mdl=strval(field[1]);
x=strval(field[2]);
y=strval(field[3]);
z=strval(field[4]);
r=strval(field[5]);
c1=strval(field[6]);
c2=strval(field[7]);
vidid=CreateVehicle(mdl,x,y,z+0.2,r,c1,c2,-1);
vorg[vidid]=strval(field[0]);
mysql_retrieve_row(1);
}
mysql_free_result();
mysql_debug(0);
return 1;
}
thats how i load the vehicles from mysql but the thing is if there are 3 vehicles in the table atm only 1 loads from them.. please see the log, it just retrieves rows again and doesnt fetch them can you tell me whats goin on?
Re: loading cars from mysql -
mprofitt - 01.04.2011
you don't think this is causing an issue?
Код:
mysql_retrieve_row(1);
Re: loading cars from mysql -
THE_KNOWN - 02.04.2011
same issue removing it. any suggestions?
Re: loading cars from mysql -
Alby Fire - 02.04.2011
pawn Код:
stock LoadOvehs()
{
mysql_debug(1);
new
query[128],
field[13][128],
c1,
c2;
mysql_query("SELECT * FROM `orgvehs`");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(query))
{
mysql_fetch_row_format(query, "|");
explode(query, field, "|");
new mdl,vidid,Float:x,Float:y,Float:z,Float:r;
mdl=strval(field[1]);
x=strval(field[2]);
y=strval(field[3]);
z=strval(field[4]);
r=strval(field[5]);
c1=strval(field[6]);
c2=strval(field[7]);
vidid=CreateVehicle(mdl,x,y,z+0.2,r,c1,c2,-1);
vorg[vidid]=strval(field[0]);
}
}
mysql_free_result();
mysql_debug(0);
return 1;
}
Try this.