03.07.2011, 20:56
I made a code to save each car to their individual file upon server shutdown, however instead not creating files for vehicle IDs that return a model number out of the regular range, it just keeps going. why wont the is loop break?
Thanks in advance
Код:
public SaveVehicleData() { print("--- Saving Vehicles"); for (new vID = 1; vID <= 500; vID++) { model = GetVehicleModel(vID); if(model >= 400, model <= 611) { new carfile[20], percent[36]; GetVehiclePos(vID, posx, posy, posz); GetVehicleZAngle(vID, rotz); GetVehicleHealth(vID, chealth); GetVehicleDamageStatus(vID, panels, doors, lights, tires); if(vID > 1) { if(GetVehicleModel(vID-1) == 0) { format(carfile, sizeof(carfile), "Vehicles/%i.txt", vID-1); } else { format(carfile, sizeof(carfile), "Vehicles/%i.txt", vID); } } else if(vID == 1) { format(carfile, sizeof(carfile), "Vehicles/%i.txt", vID); } new INI:veh = INI_Open(carfile); INI_WriteInt(veh, "VEHICLE-ID", vID); INI_WriteInt(veh, "VEHICLE-MODEL", model); INI_WriteFloat(veh, "POSITION-X", posx); INI_WriteFloat(veh, "POSITION-Y", posy); INI_WriteFloat(veh, "POSITION-Z", posz); INI_WriteFloat(veh, "ROTATION-Z", rotz); INI_WriteFloat(veh, "HEALTH", chealth); INI_WriteInt(veh, "PANELS-DAMAGE", panels); INI_WriteInt(veh, "DOORS-DAMAGE", doors); INI_WriteInt(veh, "LIGHTS-DAMAGE", lights); INI_WriteInt(veh, "TIRE-DAMAGE", tires); INI_WriteInt(veh, "GOVERNMENT-VEHICLE", gVehicleData[vID][GOVERNMENT]); INI_WriteInt(veh, "POLICE-VEHICLE", gVehicleData[vID][POLICE]); INI_WriteInt(veh, "ARMY-VEHICLE", gVehicleData[vID][ARMY]); INI_WriteInt(veh, "FBI-VEHICLE", gVehicleData[vID][FBI]); INI_WriteInt(veh, "SANITATION-VEHICLE", gVehicleData[vID][SANITATION]); INI_WriteInt(veh, "DEALERSHIP-VEHICLE", gVehicleData[vID][DEALERSHIP]); INI_WriteInt(veh, "PUBLIC-TRANSPORTATION-VEHICLE", gVehicleData[vID][PUBLICTRANSPORT]); INI_WriteInt(veh, "VEHICLE-PRICE", gVehicleData[vID][PRICE]); INI_WriteInt(veh, "TRUCKING-VEHICLE", gVehicleData[vID][TRUCKING]); INI_WriteFloat(veh, "DEALER-SPAWN-X", gVehicleData[vID][DSPAWNX]); INI_WriteFloat(veh, "DEALER-SPAWN-Y", gVehicleData[vID][DSPAWNY]); INI_WriteFloat(veh, "DEALER-SPAWN-Z", gVehicleData[vID][DSPAWNZ]); INI_WriteFloat(veh, "DEALER-SPAWN-ZR", gVehicleData[vID][DSPAWNZR]); INI_Close(veh); TextDrawHideForAll(savingcars); TextDrawDestroy(savingcars); format(percent, sizeof(percent), "Saving Cars, %i Percent Completed", vID/5); savingcars = TextDrawCreate(10.0, 100.0, percent); TextDrawShowForAll(savingcars); } } TextDrawDestroy(savingcars); TextDrawHideForAll(savingcars); return 1; }