lückenlose nachvollziehbarkeit

This commit is contained in:
hydrant
2021-05-25 20:45:31 +02:00
parent 8c964dc026
commit 16aab6a8bb
6 changed files with 44 additions and 17 deletions

View File

@@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Inventory;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
@@ -25,6 +27,8 @@ namespace ReallifeGamemode.Server.Events
{
public class Death : Script
{
private static readonly ILogger logger = LogManager.GetLogger<Death>();
private readonly Dictionary<Player, DateTime> lastPlayerDeathTime = new Dictionary<Player, DateTime>();
[ServerEvent(Event.PlayerDeath)]
@@ -61,16 +65,16 @@ namespace ReallifeGamemode.Server.Events
float killerPosZ = -1;
float killerHeading = -1;
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer = {(killer != null ? killer.Name : "no killer found")}");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer = {(killer != null ? killer.Name : "no killer found")}");
if (killer.IsLoggedIn())
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer is logged in");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer is logged in");
var killerUser = killer.GetUser(dbContext);
if (killerUser != null)
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer GetUser is not null");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer GetUser is not null");
killerId = killerUser.Id;
killerPosX = killer.Position.X;
killerPosY = killer.Position.Y;
@@ -80,10 +84,10 @@ namespace ReallifeGamemode.Server.Events
var playerInGangwar = player.HasData("inGangWar");
var killerInGangwar = killer.HasData("inGangWar");
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - PlayerInGangwar = {playerInGangwar}, KillerInGangwar = {killerInGangwar}");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - PlayerInGangwar = {playerInGangwar}, KillerInGangwar = {killerInGangwar}");
if (playerInGangwar && killerInGangwar)
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Both players in gangwar, setting kill");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Both players in gangwar, setting kill");
Gangwar.Gangwar.GangwarKill(killer, player);
}
@@ -228,6 +232,7 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("RespawnPlayerAtHospital")]
public void RespawnPlayerAtHospital(Player player)
{
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
player.SetData("isDead", false);
using (var dbContext = new DatabaseContext())
{