16.01.2016, 12:44
I made this script so it spawns all vehicles from the database, but it only spawns the first car in the database.
This is my OnGamemodeInit.
This is my OnCarsLoad.
This is my OnGamemodeInit.
Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `vehicles`"); mysql_tquery(mysql, query, "OnCarsLoad");
Код:
public OnCarsLoad(vehicleid) { new tmp[256], string5[256]; cInfo[vehicleid][cModel] = cache_get_field_content_int(0, "carModel"); cInfo[vehicleid][cPosX] = cache_get_field_content_float(0, "carPosX"); cInfo[vehicleid][cPosY] = cache_get_field_content_float(0, "carPosY"); cInfo[vehicleid][cPosZ] = cache_get_field_content_float(0, "carPosZ"); cInfo[vehicleid][cPosF] = cache_get_field_content_float(0, "carPosF"); cInfo[vehicleid][cGroup] = cache_get_field_content_int(0, "carGroup"); cInfo[vehicleid][cVW] = cache_get_field_content_int(0, "carVirtualWorld"); cInfo[vehicleid][cColor1] = cache_get_field_content_int(0, "carColor1"); cInfo[vehicleid][cColor2] = cache_get_field_content_int(0, "carColor2"); cache_get_field_content(0, "carPlate", tmp, mysql), cInfo[vehicleid][cPlate] = strval(tmp); CreateVehicle(cInfo[vehicleid][cModel], cInfo[vehicleid][cPosX], cInfo[vehicleid][cPosY], cInfo[vehicleid][cPosZ], cInfo[vehicleid][cPosF], cInfo[vehicleid][cColor1], cInfo[vehicleid][cColor2], -1); SetVehicleVirtualWorld(vehicleid, cInfo[vehicleid][cVW]); SetVehicleNumberPlate(vehicleid, cInfo[vehicleid][cPlate]); vCount++; format(string5, sizeof(string5), " %d cars loaded from database.", vCount); print(string5); return 1; }