24.08.2012, 06:24
Hello, When in my script there's /vehiclesave cmd, when i use it it's works fine before the gmx.
but when i do the gmx it dosen't save the vehicle.
please help me.
but when i do the gmx it dosen't save the vehicle.
please help me.
PHP код:
dcmd_vehicle(playerid, params[])
{
new carid, string[ 128 ], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id;
if( sscanf( params, "d", carid) )
{
if( PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pGangMod] == 1)
{
SendClientMessage( playerid, COLOR_WHITE, "USAGE: /vehicle [vehicleid]" );
}
}
else
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
if(CarCount < MAX_VEHICLES)
{
if(carid < 400 || carid > 611)
{
SendClientMessage( playerid, COLOR_WHITE, "Valid car IDs start from 400, ending at 611." );
return 1;
}
GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
physical_car_id = CreateVehicle(carid, CarToX, CarToY, CarToZ, 90, -1, -1, -1);
format( string, sizeof( string ), "You have spawned vehicle model %d. If you wish to save this, type .", carid);
VehicleSpawned[SpawnedVehicles] = physical_car_id;
SpawnedVehicles++;
SendClientMessage( playerid, COLOR_WHITE, string);
PutPlayerInVehicle( playerid, physical_car_id, 0 );
LinkVehicleToInterior(physical_car_id, GetPlayerInterior( playerid ) );
SetVehicleVirtualWorld(physical_car_id, GetPlayerVirtualWorld( playerid ) );
}
else
{
SendClientMessage( playerid, COLOR_GREY, "Despawn the current spawned vehicles before spawning any more." );
}
}
}
return 1;
}
dcmd_vehiclesave(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
if(UnconfirmedSave[playerid] == 0)
{
SendClientMessage( playerid, COLOR_LIGHTRED, "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 ), string[128];
id = CarCount+1;
format(Vehicle, sizeof(Vehicle), "V_%d", id);
if(djIsSet(VEHICLES_FILE, Vehicle))
{
CarCount++;
format( string, sizeof( string ), "Vehicle (ID: %d) already exist!", id);
SendClientMessage( playerid, COLOR_GREY, string);
SendClientMessage( playerid, COLOR_YELLOW, "Please try again by typing /vehiclesave complete");
}
else
{
GetVehiclePos(vehicleid, Vehicles[id][CarPosX], Vehicles[id][CarPosY], Vehicles[id][CarPosZ]);
GetVehicleZAngle(vehicleid, Vehicles[id][CarZAngle]);
new plate[255];
new randl1 = random(sizeof(Letters1));
new randl2 = random(sizeof(Letters2));
new randl3 = random(sizeof(Letters3));
new randl4 = random(sizeof(Letters4));
new randn1 = random(sizeof(Numbers1));
new randn2 = random(sizeof(Numbers2));
new randn3 = random(sizeof(Numbers3));
format(plate, sizeof(plate),"%s%s%s%s %s%s%s", Letters1[randl1], Letters2[randl2], Letters3[randl3], Letters4[randl4], Numbers1[randn1], Numbers2[randn2], Numbers3[randn3]);
Vehicles[id][Plate] = plate;
Vehicles[id][CarModel] = GetVehicleModel(vehicleid);
Vehicles[id][CarColour1] = -1;
Vehicles[id][CarColour2] = -1;
Vehicles[id][Faction] = 0;
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/Faction", id);
djSetInt(VEHICLES_FILE, Vehicle, Vehicles[id][Faction], 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/Plate", id);
djSet(VEHICLES_FILE, Vehicle, Vehicles[id][Plate], true);
djCommit(VEHICLES_FILE);
djAutocommit(true);
CarCount++;
printf( "[system] Vehicle %d has been saved to %s.", id, VEHICLES_FILE);
SendClientMessage( playerid, COLOR_LIGHTBLUE, "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 );
SetVehicleNumberPlate(Vehicles[id][GameID], Vehicles[id][Plate]);
PutPlayerInVehicle( playerid, Vehicles[id][GameID], 0 );
SendClientMessage( playerid, COLOR_YELLOW, "You can despawn this vehicle by using /vehicledelete.");
for(new i = 0; i < SpawnedVehicles; i++)
{
if(VehicleSpawned[i] == GetPlayerVehicleID(playerid))
{
VehicleSpawned[i] = 0;
}
}
}
}
}
}
return 1;
}
dcmd_vehicledelete(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
if(UnconfirmedSave[playerid] == 0)
{
SendClientMessage( playerid, COLOR_LIGHTRED, "Are you sure you want to delete 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 = GetVehicleFileID(vehicleid);
format(Vehicle, sizeof(Vehicle), "V_%d", id);
if(djIsSet(VEHICLES_FILE, Vehicle))
{
format(Vehicle, sizeof(Vehicle), "V_%d", id);
djUnset(VEHICLES_FILE, Vehicle);
CarCount--;
printf( "[system] Vehicle %d has been deleted to %s.", id, VEHICLES_FILE);
SendClientMessage( playerid, COLOR_LIGHTBLUE, "Vehicle deleted!" );
DestroyVehicle(vehicleid);
}
else
{
SendClientMessage( playerid, COLOR_GREY, "Unable to delete the vehicle!" );
}
}
}
}
return 1;
}
dcmd_vehiclefid(playerid, params[])
{
new id, string[ 128 ], ftext[128];
if( sscanf( params, "d", id))
{
if( PlayerInfo[playerid][pAdmin] >= 1337)
{
SendClientMessage( playerid, COLOR_WHITE, "USAGE: /vehiclefid [Faction ID]" );
SendClientMessage( playerid, COLOR_YELLOW, "HINT: Type /vehiclefid 0 to unlock the vehicle." );
}
}
else
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(id > 1 || id < 10)
{
if(GetVehicleFileID(vehicleid) == 0)
{
SendClientMessage( playerid, COLOR_GREY, "That doesn't seem to be a saved vehicle!" );
}
else
{
if(id == 0)
{
SendClientMessage( playerid, COLOR_LIGHTBLUE, "You have unlocked this vehicle!" );
Vehicles[GetVehicleFileID(vehicleid)][Faction] = 0;
}
else
{
if(id == 1) { ftext = "LSPD"; }
else if(id == 2) { ftext = "FBI"; }
else if(id == 3) { ftext = "RCSD"; }
else if(id == 4) { ftext = "LSFMD"; }
else if(id == 5) { ftext = "National Guards"; }
else if(id == 6) { ftext = "Senate"; }
else if(id == 7) { ftext = "Secret Service"; }
else if(id == 8) { ftext = "Hitman Agency"; }
else if(id == 9) { ftext = "News Agency"; }
else if(id == 10) { ftext = "Taxi Cab Company"; }
Vehicles[GetVehicleFileID(vehicleid)][Faction] = id;
format( string, sizeof( string ), "You have Locked this vehicle for Faction %s !", ftext);
SendClientMessage( playerid, COLOR_LIGHTBLUE, string);
SaveExistingVehicle(vehicleid);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Faction can't be below 1 or above 10!");
return 1;
}
}
else
{
SendClientMessage( playerid, COLOR_GREY, "You are not in a valid vehicle!" );
}
}
}
return 1;
}