Destroy Vehicle Problem
#1

Hello, I have
pawn Код:
OnPlayerExitVehicle(playerid, vehicleid)
a timer and when the driver exit the vehicle, the vehicle will be destroy.
The problem is, that if the driver exit vehicle, and there are passenger in the vehicle, the vehicle still destroyed.
How can I make it, so when the driver exit vehicle, to check if there are passenger in the vehicle. If not the car will be destroyed, if else there are passengers in the vehicle to wait all passenger exit vehicle and then destroyed.
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER) {
        DestroyVehicle(vehicleid);
    }
    SetTimerEx("cardestroyedhide", 5000, 0, "i", vehicleid);//
}
Reply
#2

Try checking if is there anyone in the vehicle at all (a basic player for loop or foreach + IsPlayerInVehicle) and, if so, only then destroy the vehicle

Or the post below if this doesn't work
Reply
#3

You can also use PLAYER_STATE_PASSENGER, and toggle the vehicle from respawning if the player's state is as a passenger.
Reply
#4

Can you explain me because I didn't understand it.
Also, can you give me an example on this. I tried something with foreach but I failed.

@=WoR=G4M3Ov3r, How can I toggle the vehicle from respawning if the player's state is as a passenger
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)