From dfc9be29c6d7f83e7f82b67dd7acb00c7112446e Mon Sep 17 00:00:00 2001 From: CroniX Date: Sat, 23 Jan 2021 17:06:09 +0100 Subject: [PATCH] Fix online list show faction --- ReallifeGamemode.Client/Gui/playerlist.ts | 4 ++-- ReallifeGamemode.Server/Events/Key.cs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/playerlist.ts b/ReallifeGamemode.Client/Gui/playerlist.ts index 8ed01339..454b0df0 100644 --- a/ReallifeGamemode.Client/Gui/playerlist.ts +++ b/ReallifeGamemode.Client/Gui/playerlist.ts @@ -9,7 +9,7 @@ export default function playerList(globalData: IGlobalData): void { var playerlistBrowser: BrowserMp = null; var pList; - mp.events.add("showPlayerlist", (playersJson, factionname) => { + mp.events.add("showPlayerlist", (playersJson) => { if (playerlistBrowser !== null) { playerlistBrowser.destroy(); @@ -25,7 +25,7 @@ export default function playerList(globalData: IGlobalData): void { mp.gui.cursor.show(true, true); pList = JSON.parse(playersJson); pList.forEach((player) => { - playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',${JSON.stringify(factionname)},'${JSON.stringify(player.Ping)}');`); + playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',${JSON.stringify(player.FactionName)},'${JSON.stringify(player.Ping)}');`); }); } }); diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 4e812795..7d67e9ac 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -609,16 +609,17 @@ namespace ReallifeGamemode.Server.Events if (!player.IsLoggedIn()) return; using (var dbContext = new DatabaseContext()) { - string factionname = player.GetUser(dbContext).Faction.Name; + string FactionName; List players = NAPI.Pools.GetAllPlayers(); - var listPlayers = players.Select(p => new - { - Id = p.Handle.Value, - p.Name, - p.Ping, - }) ; - player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers), JsonConvert.SerializeObject(factionname)); + var listPlayers = players.Select(p => new + { + Id = p.Handle.Value, + p.Name, + p.Ping, + FactionName = p.GetUser().Faction.Name, + }) ; + player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers)); } }