diff --git a/api/AltV.Net.Client/Core.Events.cs b/api/AltV.Net.Client/Core.Events.cs index 10583a98f..352984991 100644 --- a/api/AltV.Net.Client/Core.Events.cs +++ b/api/AltV.Net.Client/Core.Events.cs @@ -254,8 +254,12 @@ public void OnPlayerEnterVehicle(IntPtr pointer, byte seat) var vehicle = PoolManager.Vehicle.Get(pointer); if (vehicle is null) { - Console.WriteLine("Invalid vehicle: " + pointer); - return; + vehicle = PoolManager.LocalVehicle.Get(pointer); + if (vehicle is null) + { + Console.WriteLine("Invalid vehicle: " + pointer); + return; + } } EnterVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, seat), $"event {nameof(OnPlayerEnterVehicle)}"); @@ -478,6 +482,16 @@ public void OnRemoveEntity(IntPtr targetPtr, BaseObjectType type) public void OnPlayerLeaveVehicle(IntPtr vehiclePtr, byte seat) { var vehicle = PoolManager.Vehicle.Get(vehiclePtr); + if (vehicle is null) + { + vehicle = PoolManager.LocalVehicle.Get(vehiclePtr); + if (vehicle is null) + { + Console.WriteLine("Invalid vehicle: " + vehiclePtr); + return; + } + } + PlayerLeaveVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, seat), $"event {nameof(OnPlayerLeaveVehicle)}"); }