Added mileage, changed all namespaces from reallife_gamemode to ReallifeGamemode

This commit is contained in:
hydrant
2019-03-06 21:12:34 +01:00
parent 13142edbb7
commit bee3497fc3
104 changed files with 1408 additions and 297 deletions

View File

@@ -1,10 +1,10 @@
using GTANetworkAPI;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Models;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Models;
using System;
using System.Collections.Generic;
namespace reallife_gamemode.Server.Managers
namespace ReallifeGamemode.Server.Managers
{
public class VehicleManager
{
@@ -110,11 +110,24 @@ namespace reallife_gamemode.Server.Managers
return GetVehicleFromHandle(_serverVehicles[serverVehicle.Id]);
}
public static ServerVehicle GetServerVehicleFromVehicle(Vehicle veh)
public static ServerVehicle GetServerVehicleFromVehicle(Vehicle veh, DatabaseContext dbContext = null)
{
using (var dbContext = new DatabaseContext())
if(dbContext == null)
{
foreach(KeyValuePair<int, NetHandle> pair in _serverVehicles)
using (dbContext = new DatabaseContext())
{
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)
{