fix vehicle death inventory clear

This commit is contained in:
hydrant
2021-05-29 03:15:58 +02:00
parent 8f23ecb7fe
commit 89280e1f85

View File

@@ -1122,10 +1122,17 @@ namespace ReallifeGamemode.Server.Managers
{ {
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
Vehicle vehicle = NAPI.Pools.GetAllVehicles().Find(v => v.Id == id); Vehicle vehicle = NAPI.Pools.GetAllVehicles().Find(v => v.Id == id);
ServerVehicle sV = vehicle.GetServerVehicle(dbContext); ServerVehicle sV = vehicle.GetServerVehicle(dbContext);
var items = InventoryManager.GetVehicleItems(vehicle);
if (items.Any())
{
string itemsStr = string.Join(", ", items.Select(i => $"{i.ItemId} (amount: {i.Amount})"));
logger.LogInformation("Vehicle {0} died and lost the items: {1}", sV.Id, itemsStr);
InventoryManager.RemoveAllItemsfromVehicleInventory(vehicle);
}
if (sV is UserVehicle uV) if (sV is UserVehicle uV)
{ {
@@ -1154,14 +1161,6 @@ namespace ReallifeGamemode.Server.Managers
Vehicle newVeh = sV.Spawn(vehicle); Vehicle newVeh = sV.Spawn(vehicle);
newVeh.Repair(); newVeh.Repair();
} }
var items = InventoryManager.GetVehicleItems(vehicle);
if (items.Any())
{
string itemsStr = string.Join(", ", items.Select(i => $"{i.ItemId} (amount: {i.Amount})"));
logger.LogInformation("Vehicle {0} died and lost the items: {1}", sV.Id, itemsStr);
InventoryManager.RemoveAllItemsfromVehicleInventory(vehicle);
}
} }
} }