Skip to content

Commit

Permalink
fix(client): OnPlayerEnterVehicle for LocalVehicle
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Feb 26, 2024
1 parent 68aa112 commit 8fc2a62
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/AltV.Net.Client/Core.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}");
Expand Down Expand Up @@ -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)}");
}

Expand Down

0 comments on commit 8fc2a62

Please sign in to comment.