logs bei tod items verloren + items weg wenn knast
This commit is contained in:
@@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Admin;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
@@ -105,14 +106,30 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
time *= 2;
|
||||
}
|
||||
|
||||
int factionMoney = user.Wanteds * 25;
|
||||
var lostItems = InventoryManager.RemoveIllegalItemsFromInventory(user.Player);
|
||||
if (lostItems.Any())
|
||||
{
|
||||
Logger.LogInformation("Player {0} lost the following items when sent to prison: " + string.Join(", ", lostItems.Select(i =>
|
||||
{
|
||||
IItem item = InventoryManager.GetItemById(i.ItemId);
|
||||
return $"{item.Name} ({item.Id}, amount: {i.Amount})";
|
||||
})));
|
||||
}
|
||||
var illegalItemsPrice = lostItems.Select(i =>
|
||||
{
|
||||
IIllegalItem item = (IIllegalItem)InventoryManager.GetItemById(i.ItemId);
|
||||
return item.PriceForConfiscation * i.Amount;
|
||||
}).Sum();
|
||||
|
||||
int wantedMoney = user.Wanteds * 25;
|
||||
int factionMoney = wantedMoney + illegalItemsPrice;
|
||||
var executiveFactions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
|
||||
foreach (var faction in executiveFactions)
|
||||
{
|
||||
faction.BankAccount.Balance += factionMoney;
|
||||
}
|
||||
|
||||
Logger.LogInformation("Player {0} was sent to jail for {1} seconds, executive factions got {2} dollars each", user.Name, time, factionMoney);
|
||||
Logger.LogInformation("Player {0} was sent to jail for {1} seconds, executive factions got {2} dollars each (wanteds: {3}, illegal items: {4})", user.Name, time, factionMoney, wantedMoney, illegalItemsPrice);
|
||||
|
||||
user.Wanteds = 0;
|
||||
user.JailTime = time;
|
||||
@@ -480,7 +497,7 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
|
||||
public static void ToggleInventory(this Player player, InventoryToggleOption option = InventoryToggleOption.TOGGLE)
|
||||
{
|
||||
if(option == InventoryToggleOption.TOGGLE)
|
||||
if (option == InventoryToggleOption.TOGGLE)
|
||||
{
|
||||
player.TriggerEvent("inventoryShow");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user