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

@@ -1935,6 +1935,7 @@ namespace ReallifeGamemode.Server.Commands
{ {
if (!managedPlayer.IsLoggedIn()) return; if (!managedPlayer.IsLoggedIn()) return;
managedPlayer.GiveWeapon(weaponHash, munition); managedPlayer.GiveWeapon(weaponHash, munition);
logger.LogInformation("Admin {0} gave the weapon {1} (ammo: {2}) to player {3}", player.Name, weapon, munition, managedPlayer.Name);
ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " eine/n " + weapon + " mit " + munition + " Munition vergeben."); ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " eine/n " + weapon + " mit " + munition + " Munition vergeben.");
} }
ChatService.SendMessage(player, "~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben"); ChatService.SendMessage(player, "~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben");
@@ -3826,6 +3827,8 @@ namespace ReallifeGamemode.Server.Commands
return; return;
} }
logger.LogInformation("Admin {0} gave the weapon {1} (ammo: {2}) to player {3}", player.Name, hash, ammo, target.Name);
target.GiveWeapon((WeaponHash)uHash, ammo); target.GiveWeapon((WeaponHash)uHash, ammo);
ChatService.SendMessage(target, "~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten."); ChatService.SendMessage(target, "~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
ChatService.SendMessage(player, "~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben."); ChatService.SendMessage(player, "~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");

View File

@@ -45,19 +45,24 @@ namespace ReallifeGamemode.Server.Commands
} }
[Command("eventport", "~m~eventport")] [Command("eventport", "~m~eventport")]
public void CmdUserEventport(Player player, String option = "") public void CmdUserEventport(Player player, string option = "")
{ {
if (!player.IsLoggedIn()) return; if (!player.IsLoggedIn()) return;
option = option.ToLower();
if (option == "on") if (option == "on")
{ {
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
{ {
return; return;
} }
PositionManager.eventportPosition = player.Position; Vector3 position = player.Position;
PositionManager.eventportPosition = position;
PositionManager.eventportActive = true; PositionManager.eventportActive = true;
player.SendChatMessage("~y~Du hast hier erfolgreich einen Eventport gesetzt."); player.SendChatMessage("~y~Du hast hier erfolgreich einen Eventport gesetzt.");
ChatService.BroadcastAdmin($"~b~[ADMIN]~s~ ~y~{player.Name}~s~ hat einen Eventport erstellt.", AdminLevel.ADMIN);
logger.LogInformation("Admin {0} created the eventport at x: {1}, y: {2}, z: {3}", player.Name, position.X, position.Y, position.Z);
return; return;
} }
@@ -69,6 +74,8 @@ namespace ReallifeGamemode.Server.Commands
} }
PositionManager.eventportActive = false; PositionManager.eventportActive = false;
player.SendChatMessage("~y~Du hast den Eventport deaktiviert."); player.SendChatMessage("~y~Du hast den Eventport deaktiviert.");
ChatService.BroadcastAdmin($"~b~[ADMIN]~s~ ~y~{player.Name}~s~ hat einen Eventport deaktiviert.", AdminLevel.ADMIN);
logger.LogInformation("Admin {0} removed the eventport", player.Name);
return; return;
} }
@@ -92,7 +99,10 @@ namespace ReallifeGamemode.Server.Commands
int randomX = rnd.Next(-3, 3); int randomX = rnd.Next(-3, 3);
int randomY = rnd.Next(-3, 3); int randomY = rnd.Next(-3, 3);
Vector3 teleportPosition = new Vector3(PositionManager.eventportPosition.X + randomX, PositionManager.eventportPosition.Y + randomY, PositionManager.eventportPosition.Z); Vector3 currentEventport = PositionManager.eventportPosition;
Vector3 teleportPosition = new Vector3(currentEventport.X + randomX, currentEventport.Y + randomY, currentEventport.Z);
logger.LogInformation("Player {0} used the eventport to x: {1}, y: {2}, z: {3}", player.Name, currentEventport.X, currentEventport.Y, currentEventport.Z);
player.SafeTeleport(teleportPosition); player.SafeTeleport(teleportPosition);
player.SendNotification("Du hast dich zum Event teleportiert"); player.SendNotification("Du hast dich zum Event teleportiert");

View File

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

View File

@@ -297,7 +297,7 @@ namespace ReallifeGamemode.Server.Events
dbContext.VehicleItems.Remove(v); dbContext.VehicleItems.Remove(v);
} }
logger.LogInformation("Player {0} took the weapon deal item {1} (amount: {2}) out of weapon vehicle {3}", player.Name, v.VehicleId, itemToAdd, v.VehicleId); logger.LogInformation("Player {0} took the weapon deal item {1} (amount: {2}) out of weapon vehicle {3}", player.Name, v.ItemId, itemToAdd, v.VehicleId);
InventoryManager.AddItemToInventory(player, v.ItemId, itemToAdd); InventoryManager.AddItemToInventory(player, v.ItemId, itemToAdd);
nearestBehindVehiclePoint.usePoint(player); nearestBehindVehiclePoint.usePoint(player);
@@ -909,6 +909,11 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
if (player.Dead == true)
{
return;
}
bool state = VehicleStreaming.GetEngineState(v); bool state = VehicleStreaming.GetEngineState(v);
ServerVehicle sV = v.GetServerVehicle(); ServerVehicle sV = v.GetServerVehicle();
if (sV != null) if (sV != null)

View File

@@ -1,16 +1,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
namespace ReallifeGamemode.Server.Gangwar namespace ReallifeGamemode.Server.Gangwar
{ {
public class Gangwar : Script public class Gangwar : Script
{ {
private static ILogger logger = LogManager.GetLogger<Gangwar>();
public static Turf[] _loadedTurfs; public static Turf[] _loadedTurfs;
private static List<Turfs> turfs; private static List<Turfs> turfs;
public const int GANGWAR_TOTAL_TIME = 900; public const int GANGWAR_TOTAL_TIME = 900;
@@ -53,19 +57,19 @@ namespace ReallifeGamemode.Server.Gangwar
var killerInsideTurf = killer.HasData("GotInsideOfTurf"); var killerInsideTurf = killer.HasData("GotInsideOfTurf");
var victimInsideTurf = victim.HasData("GotInsideOfTurf"); var victimInsideTurf = victim.HasData("GotInsideOfTurf");
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - KillerInsideTurf = {killerInsideTurf}, VictimInsideTurf = {victimInsideTurf}"); logger.LogDebug($"GangwarKill - Victim {victim.Name} - KillerInsideTurf = {killerInsideTurf}, VictimInsideTurf = {victimInsideTurf}");
if (killerInsideTurf && victimInsideTurf) if (killerInsideTurf && victimInsideTurf)
{ {
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Killer and Victim are in Turf area"); logger.LogDebug($"GangwarKill - Victim {victim.Name} - Killer and Victim are in Turf area");
killer.TriggerEvent("gangWarKillNotification", victim.Name); killer.TriggerEvent("gangWarKillNotification", victim.Name);
foreach (var turf in getTurfs()) foreach (var turf in getTurfs())
{ {
if (turf.getId() == victim.GetData<int>("inGangWar")) if (turf.getId() == victim.GetData<int>("inGangWar"))
{ {
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Killed in turf id {turf.getId()}"); logger.LogDebug($"GangwarKill - Victim {victim.Name} - Killed in turf id {turf.getId()}");
var victimFactionName = victim.GetUser().Faction.Name; var victimFactionName = victim.GetUser().Faction.Name;
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}"); logger.LogDebug($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}");
turf.setKill(victimFactionName); turf.setKill(victimFactionName);
return; return;
} }
@@ -96,7 +100,7 @@ namespace ReallifeGamemode.Server.Gangwar
[RemoteEvent("Gangarea:Leave")] [RemoteEvent("Gangarea:Leave")]
public void RmtEvent_TurfLeave(Player client, string jsonId) public void RmtEvent_TurfLeave(Player client, string jsonId)
{ {
if(string.IsNullOrEmpty(jsonId)) if (string.IsNullOrEmpty(jsonId))
{ {
return; return;
} }
@@ -189,7 +193,7 @@ namespace ReallifeGamemode.Server.Gangwar
public void RmtEvent_StartGangwar(Player client) public void RmtEvent_StartGangwar(Player client)
{ {
User user = client.GetUser(); User user = client.GetUser();
if(user == null || user.Faction == null) if (user == null || user.Faction == null)
{ {
return; return;
} }

View File

@@ -385,12 +385,12 @@ namespace ReallifeGamemode.Server.Gangwar
{ {
if (getOwner() == FactionName) if (getOwner() == FactionName)
{ {
NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); logger.LogDebug($"GangwarKill - Adding Point for Faction {getAttacker()}");
Att_Score += 1; Att_Score += 1;
} }
else if (getAttacker() == FactionName) else if (getAttacker() == FactionName)
{ {
NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getOwner()}"); logger.LogDebug($"GangwarKill - Adding Point for Faction {getOwner()}");
Def_Score += 1; Def_Score += 1;
} }
} }