From 03338bf4d7605b0af4eb501d3ccbdc2ebcd3db68 Mon Sep 17 00:00:00 2001 From: VegaZ Date: Sun, 11 Apr 2021 02:23:00 +0200 Subject: [PATCH 1/6] Fix BLip Name Tag Color Fix --- ReallifeGamemode.Server/Managers/InteractionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 2382c7dc..a6123d95 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -259,11 +259,11 @@ namespace ReallifeGamemode.Server.Managers targetPlayer.TriggerEvent("toggleDutyMode", false); UpdateCharacterCloth.LoadCharacterDefaults(targetPlayer); ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen."); - } - targetUser.SetBlipAndNametagColor(); + } Medic.UpdateDutyMedics(); targetUser.FactionRankId = null; targetUser.FactionId = null; + targetUser.SetBlipAndNametagColor(); ChatService.SendMessage(player, "!{02FCFF}Du hast " + targetUser.Name + " aus der Fraktion geworfen."); dbContext.SaveChanges(); From 28c75d78419774210684f6ac8c80efcd7670bda8 Mon Sep 17 00:00:00 2001 From: VegaZ Date: Sun, 11 Apr 2021 02:32:11 +0200 Subject: [PATCH 2/6] Fix endlich Frak-Wechsel --- ReallifeGamemode.Server/Managers/InteractionManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index a6123d95..e6f8d581 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -258,12 +258,14 @@ namespace ReallifeGamemode.Server.Managers targetPlayer.SetData("duty", false); targetPlayer.TriggerEvent("toggleDutyMode", false); UpdateCharacterCloth.LoadCharacterDefaults(targetPlayer); - ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen."); + ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen."); + FactionHelper.ResetPlayer(targetPlayer, targetUser, dbContext); } Medic.UpdateDutyMedics(); targetUser.FactionRankId = null; targetUser.FactionId = null; targetUser.SetBlipAndNametagColor(); + ChatService.SendMessage(player, "!{02FCFF}Du hast " + targetUser.Name + " aus der Fraktion geworfen."); dbContext.SaveChanges(); From 4126e2251467f4d369c763eb23dc6f74c64f9f25 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 11 Apr 2021 02:25:23 +0200 Subject: [PATCH 3/6] fix tp hack --- ReallifeGamemode.Client/admin/anticheat.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ReallifeGamemode.Client/admin/anticheat.ts b/ReallifeGamemode.Client/admin/anticheat.ts index 1703050b..ebe95e13 100644 --- a/ReallifeGamemode.Client/admin/anticheat.ts +++ b/ReallifeGamemode.Client/admin/anticheat.ts @@ -181,7 +181,6 @@ let Difference = Behaviour.subtractVector(Behaviour.pos, mp.players.local.position) if (Math.abs(Difference.x) > 30 || Math.abs(Difference.y) > 30) { if (Behaviour.isWalking()) { - mp.gui.chat.push("tp hack"); mp.events.callRemote("CLIENT:CheatDetection", "Flyhack/Teleport") } } From 34726abc049638dbcf5a9f929d7574557e3184ba Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 11 Apr 2021 02:36:44 +0200 Subject: [PATCH 4/6] no health anti cheat when healing --- ReallifeGamemode.Server/Admin/AntiCheat.cs | 5 +++++ ReallifeGamemode.Server/Commands/AdminCommands.cs | 8 ++++---- ReallifeGamemode.Server/Commands/FactionCommands.cs | 3 ++- ReallifeGamemode.Server/Events/Login.cs | 2 +- ReallifeGamemode.Server/Extensions/ClientExtension.cs | 6 ++++++ ReallifeGamemode.Server/Factions/Medic/Medic.cs | 2 +- ReallifeGamemode.Server/Inventory/Items/FoodItem.cs | 2 +- ReallifeGamemode.Server/Wanted/Jail.cs | 8 ++++---- 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ReallifeGamemode.Server/Admin/AntiCheat.cs b/ReallifeGamemode.Server/Admin/AntiCheat.cs index ffc8937a..1dc48cce 100644 --- a/ReallifeGamemode.Server/Admin/AntiCheat.cs +++ b/ReallifeGamemode.Server/Admin/AntiCheat.cs @@ -47,5 +47,10 @@ namespace ReallifeGamemode.Server.Admin { lastAntiCheatBroadcastTime[(name, "Flyhack/Teleport")] = DateTime.Now.Subtract(antiCheatMessageCooldown).Add(TimeSpan.FromSeconds(5)); } + + internal static void NoHealthAntiCheatForPlayer(string name) + { + lastAntiCheatBroadcastTime[(name, "Healkey (unexpected HP added)")] = DateTime.Now.Subtract(antiCheatMessageCooldown).Add(TimeSpan.FromSeconds(5)); + } } } diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 4eaf5de2..cedff294 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1324,7 +1324,7 @@ namespace ReallifeGamemode.Server.Commands return; } - target.Health = hp; + target.SafeSetHealth(hp); ChatService.SendMessage(target, "~b~Deine HP wurden von " + player.Name + " auf " + hp + " gesetzt."); ChatService.SendMessage(player, "~b~Du hast die HP von " + target.Name + " auf " + hp + " gesetzt."); } @@ -1444,7 +1444,7 @@ namespace ReallifeGamemode.Server.Commands dbContext.SaveChanges(); } target.SafeTeleport(target.Position, 0, true); - target.Health = 100; + target.SafeSetHealth(100); Medic.delReviveTask(target); } @@ -2010,7 +2010,7 @@ namespace ReallifeGamemode.Server.Commands foreach (var managedPlayer in peopleInRange) { if (!managedPlayer.IsLoggedIn()) return; - managedPlayer.Health = hp; + managedPlayer.SafeSetHealth(hp); ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " die HP auf " + hp + " gesetzt."); } ChatService.SendMessage(player, "~b~Das Leben von " + peopleInRange.Count + " Spielern wurde auf " + hp + " gesetzt."); @@ -2415,7 +2415,7 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(managedPlayer, toPlayerChat); managedPlayer.SafeTeleport(managedPlayer.Position, 0, true); - managedPlayer.Health = 100; + managedPlayer.SafeSetHealth(100); Medic.delReviveTask(managedPlayer); } diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 674cb182..a32d7df9 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -6,6 +6,7 @@ using GTANetworkAPI; using Microsoft.EntityFrameworkCore; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Admin; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Managers; @@ -344,7 +345,7 @@ namespace ReallifeGamemode.Server.Commands dbContext.SaveChanges(); } deadPlayer.SafeTeleport(deadPlayer.Position, 0, true); - deadPlayer.Health = 50; + deadPlayer.SafeSetHealth(50); MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == deadPlayer.Name); Medic.RemoveTaskFromList(task); diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index 98164ab9..344c2ed5 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -144,7 +144,7 @@ namespace ReallifeGamemode.Server.Events { player.TriggerEvent("startDeathTimer", false); } - player.Health = 0; + player.SafeSetHealth(0); player.SetData("isDead", true); } else diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 9b92db14..1a1d34eb 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -74,6 +74,12 @@ namespace ReallifeGamemode.Server.Extensions } } + public static void SafeSetHealth(this Player player, int health) + { + AntiCheat.NoHealthAntiCheatForPlayer(player.Name); + player.SafeSetHealth(health); + } + public static void SetJailTime(this User user, bool killed) { if (user == null) diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 3d060783..bcff62c9 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -146,7 +146,7 @@ namespace ReallifeGamemode.Server.Factions.Medic dbContext.SaveChanges(); } - activeDecision.dTarget.Health = 100; + activeDecision.dTarget.SafeSetHealth(100); activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false); activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false); delHealTask(activeDecision.dTarget); diff --git a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs index 77f76cd4..03073fb5 100644 --- a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs @@ -27,7 +27,7 @@ namespace ReallifeGamemode.Server.Inventory.Items amountToAdd = 100 - player.Health; } - player.Health += amountToAdd; + player.SafeSetHealth(player.Health + amountToAdd); player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false); InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1); } diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index ad6fc243..bee57db4 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -29,7 +29,7 @@ namespace ReallifeGamemode.Server.Wanted player.RemoveAllWeapons(); player.ClearAttachments(); player.ClearAnimation(); - player.Health = 100; + player.SafeSetHealth(100); player.Armor = 0; Random rnd = new Random(); int rndInt = rnd.Next(1, 3); @@ -159,7 +159,7 @@ namespace ReallifeGamemode.Server.Wanted } player.TriggerEvent("jailTime", timeMinutes); - player.Health = 100; + player.SafeSetHealth(100); } } } @@ -182,7 +182,7 @@ namespace ReallifeGamemode.Server.Wanted player.GetUser(dbContext).JailTime = 0; dbContext.SaveChanges(); } - player.Health = 100; + player.SafeSetHealth(100); player.SafeTeleport(new Vector3(427.879, -984.65, 30.71)); ChatService.HQMessage("Beamter " + cop.Name + " hat " + user.Name + " aus dem Knast entlassen."); @@ -202,7 +202,7 @@ namespace ReallifeGamemode.Server.Wanted user.JailTime = 0; dbContext.SaveChanges(); - target.Health = 100; + target.SafeSetHealth(100); target.SafeTeleport(new Vector3(427.879, -984.65, 30.71)); ChatService.HQMessage(" Admin " + admin.Name + " hat " + user.Name + " aus dem Knast entlassen."); From 3a19c267281de79b99a780c6361bdc1a2d273af1 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 11 Apr 2021 02:45:43 +0200 Subject: [PATCH 5/6] set hp fix --- ReallifeGamemode.Server/Extensions/ClientExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 1a1d34eb..01706dbe 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -77,7 +77,7 @@ namespace ReallifeGamemode.Server.Extensions public static void SafeSetHealth(this Player player, int health) { AntiCheat.NoHealthAntiCheatForPlayer(player.Name); - player.SafeSetHealth(health); + player.Health = health; } public static void SetJailTime(this User user, bool killed) From ec9fbbee3a629a1f51ad9e95be64313fa2c10da3 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 11 Apr 2021 02:53:08 +0200 Subject: [PATCH 6/6] fix uninvite offduty GEHEN --- ReallifeGamemode.Server/Managers/InteractionManager.cs | 2 +- ReallifeGamemode.Server/Util/FactionHelper.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index e6f8d581..7906e1f2 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -255,7 +255,7 @@ namespace ReallifeGamemode.Server.Managers if (targetPlayer != null) { - targetPlayer.SetData("duty", false); + targetUser.SetData("duty", false); targetPlayer.TriggerEvent("toggleDutyMode", false); UpdateCharacterCloth.LoadCharacterDefaults(targetPlayer); ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen."); diff --git a/ReallifeGamemode.Server/Util/FactionHelper.cs b/ReallifeGamemode.Server/Util/FactionHelper.cs index 1f54c2d0..b39177e6 100644 --- a/ReallifeGamemode.Server/Util/FactionHelper.cs +++ b/ReallifeGamemode.Server/Util/FactionHelper.cs @@ -36,9 +36,9 @@ namespace ReallifeGamemode.Server.Util public static void ResetPlayer(Player player, User user, DatabaseContext dbContext) { - if (player.GetData("duty") == true) + if (user.GetData("duty") == true) { - player.SetData("duty", false); + user.SetData("duty", false); Medic.UpdateDutyMedics(); }