Quote:
Originally Posted by Tanush123
You have Define MAX_VEHICLES or w/e on top of your script? if not just add
pawn Код:
public LoadVehicles() { new i; mysql_query("SELECT * FROM vehicles"); mysql_store_result(); new field[128][128]; if(mysql_num_rows() != 0) { VehicleInfo[i][cID] = strval(field[0]); VehicleInfo[i][cModel] = strval(field[1]); VehicleInfo[i][cPosX] = floatstr(field[2]); VehicleInfo[i][cPosY] = floatstr(field[3]); VehicleInfo[i][cPosZ] = floatstr(field[4]); VehicleInfo[i][cAngle] = floatstr(field[5]); VehicleInfo[i][cInterior] = strval(field[6]); VehicleInfo[i][cWorld] = strval(field[7]); VehicleInfo[i][cColor1] = strval(field[8]); VehicleInfo[i][cColor2] = strval(field[9]); VehicleInfo[i][cFaction] = strval(field[10]); VehicleInfo[i][cAlarm] = 0; VehicleInfo[i][cEngine] = 0; VehicleInfo[vehid][cFuel] = 100.0; AddStaticVehicle(VehicleInfo[i][cModel],VehicleInfo[i][cPosX],VehicleInfo[i][cPosY],VehicleInfo[i][cPosZ],VehicleInfo[i][cAngle],VehicleInfo[i][cColor1],VehicleInfo[i][cColor2]); LinkVehicleToInterior(i,VehicleInfo[i][cInterior]); SetVehicleVirtualWorld(i,VehicleInfo[i][cWorld]); } mysql_free_result(); return 1; }
if you do add
pawn Код:
public LoadVehicles() { for(new i=1; i<MAX_VEHICLE; i++)//edit the max_vehicle to urs { mysql_query("SELECT * FROM vehicles WHERE ID = '%d'",i); mysql_store_result(); new field[128][128]; if(mysql_num_rows() != 0) { VehicleInfo[i][cID] = strval(field[0]); VehicleInfo[i][cModel] = strval(field[1]); VehicleInfo[i][cPosX] = floatstr(field[2]); VehicleInfo[i][cPosY] = floatstr(field[3]); VehicleInfo[i][cPosZ] = floatstr(field[4]); VehicleInfo[i][cAngle] = floatstr(field[5]); VehicleInfo[i][cInterior] = strval(field[6]); VehicleInfo[i][cWorld] = strval(field[7]); VehicleInfo[i][cColor1] = strval(field[8]); VehicleInfo[i][cColor2] = strval(field[9]); VehicleInfo[i][cFaction] = strval(field[10]); VehicleInfo[i][cAlarm] = 0; VehicleInfo[i][cEngine] = 0; VehicleInfo[vehid][cFuel] = 100.0; AddStaticVehicle(VehicleInfo[i][cModel],VehicleInfo[i][cPosX],VehicleInfo[i][cPosY],VehicleInfo[i][cPosZ],VehicleInfo[i][cAngle],VehicleInfo[i][cColor1],VehicleInfo[i][cColor2]); LinkVehicleToInterior(i,VehicleInfo[i][cInterior]); SetVehicleVirtualWorld(i,VehicleInfo[i][cWorld]); } mysql_free_result(); } return 1; }
|
I know that the solution has been found, but do not do what's in that post. Looping a query is around 70 times slower than just using mysql_retrieve_row.