From 88e7df88c2b879b7ef377263ae4348bee0908d0d Mon Sep 17 00:00:00 2001 From: "michael.reiswich" Date: Fri, 29 Jan 2021 19:54:48 +0100 Subject: [PATCH] =?UTF-8?q?add=20onlinewanteds=20in=20factionmen=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interaction/factioninteraction.ts | 52 ++++++++++++++++++- .../assets/html/Wantedlist/script.js | 19 +++++++ .../assets/html/Wantedlist/style.css | 36 +++++++++++++ .../assets/html/Wantedlist/wanteds.html | 38 ++++++++++++++ .../assets/js/wantedlist/application.js | 6 +++ .../Managers/InteractionManager.cs | 21 ++++++++ 6 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 ReallifeGamemode.Client/assets/html/Wantedlist/script.js create mode 100644 ReallifeGamemode.Client/assets/html/Wantedlist/style.css create mode 100644 ReallifeGamemode.Client/assets/html/Wantedlist/wanteds.html create mode 100644 ReallifeGamemode.Client/assets/js/wantedlist/application.js diff --git a/ReallifeGamemode.Client/Interaction/factioninteraction.ts b/ReallifeGamemode.Client/Interaction/factioninteraction.ts index dfa9ea32..ce529d9c 100644 --- a/ReallifeGamemode.Client/Interaction/factioninteraction.ts +++ b/ReallifeGamemode.Client/Interaction/factioninteraction.ts @@ -40,6 +40,7 @@ export default function factionInteraction(globalData: IGlobalData) { //LSPD let ticketTaskMenuLSPD; let pointsTaskMenuLSPD; + let wantedsMenuLSPD if (userFactionId == 1 || userFactionId == 3) { if (isDuty) { mp.gui.chat.activate(false); @@ -53,6 +54,9 @@ export default function factionInteraction(globalData: IGlobalData) { pointsTaskMenuLSPD = new UIMenuItem("Strafpunkte verteilen", "Einem Spieler Strafpunkte verteilen."); factionInteractionMenu.AddItem(pointsTaskMenuLSPD); + wantedsMenuLSPD = new UIMenuItem("Verbrecher Liste"); + factionInteractionMenu.AddItem(wantedsMenuLSPD); + /*TaskMenuLSPD = new UIMenuItem(""); TaskMenuLSPD.SetRightLabel(""); factionInteractionMenu.AddItem(TaskMenuLSPD);*/ //weiteres @@ -100,6 +104,12 @@ export default function factionInteraction(globalData: IGlobalData) { mp.events.call("CLIENT:InteractionMenu_LSPD_Points", name); globalData.InInput = false; }); + break + case wantedsMenuLSPD: + factionInteractionMenu.Visible = false; + mp.gui.chat.activate(true); + globalData.InMenu = false; + mp.events.callRemote("CLIENT:wantedlist"); break; } }); @@ -159,11 +169,51 @@ export default function factionInteraction(globalData: IGlobalData) { }); }); + var wantedlistBrowser: BrowserMp = null; + var wList; + + mp.events.add("showWantedlist", (playersJson) => { + + if (wantedlistBrowser !== null) { + wantedlistBrowser.destroy(); + wantedlistBrowser = null; + globalData.InInput = false; + mp.gui.cursor.show(false, false); + mp.gui.chat.activate(true); + } + else if (!globalData.InInput) { + globalData.InInput = true; + wantedlistBrowser = mp.browsers.new('package://assets/html/Wantedlist/wanteds.html'); + mp.gui.chat.activate(false); + mp.gui.cursor.show(true, true); + wList = JSON.parse(playersJson); + wList.forEach((player) => { + wantedlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}','${JSON.stringify(player.wanted)}');`); + }); + } + }); + + mp.events.add("removeWantedlist", () => { + + if (wantedlistBrowser == null) { + return; + } + else if (globalData.InInput) { + wantedlistBrowser.destroy(); + wantedlistBrowser = null; + globalData.InInput = false; + mp.gui.cursor.show(false, false); + mp.gui.chat.activate(true); + } + }); + + //Medic + mp.events.add("showFactionInteractionMedic", (userFactionId, isDuty, userFactionName, isFactionLeader, reviveTaskCountMedic, healTaskCountMedic, fireTaskCountMedic) => { mp.gui.chat.activate(false); globalData.InMenu = true; - //Medic + var rPM = ((reviveTaskCountMedic === "0") ? "~r~" : "~g~"); var hPM = ((healTaskCountMedic === "0") ? "~r~" : "~g~"); var fPM = ((fireTaskCountMedic === "0") ? "~r~" : "~g~"); diff --git a/ReallifeGamemode.Client/assets/html/Wantedlist/script.js b/ReallifeGamemode.Client/assets/html/Wantedlist/script.js new file mode 100644 index 00000000..d8aaf2b0 --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/Wantedlist/script.js @@ -0,0 +1,19 @@ + + + +function ad_row(id, name, wanteds) { + var table_id = "t1"; + var table = document.getElementById(table_id); + var rows = table.getElementsByTagName('tr').length; + var tr = table.insertRow(rows); + var td1 = document.createElement('td'); + var td2 = document.createElement('td'); + var td3 = document.createElement('td'); + var test = wanteds; + td1.innerHTML = ''+id; + td2.innerHTML = name.slice(1, -1); + td3.innerHTML = '' +wanteds; + tr.appendChild(td1); + tr.appendChild(td2); + tr.appendChild(td3); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/Wantedlist/style.css b/ReallifeGamemode.Client/assets/html/Wantedlist/style.css new file mode 100644 index 00000000..1fc57735 --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/Wantedlist/style.css @@ -0,0 +1,36 @@ +/* style.css für Tabliste */ +div { + user-select: none; +} + + + + +th, td { + color: white; + font-size: 18px; + width:10%; + text-align: left; +} +.scroll { + height: 600px; + width: 600px; + font-size: 12px; + overflow: auto; +} +.force-overflow { + min-height: 600px; +} + +#style1::-webkit-scrollbar { + width: 10px; + background-color: #F5F5F5; +} + +#style1::-webkit-scrollbar-thumb { + background-color: #FF0040; +} + + + + diff --git a/ReallifeGamemode.Client/assets/html/Wantedlist/wanteds.html b/ReallifeGamemode.Client/assets/html/Wantedlist/wanteds.html new file mode 100644 index 00000000..a5163765 --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/Wantedlist/wanteds.html @@ -0,0 +1,38 @@ + + + + + + Eingabe | Life of German + + + + + + + + + + +
+
+ +
+
+ + + + + + + +
IDSpielernameWantedanzahl
+
+ + +
+ + + + + \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/js/wantedlist/application.js b/ReallifeGamemode.Client/assets/js/wantedlist/application.js new file mode 100644 index 00000000..94405512 --- /dev/null +++ b/ReallifeGamemode.Client/assets/js/wantedlist/application.js @@ -0,0 +1,6 @@ +let close = document.getElementById('close'); + +close.onclick = function closeWindow() { + mp.trigger('removeWantedlist'); + console.log('Fenster geschlossen!'); +} diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 1046a4dd..de06111a 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -672,6 +672,27 @@ namespace ReallifeGamemode.Server.Managers } } + [RemoteEvent("CLIENT:wantedlist")] + public void wantedlist(Player player) + { + if (!player.IsLoggedIn()) return; + List players = NAPI.Pools.GetAllPlayers(); + if (player.GetUser().Wanteds > 0) + { + var listPlayers = players.Select(p => new + { + Id = p.Handle.Value, + p.Name, + wanted = p.GetUser().Wanteds, + }) ; + player.TriggerEvent("showWantedlist", JsonConvert.SerializeObject(listPlayers)); + } + else + { + player.SendNotification("~r~[Fehler] ~w~Es gibt derzeitig keine Verbrecher!"); + } + } + [RemoteEvent("CLIENT:InteractionMenu_FindHouse")] public void InteractionMenu_House(Player player) {