06.09.2014, 11:39
So, ive made a server, running on a "Group" system, i am using this group system to run my gangs and vehicles which is totally fine, but i currently have 0 cars on my server, and i wanted to add some LSPD cars, setting the car group is fine, but saving the car is the problem, it always disappears,
Heres the /savecar command script:
This is the car file directory:
But weirdly, the cars do save to Vehciles.txt, it just doesnt load them
PS: I use /setcargroup to set the car group which also saves to .txt
Bit of Vehicles.txt (One Car Only):
Heres the /savecar command script:
Код:
command(savecar, playerid, params[]) { #pragma unused params if(Player[playerid][AdminLevel] >= 5) { if(UnconfirmedSave[playerid] == 0) { SendClientMessage(playerid, WHITE, "Are you sure you want to save this vehicle? Please re-type this command to confirm this action."); UnconfirmedSave[playerid] = 1; } else { UnconfirmedSave[playerid] = 0; if(IsPlayerInAnyVehicle(playerid)) { new id, Vehicle[16], vehicleid = GetPlayerVehicleID(playerid); id = findAvailableVehicleID(); format(Vehicle, sizeof(Vehicle), "V_%d", id); if(!djIsSet(VEHICLES_FILE, Vehicle)) // Fail-safe to prevent overwriting any current values { GetVehiclePos(vehicleid, Vehicles[id][CarPosX], Vehicles[id][CarPosY], Vehicles[id][CarPosZ]); GetVehicleZAngle(vehicleid, Vehicles[id][CarZAngle]); Vehicles[id][CarModel] = GetVehicleModel(vehicleid); Vehicles[id][CarGroup] = 0; Vehicles[id][CarColour1] = -1; Vehicles[id][CarColour2] = -1; djAutocommit(false); format(Vehicle, sizeof(Vehicle), "V_%d/PosX", id); djSetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosX], true); format(Vehicle, sizeof(Vehicle), "V_%d/PosY", id); djSetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosY], true); format(Vehicle, sizeof(Vehicle), "V_%d/PosZ", id); djSetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosZ], true); format(Vehicle, sizeof(Vehicle), "V_%d/ZAngle", id); djSetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarZAngle], true); format(Vehicle, sizeof(Vehicle), "V_%d/Model", id); djSetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarModel], true); format(Vehicle, sizeof(Vehicle), "V_%d/Col1", id); djSetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarColour1], true); format(Vehicle, sizeof(Vehicle), "V_%d/Col2", id); djSetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarColour2], true); format(Vehicle, sizeof(Vehicle), "V_%d/Group", id); djSetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarGroup], true); djCommit(VEHICLES_FILE); djAutocommit(true); CarCount++; printf("[system] Vehicle %d has been saved to %s.", id, VEHICLES_FILE); SendClientMessage(playerid, WHITE, "Vehicle saved!"); DestroyVehicle(vehicleid); Vehicles[id][GameID] = CreateVehicle(Vehicles[id][CarModel], Vehicles[id][CarPosX], Vehicles[id][CarPosY], Vehicles[id][CarPosZ], Vehicles[id][CarZAngle], Vehicles[id][CarColour1], Vehicles[id][CarColour2], 3600); PutPlayerInVehicle(playerid, Vehicles[id][GameID], 0); SendClientMessage(playerid, WHITE, "Do NOT despawn this vehicle."); for(new i = 0; i < SpawnedVehicles; i++) { if(AdminSpawned[i] == GetPlayerVehicleID(playerid)) { AdminSpawned[i] = 0; } } } else { new msgDiagnoseError[104]; format(msgDiagnoseError, sizeof(msgDiagnoseError), "[savecar] %s failed to insert in Vehicles.json. %s appears to already be set.", Vehicle, Vehicle); logError(msgDiagnoseError); SendClientMessage(playerid, WHITE, "There was an error attempting to save this vehicle, details of the error have been logged to 'scriptfiles/errors.txt'"); } } }
Код:
#define VEHICLES_FILE "Vehicles.txt"
PS: I use /setcargroup to set the car group which also saves to .txt
Bit of Vehicles.txt (One Car Only):
Код:
{"V_0":{"Col1":-1,"Col2":-1,"Group":0,"Model":596,"PosY":-1709.802124,"PosZ":5.610952,"ZAngle":359.229736},