Remove vehicle -
JimmyNeonHD - 11.05.2013
Hello, this command i need it i can't find any thing about it
But how could i make a one
I want /vkill vehicleid
Kill all the vehicles that's we type the id, is that's possible
Sorry my very very English bad
Re: Remove vehicle -
zDevon - 11.05.2013
Sort the command parameters with sscanf and use the DestroyVehicle function to despawn the specified vehicle
https://sampwiki.blast.hk/wiki/DestroyVehicle
Re: Remove vehicle -
feartonyb - 11.05.2013
new Veh[MAX_VEHICLES];
for each addstaticvehicle add before Veh[1] , for second Veh[2] ....
Then use:
CMD:vkill(playerid,params[])
{
new dvehicle;
if(sscanf(params, "d", dvehicle)) SendClientMessage(playerid,-1,"Enter vehicle id!");
DestroyVehicle(Veh[dvehicle]);
SendClientMessage(playerid,-1,"Vehicle destroyed!");
}
Re: Remove vehicle -
Knappen - 11.05.2013
Well, if you load your vehicles from a file, you probably get set the ID when you load it!
pawn Код:
CMD:destroyvehicle(playerid, params[])
{
new Vehicle;
if(IsPlayerInAnyVehicle(playerid)) // Destroys the car you are inside, if you haven't written an id
{
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
else
{
if(sscanf(params, "i", Vehicle)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /destroyvehicle [VehicleID]");
else DestroyVehicle(Vehicle);
}
return 1;
}
This will destroy the vehicle you are inside. If you're not in a car, you can write the ID of the car you want to destroy!
Re: Remove vehicle -
JimmyNeonHD - 11.05.2013
Quote:
Originally Posted by Knappen
Well, if you load your vehicles from a file, you probably get set the ID when you load it!
pawn Код:
CMD:destroyvehicle(playerid, params[]) { new Vehicle; if(IsPlayerInAnyVehicle(playerid)) // Destroys the car you are inside, if you haven't written an id { DestroyVehicle(GetPlayerVehicleID(playerid)); return 1; } else { if(sscanf(params, "i", Vehicle)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /destroyvehicle [VehicleID]"); else DestroyVehicle(Vehicle); } return 1; }
This will destroy the vehicle you are inside. If you're not in a car, you can write the ID of the car you want to destroy!
|
Thanks works!
But i have a problem when i type the vehicle id 1 only 1 vehicle destroy not other like i spawn 2 cars
Like monster 444
I type destroyvehicle 444 only one destroyed and other stay i wanna to remove all the vehicle's with the same id!
Re: Remove vehicle -
zDevon - 11.05.2013
Well you didn't say you wanted to delete by the model ID! For that you will need to loop through the server's vehicles and if the model matches your input, destroy it.
pawn Код:
YCMD:destroyvehicle(playerid, params[])
{
new Vehicle;
if(IsPlayerInAnyVehicle(playerid)) // Destroys the car you are inside, if you haven't written an id
{
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
else
{
if(sscanf(params, "i", Vehicle)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /destroyvehicle [VehicleID]");
else {
for(new i; i < MAX_VEHICLES; i++) {
if(GetVehicleModel(i) == Vehicle) DestroyVehicle(i);
}
}
}
return 1;
}
That should do it. Though I've heard that destroying vehicles in a loop may/may not work 100% of the time depending on if the vehicle is streamed in or not, just a note.