SA-MP Forums Archive
Destroy car - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Destroy car (/showthread.php?tid=509950)



Destroy car - Ananisiki - 28.04.2014

How i can add like if there are no car

"no cars to delete"

pawn Код:
CMD:dac(playerid, params[])
{
    #pragma unused params
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(AdminCar[i] == 1) DestroyVehicle(i);
    }
    return 1;
}



Re: Destroy car - DobbysGamertag - 28.04.2014

You could probably do something like this:

pawn Код:
new found = 0;
for(new i = 0; i<MAX_VEHICLES; i++)
{
    if(AdminCar[i] == 1)found++;
}
if(found==0)SendClientMessage(playerid,-1,"no vehicles found.");



Re: Destroy car - Ananisiki - 28.04.2014

ty +rep


Re: Destroy car - Ananisiki - 28.04.2014

one more thing, how i can do like if the player is in the admin car it dont get deleted


Re: Destroy car - Campbell- - 28.04.2014

In case you just don't want to destroy the vehicle whenever the person destroying the vehicles is in the administrative vehicle: Check the vehicleID the player deleting the vehicles is in via GetPlayerVehicleID() and avoid destroying the vehicle with this specific ID.

If you don't want to destroy administrative vehicles in which any player is: Either document the players entering/leaving the vehicle in OnPlayerStateChange() or loop through all players to check if anybody is in this specific administrative vehicle you want to delete.


Re: Destroy car - Ananisiki - 29.04.2014

It say no vehicles found even when there is a car,,,

pawn Код:
CMD:destroyncars(playerid, params[])
{
    #pragma unused params
    new count = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(NormalCar[i] == 1) DestroyVehicle(i);
    }
    if(!count) return SendClientMessage(playerid, COLOR_RED, "There Are No Vehicles To Delete.");
    return 1;
}



Re: Destroy car - gekas - 29.04.2014

Quote:
Originally Posted by Ananisiki
Посмотреть сообщение
It say no vehicles found even when there is a car,,,

pawn Код:
CMD:destroyncars(playerid, params[])
{
    #pragma unused params
    new count = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(NormalCar[i] == 1) DestroyVehicle(i);
    }
    if(!count) return SendClientMessage(playerid, COLOR_RED, "There Are No Vehicles To Delete.");
    return 1;
}
Try This


AW: Destroy car - Macronix - 29.04.2014

Yes, because you need to increase the "count" variable if a car was found...


Re: Destroy car - Abagail - 29.04.2014

If you want to only delete unoccupied ones you could do:

pawn Код:
CMD:destroyncars(playerid, params[])
{
    #pragma unused params
    new count = 0;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(IsVehicleOccupied(i)) return 0;
        if(NormalCar[i] == 1) DestroyVehicle(i);
        Count++;
    }
    if(!count) return SendClientMessage(playerid, COLOR_RED, "There Are No Vehicles To Delete.");
    return 1;
}

stock IsVehicleOccupied(vehicleid)
{
foreach(Player, i) {
if(GetPlayerVehicleID == vehicleid) return 1;
else return 0;
}
}
Untested.


Re: Destroy car - Ananisiki - 29.04.2014

Dont work