Remove vehicle
#1

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
Reply
#2

Sort the command parameters with sscanf and use the DestroyVehicle function to despawn the specified vehicle

https://sampwiki.blast.hk/wiki/DestroyVehicle
Reply
#3

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!");
}
Reply
#4

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!
Reply
#5

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!
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)