The event onPlayerEnterVehicleEvent
Returns null values. So even though the console states:
So if you try to grab the passenger Player object you get null.
The event onPlayerEnterVehicleEvent
Returns null values. So even though the console states:
So if you try to grab the passenger Player object you get null.
Events are typically triggered before the particular action is performed. In this case, the PlayerEnterVehicleEvent is triggered first, and then (if the event was not cancelled by a plugin) the player is actually added to the vehicle.
So when getting the passengers right when the event is triggered, the list won't contain the player yet who just entered the vehicle...
In these cases, it's better to rely on the data of the event instead. In this case, you can get the player who entered the vehicle as well as the target seat from the PlayerEnterVehicleEvent.
Don’t have an account yet? Create a new account now and be part of our community!