need help with vehicles
#1

how can i check if the player entered a car when its created like this : new masina = CreateVehicle(489, 2117.9717, -2137.3484, 13.8255, -98.0000, 0, 0, 100);
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if (GetPlayerVehicleID(playerid) == masina)
        {
            // player entered that vehicle..
        }
    }
    return 1;
}
This checks if the player enters a vehicle as driver or passenger and if the vehicleid is the one masina holds. If you want to check only for driver, change:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
to:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
This one checks if the player is in that vehicle which can be used anywhere else.
pawn Код:
if (IsPlayerInVehicle(playerid, masina))
{
    // player is in that vehicle..
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)