17.01.2011, 18:12
No errors or w/e are shown when compiling.
When I add a car IG it will use the following snippet.
At first it will spawn 1 vehicle but when I check my carspawn.cfg before even gmxing the game I notice X (didn't count them!) amount of variables and there should be only 2 "strings" or "rows" of variables.
So basicly when I restart the server it extracts ALL those variables out of the .cfg and spawns them :X.
The savedynamiccars public is pretty basic:
When I add a car IG it will use the following snippet.
At first it will spawn 1 vehicle but when I check my carspawn.cfg before even gmxing the game I notice X (didn't count them!) amount of variables and there should be only 2 "strings" or "rows" of variables.
So basicly when I restart the server it extracts ALL those variables out of the .cfg and spawns them :X.
Код:
if(IsValidCar(vehid)) { CreateVehicle(vehid, x+1,y,z,angle,c1,c2, 320000); for(new i = 0; i < sizeof(DynamicCars); i++) { GetVehiclePos(i, vehx, vehy, vehz); if(PlayerToPoint(5.0, playerid, vehx, vehy, vehz)) { new vehicle; vehicle = GetPlayerVehicleID(playerid); DynamicCars[i][CarModel] = vehid; DynamicCars[i][CarX] = x; DynamicCars[i][CarY] = y; DynamicCars[i][CarZ] = z; DynamicCars[i][CarID] = vehicle; DynamicCars[i][Price] = price; DynamicCars[i][CarType] = type; DynamicCars[i][CarColor1] = c1; DynamicCars[i][CarColor2] = c2; DynamicCars[i][CarAngle] = GetPlayerFacingAngle(playerid, angle); DynamicCars[i][FactionCar] = 255; DynamicCars[i][Owned] = 0; Fuel[i] = GasMax; EngineStatus[i] = 0; VehicleLocked[i] = 0; SaveDynamicCars(); } } }
Код:
public SaveDynamicCars() { new idx; new File: file2; while (idx < sizeof(DynamicCars)) { new coordsstring[512]; format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d|%s|%d|%d|%d\n", DynamicCars[idx][CarModel], DynamicCars[idx][CarX], DynamicCars[idx][CarY], DynamicCars[idx][CarZ], DynamicCars[idx][CarAngle], DynamicCars[idx][CarColor1], DynamicCars[idx][CarColor2], DynamicCars[idx][FactionCar], DynamicCars[idx][CarType], DynamicCars[idx][Owner], DynamicCars[idx][CarID], DynamicCars[idx][Owned], DynamicCars[idx][Price]); if(idx == 0) { file2 = fopen("EG_Scriptfiles/Cars/carspawns.cfg", io_write); } else { file2 = fopen("EG_Scriptfiles/Cars/carspawns.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2); } return 1; }