veh loading prob
#1

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;
}
Reply
#2

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
Reply
#3

can you rewrite it for me?
Reply
#4

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
Reply
#5

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

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();
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)