SA-MP Forums Archive
veh loading prob - 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: veh loading prob (/showthread.php?tid=220911)



veh loading prob - THE_KNOWN - 04.02.2011

heres my mysql loading part. the prob is the same veh keeps spawning endlessly. whats the prob in the script?

Код:
LoadOvehs()
{
	new query[128],Float:x,Float:y,Float:z,Float:r,mdl,vidid;
	format(query,128,"SELECT * FROM orgvehs ORDER BY VID ASC");
	mysql_query(query);
	mysql_store_result();
	new row[128];
	new field[13][128];
	new tmp;
	tmp = mysql_num_rows();
	mysql_fetch_row_format(row, "|");
	explode(row, field, "|");

	for(new i=1;i<=tmp;i++)
	{
	mdl=strval(field[1]);
	x=strval(field[2]);
	y=strval(field[3]);
	z=strval(field[4]);
	r=strval(field[5]);

	vidid=CreateVehicle(mdl,x,y,z+1,r,0,1,-1);
	vorg[vidid]=strval(field[0]);
	}
	mysql_free_result();
	return 1;
}



AW: veh loading prob - !Phoenix! - 04.02.2011

pawn Код:
for(new i=1;i<=tmp;i++)
You process the same string all the time (-> the same car) for each row fetched!

Use "mysql_retrieve_row" instead


Re: veh loading prob - THE_KNOWN - 04.02.2011

can you rewrite it for me?


AW: veh loading prob - !Phoenix! - 04.02.2011

I don't want because i want you to understand how it works ; )

With this function you simply can process the result row by row; visit the wiki-page


Re: veh loading prob - THE_KNOWN - 04.02.2011

i tried replacing for with while(mysql_retrieve_row()) but the same old problem exists


AW: veh loading prob - !Phoenix! - 04.02.2011

Did you simply replaced the loop?
That can't work - it would have the same effect.
I'll give you an example:

pawn Код:
new query[128];
format(query,128,"SELECT * FROM orgvehs ORDER BY VID ASC");
mysql_query(query);
mysql_store_result();
while(mysql_retrieve_row())
{
    //Fetch the fields - in each round (can you say round? oO) you will get the next row
}
mysql_free_result();