From 9b5fcffdf63fee592a3e23c80a48687227a1ff7c Mon Sep 17 00:00:00 2001 From: CroniX Date: Thu, 21 Jan 2021 19:37:32 +0100 Subject: [PATCH] Onlinelist add faction remove level --- ReallifeGamemode.Client/Gui/playerlist.ts | 4 ++-- .../assets/html/Playerlist/Tabliste.html | 1 - .../assets/html/Playerlist/script.js | 12 ++++-------- ReallifeGamemode.Server/Events/Key.cs | 11 ++++++++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/playerlist.ts b/ReallifeGamemode.Client/Gui/playerlist.ts index a674b624..8ed01339 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) => { + mp.events.add("showPlayerlist", (playersJson, factionname) => { 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)}',0,0,'${JSON.stringify(player.Ping)}');`); + playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',${JSON.stringify(factionname)},'${JSON.stringify(player.Ping)}');`); }); } }); diff --git a/ReallifeGamemode.Client/assets/html/Playerlist/Tabliste.html b/ReallifeGamemode.Client/assets/html/Playerlist/Tabliste.html index 33d0bb9b..764b197a 100644 --- a/ReallifeGamemode.Client/assets/html/Playerlist/Tabliste.html +++ b/ReallifeGamemode.Client/assets/html/Playerlist/Tabliste.html @@ -16,7 +16,6 @@ ID Spielername - Level Fraktion Ping diff --git a/ReallifeGamemode.Client/assets/html/Playerlist/script.js b/ReallifeGamemode.Client/assets/html/Playerlist/script.js index 5cd805e7..2a0e2c30 100644 --- a/ReallifeGamemode.Client/assets/html/Playerlist/script.js +++ b/ReallifeGamemode.Client/assets/html/Playerlist/script.js @@ -1,7 +1,7 @@ -function ad_row(id, name, level, faction, ping) { +function ad_row(id, name, faction, ping) { var table_id = "t1"; var table = document.getElementById(table_id); var rows = table.getElementsByTagName('tr').length; @@ -10,17 +10,13 @@ function ad_row(id, name, level, faction, ping) { var td2 = document.createElement('td'); var td3 = document.createElement('td'); var td4 = document.createElement('td'); - var td5 = document.createElement('td'); - var test = level; - var test2 = faction; + var test = faction; td1.innerHTML = ''+id; td2.innerHTML = name.slice(1, -1); - td3.innerHTML = 'WIP'; - td4.innerHTML = 'WIP'; - td5.innerHTML = ''+ping; + td3.innerHTML = ''+faction; + td4.innerHTML = ''+ping; tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); tr.appendChild(td4); - tr.appendChild(td5); } \ No newline at end of file diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index c3905a01..4e812795 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -604,17 +604,22 @@ namespace ReallifeGamemode.Server.Events } [RemoteEvent("keyPress:O")] - public void KeyPressJ(Player player) + public void KeyPressO(Player player) { if (!player.IsLoggedIn()) return; + using (var dbContext = new DatabaseContext()) + { + string factionname = player.GetUser(dbContext).Faction.Name; + 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)); + }) ; + player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers), JsonConvert.SerializeObject(factionname)); + } } [RemoteEvent("keyPress:K")]