if(strcmp(cmd, "/veh", true) == 0) { if(IsPlayerConnected(playerid)) { if (PlayerInfo[playerid][pAdmin] < 5) { SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that command!"); return 1; } ShowPlayerDialog(playerid, CARMENU, DIALOG_STYLE_LIST, "Vehicles","Heavy Trucks\nTrucks\n2Doors\n4Doors\nPlans\nBoats\nTrailers\nGovernment\nRC\nTransportation\nMotorCycles", "Spawn", "Cancel"); } return 1; }
if(strcmp(cmd, "/destroycar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 5)
{
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not Admin!");
}
}
}
new VehVehicle; //At the top of your script
VehVehile = CreateVehicle(bla,bla,...); //Where you create the vehicle
if(strcmp(cmd, "/destroycar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 5)
{
if(GetPlayerVehicleID(playerid) == VehVehicle)
{
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not Admin!");
}
}
}
// Top:
new
gStaticCars;
// GameModeInit:
gStaticCars = AddStaticVehicle(...); // This line should declare the last vehicle in OnGameModeInit, and only the last!
// Your delete cmd (single vehicle):
new
vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid > gStaticCars)
{
DestroyVehicle(vehicleid);
}
// Your delete cmd (all vehicles):
for(new i = gStaticCars+1; i < MAX_VEHICLES; i++)
{
if(!GetVehicleModel(i)) continue;
DestroyVehicle(i);
}
// GameModeInit: gStaticCars = AddStaticVehicle(...); // This line should declare the last vehicle in OnGameModeInit, and only the last! |
new bool:IsVehicleVeh[MAX_VEHICLES];
//Under your OnDialofResponse. Show us your code if you have no idea where to put this
IsVehicleVeh[vehicleidhere]++;
//Command to delete vehicle
for(new i=1;i<=MAX_VEHICLES;i++)
{
if(IsVehicleVeh[i]) DestroyVehicle(i);
}