From 3c1dfea4029f483cba7b88d02631148a5afae5b3 Mon Sep 17 00:00:00 2001 From: hydrant Date: Tue, 18 May 2021 00:11:30 +0200 Subject: [PATCH 01/13] prevent nullreference in exitvehicle --- .../Events/EnterVehicleAttempt.cs | 1 - ReallifeGamemode.Server/Events/ExitVehicle.cs | 77 +++++++------------ 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs index 0370afa7..f4814c45 100644 --- a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs +++ b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs @@ -228,7 +228,6 @@ namespace ReallifeGamemode.Server.Events } else { - ExitVehicle.timerNoobRollerRespawn.Stop(); vehicle.SetData("NoobSpawnVehicleTimer", false); } } diff --git a/ReallifeGamemode.Server/Events/ExitVehicle.cs b/ReallifeGamemode.Server/Events/ExitVehicle.cs index 255b4a5c..9e2deda1 100644 --- a/ReallifeGamemode.Server/Events/ExitVehicle.cs +++ b/ReallifeGamemode.Server/Events/ExitVehicle.cs @@ -14,21 +14,41 @@ namespace ReallifeGamemode.Server.Events { public class ExitVehicle : Script { - object LastVehicle; - public static Timer timerNoobRollerRespawn = new Timer(600000); //10 Minuten Timer NoobRollerRespawn [ServerEvent(Event.PlayerExitVehicleAttempt)] public void OnPlayerExitVehicle(Player client, GTANetworkAPI.Vehicle vehicle) { - LastVehicle = vehicle; - if (client.VehicleSeat != 0) + if (client == null) + { return; + } - if (vehicle.GetServerVehicle() is FactionVehicle veh) + if (client.VehicleSeat != 0) + { + return; + } + + if (vehicle == null) + { + return; + } + + ServerVehicle serverVehicle = vehicle.GetServerVehicle(); + if (serverVehicle == null) + { + return; + } + + if (serverVehicle is FactionVehicle factionVehicle) { User u = client.GetUser(); + if (u == null) + { + return; + } + if ((u.FactionId != null) - && (veh.GetOwners().Contains(u.FactionId ?? 0)) - && (veh.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || veh.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) + && (factionVehicle.GetOwners().Contains(u.FactionId ?? 0)) + && (factionVehicle.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || factionVehicle.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) && vehicle.HasData("weaponDeal") && vehicle.GetData("weaponDeal") == true) { @@ -36,14 +56,14 @@ namespace ReallifeGamemode.Server.Events client.TriggerEvent("destroyCP"); } else if ((u.FactionId != null) - && (veh.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || veh.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) + && (factionVehicle.Model == WeaponDealManager.WEAPON_DEAL_GANG_VEHICLE_HASH || factionVehicle.Model == WeaponDealManager.WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) && vehicle.HasData("WeaponDealLoad") && vehicle.GetData("WeaponDealLoad") == true) { client.TriggerEvent("SERVER:setMarkerBehindVehicle", vehicle); } } - if (vehicle.GetServerVehicle() is SchoolVehicle vehS) + if (serverVehicle is SchoolVehicle schoolVehicle) { if (client.HasData("ActiveSchool")) { @@ -56,45 +76,6 @@ namespace ReallifeGamemode.Server.Events CheckPointHandle.DeleteCheckpoints(client); } } - if (vehicle.GetData("NoobSpawnVehicle") == true) - { - timerNoobRollerRespawn.Start(); - vehicle.SetData("NoobSpawnVehicleTimer", true); - timerNoobRollerRespawn.AutoReset = false; - timerNoobRollerRespawn.Elapsed += Timer600000_Elapsed; - //LastVehicle = vehicle; - //timerNoobRollerRespawn.Elapsed += async (sender, e) => {await - } - } - private static void Timer600000_Elapsed(object sender, ElapsedEventArgs e) - { - //ExitVehicle c = new ExitVehicle(); - //Vehicle veh = c.LastVehicle; - NAPI.Task.Run(() => - { - NAPI.Pools.GetAllVehicles().ForEach(v => - { - if (v.GetData("NoobSpawnVehicle") == true) - { - if (v.GetData("NoobSpawnVehicleTimer") == true) - { - v.ResetData("NoobSpawnVehicleTimer"); - v.ResetData("NoobSpawnVehicle"); - VehicleManager.DeleteVehicle(v); - } - } - }); - NAPI.Pools.GetAllPlayers().ForEach(p => - { - //if (!p.IsInVehicle) - //{ - if (p.GetData("HatNoobSpawnVehicle") == true) - { - p.ResetData("HatNoobSpawnVehicle"); - } - //} - }); - }); } } } From 4f458e9ab346357ea65b17828b0b712049658c9f Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 23:14:51 +0200 Subject: [PATCH 02/13] adjust admincommands (method names, removed useless) (cherry picked from commit baf977158cd1c486a389beba9e0349593b33af52) --- .../Commands/AdminCommands.cs | 175 +++--------------- 1 file changed, 27 insertions(+), 148 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 9f4a938a..ff993e82 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -532,25 +532,6 @@ namespace ReallifeGamemode.Server.Commands } } - [Command("bitcoin", "~m~/bitcoin [ID]")] - public void CmdAdminBitcoin(Player player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Player target = PlayerService.GetPlayerByNameOrId(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.TriggerEvent("CLIENT:PlaySound", "fun/bitcoinnect", "mp3", 50); - } - #endregion Support #region Admin @@ -567,7 +548,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]", Alias = "rmss")] - public void CmdAdminRmss(Player player, String targetname) + public void CmdAdminRemSpawnSchutz(Player player, String targetname) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -620,7 +601,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("ac", "~m~Benutzung: ~s~/ac [Nachricht]", GreedyArg = true)] - public void CmdAdminA(Player player, string message) + public void CmdAdminChat(Player player, string message) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1062,110 +1043,8 @@ namespace ReallifeGamemode.Server.Commands } } - [Command("destroyped", "~m~Benutzung: ~s~/destroyped [PedNr]")] - public void CmdAdminAddPPed(Player player, int PedNr) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:DestroyPed", PedNr); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addpped", "~m~Benutzung: ~s~/addpped [PedNr] [model] [dimension] [Dynamic] [Freezed] [Collision(0-3)] [Weapon] [AttackProof] [Fire/Explosion-Proof] [DrownProof]")] - public void CmdAdminAddPPed(Player player, Array PedNr, string model, uint dimension = 0, bool dynamic = false, bool freeze = false, int collision = 0, string weapon = "none", bool attackproof = false, bool fireexplosionproof = false, bool drownproof = false) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:AddPed", PedNr, model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension, dynamic, freeze, collision, weapon, attackproof, fireexplosionproof, drownproof); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addmped", "~m~Benutzung: ~s~/addmped [model] [dimension]")] - public void CmdAdminAddMPed(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:AddPedModel", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addgped", "~m~Benutzung: ~s~/addgped")] - public void CmdAdminAddGPed(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - Ped Peter = NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - - //Peter.freezePosition(true); - } - - [Command("addgpedmore", "~m~Benutzung: ~s~/addgpedMore")] - public void CmdAdminAddGPedMore(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - Ped Peter = NAPI.Ped.CreatePed(PedHash.ChickenHawk, new Vector3(player.Position.X + 1, player.Position.Y, player.Position.Z + 2), player.Heading, dimension); - Ped Peter2 = NAPI.Ped.CreatePed(PedHash.MovAlien01, new Vector3(player.Position.X + 2, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter3 = NAPI.Ped.CreatePed(PedHash.Chimp, new Vector3(player.Position.X + 3, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter4 = NAPI.Ped.CreatePed(PedHash.Boar, new Vector3(player.Position.X + 4, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter5 = NAPI.Ped.CreatePed(PedHash.BradCadaverCutscene, new Vector3(player.Position.X + 5, player.Position.Y, player.Position.Z + 2), player.Heading, dimension); - Ped Peter6 = NAPI.Ped.CreatePed(PedHash.Cat, new Vector3(player.Position.X - 1, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter7 = NAPI.Ped.CreatePed(PedHash.Chop, new Vector3(player.Position.X - 2, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter8 = NAPI.Ped.CreatePed(PedHash.Cormorant, new Vector3(player.Position.X - 3, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter9 = NAPI.Ped.CreatePed(PedHash.Cow, new Vector3(player.Position.X - 4, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter10 = NAPI.Ped.CreatePed(PedHash.Deer, new Vector3(player.Position.X - 5, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter11 = NAPI.Ped.CreatePed(PedHash.Coyote, new Vector3(player.Position.X, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter12 = NAPI.Ped.CreatePed(PedHash.Crow, new Vector3(player.Position.X, player.Position.Y + 2, player.Position.Z + 2), player.Heading, dimension); - Ped Peter13 = NAPI.Ped.CreatePed(PedHash.Humpback, new Vector3(player.Position.X, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter14 = NAPI.Ped.CreatePed(PedHash.Husky, new Vector3(player.Position.X, player.Position.Y + 4, player.Position.Z), player.Heading, dimension); - Ped Peter15 = NAPI.Ped.CreatePed(PedHash.JohnnyKlebitz, new Vector3(player.Position.X, player.Position.Y + 5, player.Position.Z - 1), player.Heading, dimension); - Ped Peter16 = NAPI.Ped.CreatePed(PedHash.Pig, new Vector3(player.Position.X, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter17 = NAPI.Ped.CreatePed(PedHash.Pigeon, new Vector3(player.Position.X, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter18 = NAPI.Ped.CreatePed(PedHash.Poodle, new Vector3(player.Position.X, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter19 = NAPI.Ped.CreatePed(PedHash.Pug, new Vector3(player.Position.X, player.Position.Y - 4, player.Position.Z), player.Heading, dimension); - Ped Peter20 = NAPI.Ped.CreatePed(PedHash.Rabbit, new Vector3(player.Position.X, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter21 = NAPI.Ped.CreatePed(PedHash.Rat, new Vector3(player.Position.X + 1, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter22 = NAPI.Ped.CreatePed(PedHash.Retriever, new Vector3(player.Position.X + 2, player.Position.Y + 2, player.Position.Z), player.Heading, dimension); - Ped Peter23 = NAPI.Ped.CreatePed(PedHash.Rhesus, new Vector3(player.Position.X + 3, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter24 = NAPI.Ped.CreatePed(PedHash.Rottweiler, new Vector3(player.Position.X + 4, player.Position.Y + 4, player.Position.Z), player.Heading, dimension); - Ped Peter25 = NAPI.Ped.CreatePed(PedHash.Seagull, new Vector3(player.Position.X + 5, player.Position.Y + 5, player.Position.Z + 2), player.Heading, dimension); - Ped Peter26 = NAPI.Ped.CreatePed(PedHash.Shepherd, new Vector3(player.Position.X - 1, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter27 = NAPI.Ped.CreatePed(PedHash.Stingray, new Vector3(player.Position.X - 2, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter28 = NAPI.Ped.CreatePed(PedHash.Westy, new Vector3(player.Position.X - 3, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter29 = NAPI.Ped.CreatePed(PedHash.MountainLion, new Vector3(player.Position.X - 4, player.Position.Y - 4, player.Position.Z), player.Heading, dimension); - Ped Peter30 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 5, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter31 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 1, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter32 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 3, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter33 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 1, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter34 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X - 3, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter35 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X + 5, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter36 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 1, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter37 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 4, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter38 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 5, player.Position.Y + 2, player.Position.Z), player.Heading, dimension); - Ped Peter39 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 4, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - - //Peter.freezePosition(true); - } - [Command("gotox", "~m~Benutzung: ~s~/gotox [X] [Y] [Z]")] - public void CmdAdminGotoxyz(Player player, float x, float y, float z) + public void CmdAdminGotox(Player player, float x, float y, float z) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1515,7 +1394,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("aclear", "~m~Benutzung: ~s~/aclear [Spieler] [Grund]", GreedyArg = true)] - public void CmdFactionClear(Player player, string nameOrId, string reason) + public void CmdAdminClear(Player player, string nameOrId, string reason) { User user = player.GetUser(); if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) @@ -1650,7 +1529,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("vcolor", "~m~Benutzung: ~s~/vcolor [Farb-ID1] [Farb-ID2]")] - public void CmdAdminColor(Player player, int color1, int color2) + public void CmdAdminVColor(Player player, int color1, int color2) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1834,7 +1713,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setsvar", "~m~Benutzung:~s~ /setsvar [ID] [WERT]")] - public void CmdAdmSetSvar(Player player, int varId, int varValue) + public void CmdAdminSetSvar(Player player, int varId, int varValue) { if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true) { @@ -1845,7 +1724,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")] - public void CmdAdmCreateTurf(Player player, float option) + public void CmdAdminCreateTurf(Player player, float option) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1867,7 +1746,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")] - public void CmdAdmCancleTurf(Player player) + public void CmdAdminCancleTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1878,7 +1757,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")] - public void CmdAdmReloadTurf(Player player) + public void CmdAdminReloadTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1890,7 +1769,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")] - public void CmdAdmDeleteTurf(Player player) + public void CmdAdminDeleteTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1901,7 +1780,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")] - public void CmdAdmSetTurfPoint(Player player) + public void CmdAdminSetTurfPoint(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1943,7 +1822,7 @@ namespace ReallifeGamemode.Server.Commands } ChatService.SendMessage(target, "~r~WARNINFO: ~w~Dir wurde von " + adminPlayername + " ein Warn entfernt: " + reason); - ChatService.Broadcast("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " ein Warn entfernt: " + reason); + ChatService.BroadcastAdmin("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " ein Warn entfernt: " + reason, AdminLevel.ADMIN); } [Command("setskill", "~m~Benutzung: ~s~/setskill [Playerid] [Bus/Pilot] [Menge]")] @@ -2124,7 +2003,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")] - public void CmdAdminSetweather(Player player, string weather) + public void CmdAdminSetWeather(Player player, string weather) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2174,7 +2053,7 @@ namespace ReallifeGamemode.Server.Commands [Command("showtuningmenu", "~m~Benutzung: ~s~/showtuningmenu", Alias = "stm")] - public void CmdAdminShowtuningmenu(Player player) + public void CmdAdminShowTuningMenu(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2244,14 +2123,14 @@ namespace ReallifeGamemode.Server.Commands [Command("wepmod", "~m~Benutzung: ~s~/wepmod [Variable]")] public void CmdWeaponModifier(Player player, float modifier) { - player.SendChatMessage("Modifier steht auf" + modifier); + player.SendChatMessage("Modifier steht auf " + modifier); player.TriggerEvent("SERVER:WeaponModifier2", player, modifier, 1); } [Command("wepmmod", "~m~Benutzung: ~s~/wepmmod [Variable]")] public void CmdWeaponMeeleModifier(Player player, float modifier) { - player.SendChatMessage("MeeleModifier steht auf" + modifier); + player.SendChatMessage("MeeleModifier steht auf " + modifier); player.TriggerEvent("SERVER:WeaponModifier2", player, 1, modifier); } @@ -2269,7 +2148,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("sethandmoney", "~m~Benutzung: ~s~/sethandmoney [Name/ID] [Menge]")] - public void CmdAdminSetUserHandMoney(Player admin, string targetname, int amount) + public void CmdAdminSetHandMoney(Player admin, string targetname, int amount) { if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2296,7 +2175,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("givehandmoney", "~m~Benutzung: ~s~/givehandmoney [Name/ID] [Menge]")] - public void CmdAdminGiveUserHandMoney(Player admin, string targetname, int amount) + public void CmdAdminGiveHandMoney(Player admin, string targetname, int amount) { if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2323,7 +2202,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]: ~g~blip, ~g~atm")] - public void CmdAdminSetQuickSaveMode(Player player, string mode) + public void CmdAdminQuickSaveMode(Player player, string mode) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2373,7 +2252,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setshopitem", "~m~Benutzung: ~s~/setshopitem [Item ID]")] - public void CmdAdminSetItemInShop(Player player, int itemId) + public void CmdAdminSetShopItem(Player player, int itemId) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2419,7 +2298,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("rmshopitem", "~m~Benutzung: ~s~/rmshopitem [Item ID]")] - public void CmdAdminRemoveItemInShop(Player player, int itemId) + public void CmdAdminRmShopItem(Player player, int itemId) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3228,7 +3107,7 @@ namespace ReallifeGamemode.Server.Commands // [Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]", Alias = "mfr")] - public void CmdFactionManageFactionRanks(Player player, int factionID) + public void CmdAdminManageFactionRanks(Player player, int factionID) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3342,7 +3221,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setmoney", "~m~Benutzung: ~s~/setmoney [Name] [Menge]")] - public void SetPlayerMoney(Player player, string receiver, int amount) + public void CmdAdminSetMoney(Player player, string receiver, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3367,7 +3246,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("givemoney", "~m~Benutzung: ~s~/givemoney [Name] [Menge]")] - public void GivePlayerMoney(Player player, string receiver, int amount) + public void GiveAdminGiveMoney(Player player, string receiver, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3393,7 +3272,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setbusinessowner", "~m~Benutzung: ~s~/setbusinessowner [Name] [Business ID]")] - public void CmdAdminSetbusinessowner(Player player, string name, int businessid) + public void CmdAdminSetBusinessOwner(Player player, string name, int businessid) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3474,7 +3353,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setbusinessbankbalance", "~m~Benutzung: ~s~/setbusinessbankbalance [Business ID] [Menge]")] - public void CmdAdminGivebusinessbankbalance(Player player, int businessid, int amount) + public void CmdAdminSetBusinessBankBalance(Player player, int businessid, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -4006,7 +3885,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("blind", "~m~Benutzung: ~s~/blind [Spieler] [Mode]")] - public void CmdBlind(Player player, string name, int mode) + public void CmdAdminBlind(Player player, string name, int mode) { if (!player.IsLoggedIn()) return; From 91584f267ada57e2d6dd81aa8b361d3a37f32beb Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 13 May 2021 22:41:47 +0200 Subject: [PATCH 03/13] fix managefactionranks (cherry picked from commit 8dc5ad48bbde67c8afa09cc02e078b4f07d41a31) --- ReallifeGamemode.Client/FactionManagement/main.ts | 3 ++- .../assets/html/factionmanagement/ranks/index.html | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/FactionManagement/main.ts b/ReallifeGamemode.Client/FactionManagement/main.ts index b9ae499a..fc53aee7 100644 --- a/ReallifeGamemode.Client/FactionManagement/main.ts +++ b/ReallifeGamemode.Client/FactionManagement/main.ts @@ -12,7 +12,6 @@ export default function factionManagement() { mp.events.add('manageFactionRanks', (ranks) => { if (manageFactionRanksBrowser !== null) return; manageFactionRanksBrowser = mp.browsers.new('package://assets/html/factionmanagement/ranks/index.html'); - mp.gui.chat.activate(false); rankData = JSON.parse(ranks); }); @@ -22,6 +21,7 @@ export default function factionManagement() { manageFactionRanksBrowser.execute(`setFactionName('${rankData.FactionName}')`); manageFactionRanksBrowser.execute(`loadData(` + JSON.stringify(rankData.Ranks) + `)`); mp.gui.cursor.show(true, true); + this.data.InMenu = true; } }); @@ -30,6 +30,7 @@ export default function factionManagement() { manageFactionRanksBrowser.destroy(); mp.gui.cursor.show(false, false); mp.gui.chat.activate(true); + this.data.InMenu = false; var obj: FactionRanks = { factionId: rankData.FactionId, diff --git a/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html b/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html index 7561a03f..f8cfa5ec 100644 --- a/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html +++ b/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html @@ -6,14 +6,16 @@ + - + +
-

: Ränge bearbeiten

+

{{ name }}: Ränge bearbeiten

@@ -27,4 +29,5 @@ + \ No newline at end of file From 2a6bd35e6db5e9153726098b29a21f27a6c01bf6 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 9 May 2021 23:54:58 +0200 Subject: [PATCH 04/13] fix login message @airmake --- ReallifeGamemode.Server/Util/GlobalHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index 88e0a5e3..94849ec3 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -14,7 +14,7 @@ namespace ReallifeGamemode.Server.Util { ".MichaPlays.", "Der echte Ballas Leader ist online (MichaPlays)" }, { "iCroniX", "Life of Malle - Eimer für Alle - Alle für Malle - Böllern! (CroniX)" }, { "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" }, - { "AirMake", "The fresh breeze of the stone ist back. (AirMake)" }, + { "AirMake", "The fresh breeze of the stone is back. (AirMake)" }, { "raviatex", "I'll remember you all in therapy. (aviate)" }, { "datgame__", "KOPF ENTWICKLUNG!! (hydrant)" }, { "Roachkook", "2head Entwickler ist wieder online (kookroach)" } From 5a9c8e55086bcff04d1c8d68a6d9acc6afec7894 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 11 May 2021 01:14:23 +0200 Subject: [PATCH 05/13] zeit zum abtauchen auf 2,4 sekunden runtergeschraubt --- ReallifeGamemode.Client/Gui/blips.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Client/Gui/blips.ts b/ReallifeGamemode.Client/Gui/blips.ts index a648181b..9350fe60 100644 --- a/ReallifeGamemode.Client/Gui/blips.ts +++ b/ReallifeGamemode.Client/Gui/blips.ts @@ -72,7 +72,7 @@ export default function playerBlips() { } mp.events.callRemote("CLIENT:EscapeWanted"); - }, 300000); //120000 -> 2 min , 300000 -> 5min + }, 2.4 * 60 * 1000); // 2.4 Minuten } }, 50); From df69c53a4cb4201625da8690b5ccce455d72e055 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 13 May 2021 22:41:47 +0200 Subject: [PATCH 06/13] fix managefactionranks From c2cd6ebc7bbed7545fc89ab4d9ab2298437949e2 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 14 May 2021 00:25:44 +0200 Subject: [PATCH 07/13] wt nachrichten angepasst --- ReallifeGamemode.Server/Events/Key.cs | 2 +- .../WeaponDeal/WeaponDealManager.cs | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index bc347c28..99e2fe66 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -401,7 +401,7 @@ namespace ReallifeGamemode.Server.Events logger.LogInformation("Player {0} put the weapon deal item \"{1}\" (amount: {2}) in weapon rack of faction {3}", player.Name, weapon.WeaponModel, item.Amount, user.FactionId); weapon.Ammount += item.Amount; - ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefügt."); + ChatService.SendMessage(player, $"~y~[WT] ~s~Du hast eine ~y~Kiste abgeladen ~s~(Inhalt: {item.Amount}x {iItem.Name})."); unloadedWeaponPackage = true; context.Remove(item); } diff --git a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs index 8cfaae03..14dd9af6 100644 --- a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs +++ b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs @@ -128,9 +128,9 @@ namespace ReallifeGamemode.Server.WeaponDeal msg = "Die Waffenlieferung steht zur Abholung bereit"; } - ChatService.BroadcastFaction($"~y~[WAFFENDEAL]~s~ {msg}.", user.Faction); + ChatService.BroadcastFaction($"~y~[WT]~s~ {msg}.", user.Faction); - ChatService.SendMessage(client, "~y~[WAFFENDEAL]~s~ Steige in den ~y~Transporter ~s~ein und fahre zum Übergabepunkt."); + ChatService.SendMessage(client, "~y~[WT]~s~ Steig in den ~y~Transporter ~s~ein und fahre zum Übergabepunkt."); fVeh.SetData("weaponDeal", true); InventoryManager.RemoveAllItemsfromVehicleInventory(fVeh); Faction fac = context.Factions.Where(f => f.Id == user.FactionId).FirstOrDefault(); @@ -147,15 +147,6 @@ namespace ReallifeGamemode.Server.WeaponDeal } } - /* - public static void WeaponDealTimer() - { - System.Timers.Timer timer = new System.Timers.Timer(60000); - timer.Start(); - timer.Elapsed += Timer_Elapsed; - } - */ - public static void Timer_Elapsed() { using (var context = new DatabaseContext()) @@ -259,8 +250,8 @@ namespace ReallifeGamemode.Server.WeaponDeal InventoryManager.AddItemToVehicleInventory(fVeh, item7.ItemId, item7.Amount); } - ChatService.BroadcastFaction("~y~[WAFFENDEAL] ~w~Der Transporter wurde erfolgreich beladen.", new List() { client.GetUser().Faction.Id }); - client.SendChatMessage("~y~[WAFFENDEAL] ~w~Fahre nun zu deiner Base zurück."); + ChatService.BroadcastFaction("~y~[WT] ~w~Der Transporter wurde erfolgreich beladen.", new List() { client.GetUser().Faction.Id }); + client.SendChatMessage("~y~[WT] ~w~Fahre nun zu deiner Base zurück."); BasePoints basePoints = new BasePoints(); basePoints.getbase(user.FactionId, client); } From 7a49fa4aa29562344d0faf08837456f20919d5e1 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 14 May 2021 00:33:20 +0200 Subject: [PATCH 08/13] duty notification angepasst --- ReallifeGamemode.Server/Events/Key.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 99e2fe66..c41554ca 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -312,7 +312,7 @@ namespace ReallifeGamemode.Server.Events if (user.GetData("duty") == false) { user.SetData("duty", true); - player.SendNotification("Du bist nun ~g~im Dienst."); + player.SendNotification("Du bist nun ~g~im Dienst"); player.TriggerEvent("toggleDutyMode", true); player.TriggerEvent("abortSpawnschutz"); if (user.FactionId == 2) //Fire Department @@ -353,7 +353,7 @@ namespace ReallifeGamemode.Server.Events else { user.SetData("duty", false); - player.SendNotification("Du bist nun ~r~außer Dienst."); + player.SendNotification("Du bist nun ~r~nicht mehr im Dienst"); player.TriggerEvent("toggleDutyMode", false); Medic.UpdateDutyMedics(); UpdateCharacterCloth.LoadCharacterDefaults(player); From 5527c420403d6c182ab1f9edb3cc9e4edb971c35 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 14 May 2021 00:53:46 +0200 Subject: [PATCH 09/13] mfr wurde jetzt wirklich gefixt --- .../assets/html/factionmanagement/ranks/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html b/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html index f8cfa5ec..5d04d846 100644 --- a/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html +++ b/ReallifeGamemode.Client/assets/html/factionmanagement/ranks/index.html @@ -24,10 +24,10 @@
- - - - + + + + \ No newline at end of file From 09bd4357fde2fac4acb58d0654b7606255719e25 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 14 May 2021 01:01:56 +0200 Subject: [PATCH 10/13] mfr: this.data.InMenu gibt error, deswegen wieder raus sorry @airmake --- ReallifeGamemode.Client/inputhelper/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ReallifeGamemode.Client/inputhelper/index.ts b/ReallifeGamemode.Client/inputhelper/index.ts index 62e509ae..6297caab 100644 --- a/ReallifeGamemode.Client/inputhelper/index.ts +++ b/ReallifeGamemode.Client/inputhelper/index.ts @@ -29,8 +29,7 @@ export default class InputHelper { } show() { - if (this.created) return; - this.data.InMenu = true; + if (this.created) return; this.created = true; this.browser = mp.browsers.new('package://assets/html/inputhelper/index.html'); mp.gui.cursor.show(true, true); @@ -44,11 +43,9 @@ export default class InputHelper { mp.events.remove('cef_request_title'); mp.events.remove('closeinputhelper'); this.browser.destroy(); - this.data.InMenu = false; this.created = false; this.browser = null; mp.gui.cursor.show(false, false); - } } From 6a958d77cd148c262e202da5525e5642cade034d Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 16 May 2021 20:46:14 +0200 Subject: [PATCH 11/13] /aunshow und NoClip auf Admin 1 --- ReallifeGamemode.Server/Commands/AdminCommands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index ff993e82..3da213f2 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1645,7 +1645,7 @@ namespace ReallifeGamemode.Server.Commands public void CmdAdminUnshow(Player player) { User user = player.GetUser(); - if (!user.IsAdmin(AdminLevel.HEADADMIN)) + if (!user.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -3945,7 +3945,7 @@ namespace ReallifeGamemode.Server.Commands [RemoteEvent("Noclip")] public void Noclip(Player player) { - if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN)) + if (!player.GetUser().IsAdmin(AdminLevel.ADMIN)) { return; } From 16aab6a8bbcfcc62e4db29f45bfe28ffda2457aa Mon Sep 17 00:00:00 2001 From: hydrant Date: Tue, 25 May 2021 20:45:31 +0200 Subject: [PATCH 12/13] =?UTF-8?q?l=C3=BCckenlose=20nachvollziehbarkeit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/AdminCommands.cs | 3 +++ ReallifeGamemode.Server/Commands/UserCommands.cs | 16 +++++++++++++--- ReallifeGamemode.Server/Events/Death.cs | 15 ++++++++++----- ReallifeGamemode.Server/Events/Key.cs | 7 ++++++- ReallifeGamemode.Server/Gangwar/Gangwar.cs | 16 ++++++++++------ ReallifeGamemode.Server/Gangwar/Turf.cs | 4 ++-- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 3da213f2..2d38395c 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1935,6 +1935,7 @@ namespace ReallifeGamemode.Server.Commands { if (!managedPlayer.IsLoggedIn()) return; 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(player, "~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben"); @@ -3826,6 +3827,8 @@ namespace ReallifeGamemode.Server.Commands 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); 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."); diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index ec9dfcd2..4875c2e0 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -45,19 +45,24 @@ namespace ReallifeGamemode.Server.Commands } [Command("eventport", "~m~eventport")] - public void CmdUserEventport(Player player, String option = "") + public void CmdUserEventport(Player player, string option = "") { if (!player.IsLoggedIn()) return; + option = option.ToLower(); if (option == "on") { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { return; } - PositionManager.eventportPosition = player.Position; + Vector3 position = player.Position; + PositionManager.eventportPosition = position; PositionManager.eventportActive = true; + 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; } @@ -69,6 +74,8 @@ namespace ReallifeGamemode.Server.Commands } PositionManager.eventportActive = false; 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; } @@ -92,7 +99,10 @@ namespace ReallifeGamemode.Server.Commands int randomX = 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.SendNotification("Du hast dich zum Event teleportiert"); diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index f64e53a6..4c3a3637 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -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(); + private readonly Dictionary lastPlayerDeathTime = new Dictionary(); [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()) { diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index c41554ca..69f12ced 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -297,7 +297,7 @@ namespace ReallifeGamemode.Server.Events 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); nearestBehindVehiclePoint.usePoint(player); @@ -909,6 +909,11 @@ namespace ReallifeGamemode.Server.Events return; } + if (player.Dead == true) + { + return; + } + bool state = VehicleStreaming.GetEngineState(v); ServerVehicle sV = v.GetServerVehicle(); if (sV != null) diff --git a/ReallifeGamemode.Server/Gangwar/Gangwar.cs b/ReallifeGamemode.Server/Gangwar/Gangwar.cs index 8d6ac346..10474ac8 100644 --- a/ReallifeGamemode.Server/Gangwar/Gangwar.cs +++ b/ReallifeGamemode.Server/Gangwar/Gangwar.cs @@ -1,16 +1,20 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Gangwar { public class Gangwar : Script { + private static ILogger logger = LogManager.GetLogger(); + public static Turf[] _loadedTurfs; private static List turfs; public const int GANGWAR_TOTAL_TIME = 900; @@ -53,19 +57,19 @@ namespace ReallifeGamemode.Server.Gangwar var killerInsideTurf = killer.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) { - 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); foreach (var turf in getTurfs()) { if (turf.getId() == victim.GetData("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; - NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}"); + logger.LogDebug($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}"); turf.setKill(victimFactionName); return; } @@ -96,7 +100,7 @@ namespace ReallifeGamemode.Server.Gangwar [RemoteEvent("Gangarea:Leave")] public void RmtEvent_TurfLeave(Player client, string jsonId) { - if(string.IsNullOrEmpty(jsonId)) + if (string.IsNullOrEmpty(jsonId)) { return; } @@ -189,7 +193,7 @@ namespace ReallifeGamemode.Server.Gangwar public void RmtEvent_StartGangwar(Player client) { User user = client.GetUser(); - if(user == null || user.Faction == null) + if (user == null || user.Faction == null) { return; } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 58f29fb1..b094a328 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -385,12 +385,12 @@ namespace ReallifeGamemode.Server.Gangwar { if (getOwner() == FactionName) { - NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); + logger.LogDebug($"GangwarKill - Adding Point for Faction {getAttacker()}"); Att_Score += 1; } else if (getAttacker() == FactionName) { - NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getOwner()}"); + logger.LogDebug($"GangwarKill - Adding Point for Faction {getOwner()}"); Def_Score += 1; } } From cb78c351e6b56c92259c7f3351e6cc68836c1a7f Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 25 May 2021 20:21:19 +0000 Subject: [PATCH 13/13] jeder kann in den chat schreiben --- ReallifeGamemode.Client/Gui/deathscreen.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/deathscreen.ts b/ReallifeGamemode.Client/Gui/deathscreen.ts index 32826cce..5aeb9d91 100644 --- a/ReallifeGamemode.Client/Gui/deathscreen.ts +++ b/ReallifeGamemode.Client/Gui/deathscreen.ts @@ -26,12 +26,7 @@ export default function deathScreen() { mp.events.add("startDeathTimer", (isAdmin) => { if (isDeath === false) { isDeath = true; - if (isAdmin) { - mp.gui.chat.activate(true); - } - else { - mp.gui.chat.activate(false); - } + mp.gui.chat.activate(true); mp.game.audio.playSoundFrontend(-1, "Bed", "WastedSounds", true); deathDate = new Date(); respawnTime = Math.floor(deathDate.getTime() / 1000 + maxDeathTime);