03.07.2014, 15:13
I dont know how to make it spawn all the vehicles in the database... 
Could someone please help me?
I am trying to make a vehicle system for my gamemode and I have made the whole saving system for the vehicles. Just need them all to load and spawn. It loads the first vehicle in the database but not the rest, because I dont know how to make it loop through them all.
Here is my loading function:

Could someone please help me?
I am trying to make a vehicle system for my gamemode and I have made the whole saving system for the vehicles. Just need them all to load and spawn. It loads the first vehicle in the database but not the rest, because I dont know how to make it loop through them all.
Here is my loading function:
Код:
#define SCRIPT_CARS 1999
stock Load_Vehicles()
{
new Query[512], savestr[128], rows, fields;
mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Vehicles`");
mysql_query(dbHandle,Query);
cache_get_data(rows, fields);
if(rows)
{
cache_get_field_content(0, "ID", savestr); vInfo[SCRIPT_CARS][vID] = strval(savestr);
cache_get_field_content(0, "Owner", savestr); vInfo[SCRIPT_CARS][vOwner] = strval(savestr);
cache_get_field_content(0, "Model", savestr); vInfo[SCRIPT_CARS][vModel] = strval(savestr);
cache_get_field_content(0, "PosX", savestr); vInfo[SCRIPT_CARS][Pos][vX] = floatstr(savestr);
cache_get_field_content(0, "PosY", savestr); vInfo[SCRIPT_CARS][Pos][vY] = floatstr(savestr);
cache_get_field_content(0, "PosZ", savestr); vInfo[SCRIPT_CARS][Pos][vZ] = floatstr(savestr);
cache_get_field_content(0, "PosA", savestr); vInfo[SCRIPT_CARS][Pos][vR] = floatstr(savestr);
cache_get_field_content(0, "Color1", savestr); vInfo[SCRIPT_CARS][vColor1] = strval(savestr);
cache_get_field_content(0, "Color2", savestr); vInfo[SCRIPT_CARS][vColor2] = strval(savestr);
}
AddStaticVehicleEx(vInfo[SCRIPT_CARS][vModel], vInfo[SCRIPT_CARS][Pos][vX], vInfo[SCRIPT_CARS][Pos][vY], vInfo[SCRIPT_CARS][Pos][vZ], vInfo[SCRIPT_CARS][Pos][vR], vInfo[SCRIPT_CARS][vColor1], vInfo[SCRIPT_CARS][vColor2], 10000);
}

