add option to park vehicles in vehicle menu

This commit is contained in:
hydrant
2019-05-11 22:10:53 +02:00
parent 7b19a83e12
commit 41d756c4d2
8 changed files with 83 additions and 39 deletions

View File

@@ -162,27 +162,13 @@ namespace ReallifeGamemode.Server.Managers
public static ServerVehicle GetServerVehicleFromVehicle(Vehicle veh, DatabaseContext dbContext = null)
{
if (dbContext == null)
dbContext = dbContext ?? new DatabaseContext();
foreach (KeyValuePair<int, NetHandle> pair in _serverVehicles)
{
using (dbContext = new DatabaseContext())
if (pair.Value == veh.Handle)
{
foreach (KeyValuePair<int, NetHandle> pair in _serverVehicles)
{
if (pair.Value == veh.Handle)
{
return dbContext.ServerVehicles.Find(pair.Key);
}
}
}
}
else
{
foreach (KeyValuePair<int, NetHandle> pair in _serverVehicles)
{
if (pair.Value == veh.Handle)
{
return dbContext.ServerVehicles.Find(pair.Key);
}
return dbContext.ServerVehicles.Find(pair.Key);
}
}