fix getdriver

This commit is contained in:
hydrant
2020-05-04 23:46:36 +02:00
parent 7a6d468230
commit d188905f59

View File

@@ -1,4 +1,4 @@
using GTANetworkAPI;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Managers;
@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Extensions
public static Player GetDriver(this Vehicle veh)
{
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle != null && p.Vehicle?.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
}
}
}