logs bei tod items verloren + items weg wenn knast
This commit is contained in:
@@ -64,7 +64,6 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
PositionManager.cuffPoints.Remove(player);
|
PositionManager.cuffPoints.Remove(player);
|
||||||
player.TriggerEvent("abortSpawnschutz");
|
player.TriggerEvent("abortSpawnschutz");
|
||||||
|
|
||||||
//TODO: Zum Full Release entfernen
|
|
||||||
if (player.HasData("togdeath") && user.IsAdmin(AdminLevel.ADMIN))
|
if (player.HasData("togdeath") && user.IsAdmin(AdminLevel.ADMIN))
|
||||||
{
|
{
|
||||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||||
@@ -235,7 +234,15 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
public void RespawnPlayerAtHospital(Player player)
|
public void RespawnPlayerAtHospital(Player player)
|
||||||
{
|
{
|
||||||
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
|
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
|
||||||
InventoryManager.RemoveIllegalItemsFromInventory(player);
|
var lostItems = InventoryManager.RemoveIllegalItemsFromInventory(player);
|
||||||
|
if (lostItems.Any())
|
||||||
|
{
|
||||||
|
logger.LogInformation("Player {0} lost the following items on death: " + string.Join(", ", lostItems.Select(i =>
|
||||||
|
{
|
||||||
|
IItem item = InventoryManager.GetItemById(i.ItemId);
|
||||||
|
return $"{item.Name} ({item.Id}, amount: {i.Amount})";
|
||||||
|
})));
|
||||||
|
}
|
||||||
player.SetData("isDead", false);
|
player.SetData("isDead", false);
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
|||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Admin;
|
using ReallifeGamemode.Server.Admin;
|
||||||
|
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||||
using ReallifeGamemode.Server.Log;
|
using ReallifeGamemode.Server.Log;
|
||||||
using ReallifeGamemode.Server.Managers;
|
using ReallifeGamemode.Server.Managers;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
@@ -105,14 +106,30 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
time *= 2;
|
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);
|
var executiveFactions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
|
||||||
foreach (var faction in executiveFactions)
|
foreach (var faction in executiveFactions)
|
||||||
{
|
{
|
||||||
faction.BankAccount.Balance += factionMoney;
|
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.Wanteds = 0;
|
||||||
user.JailTime = time;
|
user.JailTime = time;
|
||||||
@@ -480,7 +497,7 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
|
|
||||||
public static void ToggleInventory(this Player player, InventoryToggleOption option = InventoryToggleOption.TOGGLE)
|
public static void ToggleInventory(this Player player, InventoryToggleOption option = InventoryToggleOption.TOGGLE)
|
||||||
{
|
{
|
||||||
if(option == InventoryToggleOption.TOGGLE)
|
if (option == InventoryToggleOption.TOGGLE)
|
||||||
{
|
{
|
||||||
player.TriggerEvent("inventoryShow");
|
player.TriggerEvent("inventoryShow");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -712,23 +712,26 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveIllegalItemsFromInventory(Player player)
|
public static List<UserItem> RemoveIllegalItemsFromInventory(Player player)
|
||||||
{
|
{
|
||||||
if (!player.IsLoggedIn())
|
if (!player.IsLoggedIn())
|
||||||
{
|
{
|
||||||
return;
|
return new List<UserItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = player.GetUser();
|
var user = player.GetUser();
|
||||||
|
List<UserItem> illegalItemsTaken = new List<UserItem>();
|
||||||
List<UserItem> items = GetUserItems(player);
|
List<UserItem> items = GetUserItems(player);
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
if (!GetItemById(item.ItemId).Legal)
|
if (!GetItemById(item.ItemId).Legal)
|
||||||
{
|
{
|
||||||
|
illegalItemsTaken.Add(item);
|
||||||
RemoveUserItem(user, item, item.Amount);
|
RemoveUserItem(user, item, item.Amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return illegalItemsTaken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user