CMD:veh(playerid, params[]) { new vehid,vehicle,engine,lights,alarm,doors,bonnet,boot,objective; if(PlayerInfo[playerid][pLevel] < 1) return error if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /veh <carid>"); else if (vehid < 400 || vehid > 611) SendClientMessage(playerid, COLOR_GREY, "[ERROR] Invalid car id! [ Car ID's range from 400 - 611 ]"); else { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); vehicle = CreateVehicle(vehid, x + 3, y, z, 0, 0,0, -1); GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vehid,1,lights,alarm,doors,bonnet,boot,objective); ChangeVehicleColor(vehicle, 219, 251); SetVehicleNumberPlate(vehicle,"{FF8000}BHaulers"); PutPlayerInVehicle(playerid,vehicle,0); SendClientMessage(playerid, COLOR_GREEN, "Car spawned!"); } return 1; }
new vehToDelete[MAX_VEHICLES] = {-1, ...};
// in your cmd
vehToDelete[vehicle] = CreateVehicle(...)
CMD:deletevehicles(playerid, params[])
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(vehToDelete[i] != -1)
DestroyVehicle(i);
}
return 1;
}
new vehToDelete[MAX_VEHICLES]; CMD:veh(playerid, params[]) { new vehid,vehicle,engine,lights,alarm,doors,bonnet,boot,objective; if(PlayerInfo[playerid][pLevel] < 1) return error if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /veh <carid>"); else if (vehid < 400 || vehid > 611) SendClientMessage(playerid, COLOR_GREY, "[ERROR] Invalid car id! [ Car ID's range from 400 - 611 ]"); else { new Float:x, Float:y, Float:z, Float:angle; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid,angle); vehToDelete[vehicle] = CreateVehicle(vehid, x + 3, y, z, angle, 219,251, -1); GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vehid,1,lights,alarm,doors,bonnet,boot,objective); SetVehicleNumberPlate(vehToDelete[vehicle],"{FF8000}BHaulers"); VehicleFuel[vehid] = 100+random(50); PutPlayerInVehicle(playerid,vehToDelete[vehicle],0); SendClientMessage(playerid, COLOR_GREEN, "Car spawned!"); } return 1; } CMD:cleancars(playerid, params[]) { for(new i = 0; i < MAX_VEHICLES; i++) { if(vehToDelete[i] != -1) DestroyVehicle(i); } return 1; }
vehicle is always going to be 0...meaning it's just replacing itself over and over so you'll only ever delete one vehicle
|
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define MAX_Vehicles 100
new vehicles[MAX_Vehicles];
new vehid,vehicle,engine,lights,alarm,doors,bonnet,boot,objective;
CMD:Veh(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"Message"); //your level checks,colors
else
{
if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, -1, "USAGE: /veh <carid>");
else if (vehid < 400 || vehid > 611) SendClientMessage(playerid, -1, "[ERROR] Invalid car id! [ Car ID's range from 400 - 611 ]");
else
{
new float:x,float:y,float:z,float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
new i=0 ;
if(i<Max_vehicles)
{
vehicles[i]=CreateVehicle(vehid,x,y,z,a,random(126),random(126),150000);
GetVehicleParamsEx(vehid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehid,1,lights,alarm,doors,bonnet,boot,objective);
ChangeVehicleColor(vehicle, 219, 251);
SetVehicleNumberPlate(vehicle,"{FF8000}BHaulers");
PutPlayerInVehicle(playerid,vehicle,0);
i++;
}
return SendClientMessage(playerid,-1,"Vehicle Spawned!"); //your colors
}
return 1;
}
}
CMD:Cleanup(playerid)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"Message"); //your level checks,colors
else
{
for(new i;i<=count;i++)
{
DestroyVehicle(vehicles[i]);
}
return SendClientMessageToAll(-1,"Spwaned Cars Have Been Cleared"),1;
}
}
CMD:delallveh(playerid, params[])
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
DestroyVehicle(i);
}
return 1;
}
CMD:delveh(playerid, params[])
{
new vehid;
if(sscanf(params, "d", vehid)) return SendClientMessage(playerid, -1, "USAGE: /delveh [veh]");
DestroyVehicle(vehid);
new string[60];
format(string, sizeof(string), "Vehicle %d destroyed!", vehid);
SendClientMessage(playerid, -1, string);
return 1;
}
Here you go:
You need zcmd include and sscanf(include+plugin) You check the vehid using /dl PHP Code:
|
I don't want to delete all vehicles.. Only those that were spawned with /veh.
Any btw kartik your method is awful.. test it and you will see why.. |
Will ONLY delete vehicles with id in the vehicles array ! Updated cause i fucked up !
|
for(new i; i<MAX_Vehicles;i++) { vehicles[i]=CreateVehicle(vehid,x,y,z,a,random(126),random(126),150000);