forward SaveDynamicCars();
public OnPlayerCommandText(playerid, cmdtext[]) { // Park your vehicle if(strcmp(cmdtext, "/park",true) == 0) { new vehicleid = GetPlayerVehicleID(playerid); new car = GetPlayerVehicleID(playerid) - 1; new Float:x,Float:y,Float:z; new Float:a; GetVehiclePos(vehicleid, x, y, z); // Gets vehicle pos GetVehicleZAngle(vehicleid, a); // Gets vehicle angle DynamicCars[car][CarX] = x; // Coords DynamicCars[car][CarY] = y; // Coords DynamicCars[car][CarZ] = z; // Coords DynamicCars[car][CarAngle] = a; // Angle DestroyVehicle(vehicleid); // Destoroy car CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1); // Creates car SaveDynamicCars(); // Save cars to file SendClientMessage(playerid,COLOR_WHITE,"SERVER: Your vehicle is now parked to here."); return 1; } return 1; }
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\n", DynamicCars[idx][CarModel], DynamicCars[idx][CarX], DynamicCars[idx][CarY], DynamicCars[idx][CarZ], DynamicCars[idx][CarAngle], DynamicCars[idx][CarColor1], DynamicCars[idx][CarColor2]); if(idx == 0) { file2 = fopen("vehicles/san_andreas.txt", io_write); } else { file2 = fopen("vehicles/san_andreas.txt", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2); } return 1; }
modelid, Float:spawn_x, Float:spawn_y,Float:spawn_z, Float:angle, color1, color2 ;
Originally Posted by dice7
Set debug messages. Does the code fail /park or SaveDynamicCars(); ?
|
... new vehicleid = GetPlayerVehicleID(playerid); new car = GetPlayerVehicleID(playerid) - 1; new Float:x,Float:y,Float:z; new Float:a; ... GetVehiclePos(vehicleid, x, y, z); // Gets vehicle pos GetVehicleZAngle(vehicleid, a); // Gets vehicle angle
DynamicCars[car][CarX] = x; // Coords DynamicCars[car][CarY] = y; // Coords DynamicCars[car][CarZ] = z; // Coords DynamicCars[car][CarAngle] = a; // Angle DestroyVehicle(vehicleid); // Destoroy car ...
Originally Posted by MadeMan
Did you tried it inside vehicle?
|
enum Cars { CarModel, Float:CarX, Float:CarY, Float:CarZ, Float:CarAngle, CarColor1, CarColor2, };
new DynamicCars[140][Cars];
Originally Posted by MadeMan
Do you have less than 140 cars in your server? If you have more then make the array bigger.
|
new DynamicCars[1900][Cars];