Added check, if vehicle is used by server system on /vdestroy

This commit is contained in:
hydrant
2018-11-29 13:52:18 +01:00
parent 14873bc3fa
commit b83c071e45
2 changed files with 26 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ using reallife_gamemode.Server.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using reallife_gamemode.Model;
namespace reallife_gamemode.Server.Managers
{
@@ -35,5 +36,21 @@ namespace reallife_gamemode.Server.Managers
return NAPI.Pools.GetAllVehicles().Find(v => v.Handle == _serverVehicles[serverVehicle.Id]);
}
public static ServerVehicle GetServerVehicleFromVehicle(Vehicle veh)
{
using (var dbContext = new DatabaseContext())
{
foreach(KeyValuePair<int, NetHandle> pair in _serverVehicles)
{
if (pair.Value == veh.Handle)
{
return dbContext.ServerVehicles.Find(pair.Key);
}
}
}
return null;
}
}
}