Destroy car
#1

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

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.");
Reply
#3

ty +rep
Reply
#4

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

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

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;
}
Reply
#7

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

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

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

Dont work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)