From 9f6282439d3c5442437e4e24644944f35e11422b Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 14:14:11 +0200 Subject: [PATCH 1/6] [HOTFIX] Fix server crash on gangwar end --- ReallifeGamemode.Server/Gangwar/Gangwar.cs | 8 ++--- ReallifeGamemode.Server/Gangwar/Turf.cs | 34 +++++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ReallifeGamemode.Server/Gangwar/Gangwar.cs b/ReallifeGamemode.Server/Gangwar/Gangwar.cs index 0c14b963..b2a3b9b3 100644 --- a/ReallifeGamemode.Server/Gangwar/Gangwar.cs +++ b/ReallifeGamemode.Server/Gangwar/Gangwar.cs @@ -40,10 +40,10 @@ namespace ReallifeGamemode.Server.Gangwar NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); foreach (var l in NAPI.Pools.GetAllPlayers()) { - if (!l.IsLoggedIn() && !l.GetUser().FactionLeader) - return; - - l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + if (l.IsLoggedIn() && l.GetUser()?.FactionLeader == true) + { + l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + } } } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index ea2f3ea0..335920fa 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -137,7 +137,7 @@ namespace ReallifeGamemode.Server.Gangwar { foreach (Player gangwarPlayer in this.playerInGangwar) { - if(!gangwarPlayer.IsLoggedIn()) + if (!gangwarPlayer.IsLoggedIn()) { continue; } @@ -159,7 +159,7 @@ namespace ReallifeGamemode.Server.Gangwar { foreach (Player gangwarPlayer in this.playerInGangwar) { - if(!gangwarPlayer.IsLoggedIn()) + if (!gangwarPlayer.IsLoggedIn()) { continue; } @@ -242,10 +242,22 @@ namespace ReallifeGamemode.Server.Gangwar this.timer = null; using (var dbContext = new DatabaseContext()) { + Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction?.Name == this.Owner).ToArray(); + Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction?.Name == this.Attacker).ToArray(); + + Faction ownerFaction = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).FirstOrDefault(); + Faction attackerFaction = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).FirstOrDefault(); + + if (ownerFaction == null || attackerFaction == null) + { + return; + } + if (getOwner() == FactionName) { - Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); - Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", ownerFaction); + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", attackerFaction); + foreach (var o in owners) { o.TriggerEvent("CLIENT:win"); @@ -254,15 +266,12 @@ namespace ReallifeGamemode.Server.Gangwar { a.TriggerEvent("CLIENT:loose"); } - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault()); - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).First().BankAccount.Balance += 15000; + ownerFaction.BankAccount.Balance += 15000; } else if (getOwner() != FactionName) { - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); - Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", ownerFaction); + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", attackerFaction); foreach (var o in owners) { if (o != null) @@ -274,11 +283,10 @@ namespace ReallifeGamemode.Server.Gangwar a.TriggerEvent("CLIENT:win"); } this.Owner = FactionName; - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).First().BankAccount.Balance += 10000; + attackerFaction.BankAccount.Balance += 10000; Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); turf.Owner = this.Owner; - turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id; + turf.FactionId = attackerFaction.Id; } dbContext.SaveChanges(); } From fa03a16f9aa75f106a9168edc5f9ea869de5a722 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 14:28:25 +0200 Subject: [PATCH 2/6] fix medic revive task --- ReallifeGamemode.Server/Events/Death.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index faeeb590..70d2424c 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -97,7 +97,7 @@ namespace ReallifeGamemode.Server.Events user.Dead = true; - if (!player.HasData("reviveSperre") || !player.HasData("inGangWar") || player.GetData("SAdminduty") == true) + if (!player.HasData("reviveSperre") && !player.HasData("inGangWar") && player.GetData("SAdminduty") == false) { //MEDIC AUFTRAG MedicTask reviveTask = new MedicTask() From 0cc7a7fc84eae57f7b3b049fea68b7311ea1a801 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 18:31:33 +0200 Subject: [PATCH 3/6] test voice --- ReallifeGamemode.Client/Gui/nametags.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index 7fee2fc4..298fe217 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -33,6 +33,13 @@ export default function customNametags() { const graphics = mp.game.graphics; const screenRes = graphics.getScreenResolution(0, 0); + var localPlayer: any = mp.players.local; + + var voiceActive = localPlayer.isVoiceActive; + var isTalking = localPlayer.isPlayerTalking; + + mp.gui.chat.push("voiceActive = " + voiceActive + ", isTalking =" + isTalking); + nametags.forEach(nametag => { let [player, x, y, distance] = nametag; From 6234646bd5699c7a0df0ea02c5519649180b520e Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 18:34:49 +0200 Subject: [PATCH 4/6] voice test --- ReallifeGamemode.Client/Gui/nametags.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index 298fe217..269ed99a 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -35,14 +35,16 @@ export default function customNametags() { var localPlayer: any = mp.players.local; - var voiceActive = localPlayer.isVoiceActive; - var isTalking = localPlayer.isPlayerTalking; - - mp.gui.chat.push("voiceActive = " + voiceActive + ", isTalking =" + isTalking); - nametags.forEach(nametag => { let [player, x, y, distance] = nametag; + + + var voiceActive = player.isVoiceActive; + var isTalking = player.isPlayerTalking; + + mp.gui.chat.push("name = " + player.name + ", voiceActive = " + voiceActive + ", isTalking =" + isTalking); + if (distance <= maxDistance) { let scale = distance / maxDistance; if (scale < 0.6) scale = 0.6; From 477f46b2ff987951db8b738f2470edda05f9d44e Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 18:38:25 +0200 Subject: [PATCH 5/6] remove voice debug --- ReallifeGamemode.Client/Gui/nametags.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index 269ed99a..7fee2fc4 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -33,18 +33,9 @@ export default function customNametags() { const graphics = mp.game.graphics; const screenRes = graphics.getScreenResolution(0, 0); - var localPlayer: any = mp.players.local; - nametags.forEach(nametag => { let [player, x, y, distance] = nametag; - - - var voiceActive = player.isVoiceActive; - var isTalking = player.isPlayerTalking; - - mp.gui.chat.push("name = " + player.name + ", voiceActive = " + voiceActive + ", isTalking =" + isTalking); - if (distance <= maxDistance) { let scale = distance / maxDistance; if (scale < 0.6) scale = 0.6; From 95f412589ecfd4449dc91002184294abe307e7cc Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 10 Apr 2021 18:40:15 +0200 Subject: [PATCH 6/6] haus blips kleiner test --- ReallifeGamemode.Server.Core/Managers/HouseManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs index f20fc600..aaf43688 100644 --- a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs +++ b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs @@ -67,7 +67,7 @@ namespace ReallifeGamemode.Server.Core.Managers else { //houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips - houseBlips[house.Id] = Api.Blip.CreateBlip(40, house.Position, "Haus", 11, 0.7f, shortRange: true); + houseBlips[house.Id] = Api.Blip.CreateBlip(40, house.Position, "Haus", 11, 0.5f, shortRange: true); } houseLabels[house.Id] = Api.TextLabel.CreateTextLabel(text, housePos, 10f, 1f, 0, new Color(255, 255, 255));