06.06.2012, 00:40
Okay, so I'm editing vortex 1, and I was going to make a /delcar, to delete the car your inside in-game, instead of Saving it.
I'm probably doing something wrong with DJson, or I'm an idiot, But I need some help!
here's the /delcar code
here's the errors
and here's the original /savecar
How's the delcar supposed to work?
I'm probably doing something wrong with DJson, or I'm an idiot, But I need some help!
here's the /delcar code
pawn Код:
command(delcar, playerid, params[])
{
#pragma unused params
if(Player[playerid][AdminLevel] >= 5)
{
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);
djUnsetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosX], true);
format(Vehicle, sizeof(Vehicle), "V_%d/PosY", id);
djUnsetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosY], true);
format(Vehicle, sizeof(Vehicle), "V_%d/PosZ", id);
djUnsetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarPosZ], true);
format(Vehicle, sizeof(Vehicle), "V_%d/ZAngle", id);
djUnsetFloat(VEHICLES_FILE, Vehicle, Vehicles[id][CarZAngle], true);
format(Vehicle, sizeof(Vehicle), "V_%d/Model", id);
djUnsetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarModel], true);
format(Vehicle, sizeof(Vehicle), "V_%d/Col1", id);
djUnsetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarColour1], true);
format(Vehicle, sizeof(Vehicle), "V_%d/Col2", id);
djUnsetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarColour2], true);
format(Vehicle, sizeof(Vehicle), "V_%d/Group", id);
djUnsetInt(VEHICLES_FILE, Vehicle, Vehicles[id][CarGroup], true);
djCommit(VEHICLES_FILE);
djAutocommit(true);
CarCount++;
printf("[system] Vehicle %d has been deleted from %s.", id, VEHICLES_FILE);
DestroyVehicle(vehicleid);
for(new i = 0; i < SpawnedVehicles; i++)
{
if(AdminSpawned[i] == GetPlayerVehicleID(playerid))
{
AdminSpawned[i] = 0;
}
}
}
else {
new
msgDiagnoseError[104];
format(msgDiagnoseError, sizeof(msgDiagnoseError), "%s: failed to delete the car in Vehicles.json. It doesn't exist.", GetName(playerid));
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'");
}
}
}
}
return 1;
}
Код:
C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26236) : error 017: undefined symbol "djUnsetFloat" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26238) : error 017: undefined symbol "djUnsetFloat" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26240) : error 017: undefined symbol "djUnsetFloat" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26242) : error 017: undefined symbol "djUnsetFloat" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26244) : error 017: undefined symbol "djUnsetInt" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26246) : error 017: undefined symbol "djUnsetInt" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26248) : error 017: undefined symbol "djUnsetInt" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26250) : error 017: undefined symbol "djUnsetInt" C:\Users\Connor\Desktop\Vortex1\gamemodes\VortexRoleplay.pwn(26279) : error 010: invalid function or declaration Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 9 Errors.
pawn Код:
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'");
}
}
}
}
return 1;
}