Check player in car
#1

Ok how can check which players are there in particular vehicle id and set their hp to zero? Thanks in advance
Reply
#2

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == id) return SetPlayerHealth(playerid, 0);
    return 1;
}
Reply
#3

You want to make like with... tanks? xD
Reply
#4

xir's code will kill the player if the player is too close to the vehicle, not when the player is in the vehicle. Use OnPlayerStateChange for that. It's more realistic to check when the player has sat inside the vehicle.

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if ((newstate == PLAYER_STATE_DRIVER) && (oldstate == PLAYER_STATE_ONFOOT))
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 432) // Tank's vehicle model id is 432
        {
            SetPlayerHealth(playerid, 0);
        }
    }
}
Reply
#5

It would not kill the player if it was near the vehicle, it would kill the player right when the player pressed enter.

But yeah OnPlayerStateChange is more realistic as you said
Reply
#6

No, Thats not what i want, Actually it kills a player when he enters the car, But i made a command of bomb in car, So when bomb is activated, the car which bomb is placed is stored in a variable say carbomb(vehicleid), So i need to check if any player is there inside the car when the bomb is activated, I never did this , Is there any way to do?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)