From 18e385717b4b2995a39f3d9e6516266e50b7a683 Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 13 Apr 2021 21:34:14 +0200 Subject: [PATCH] look basis --- .../Gui/vehiclemenu/main.ts | 32 +++++++++ .../assets/html/vehiclemenu/lastPlayers.html | 33 +++++++++ .../assets/html/vehiclemenu/script.js | 16 +++++ .../assets/html/vehiclemenu/style.css | 67 +++++++++++++++++++ .../assets/vehicle/application.js | 7 ++ .../assets/vehicle/lastPlayers.html | 32 +++++++++ .../assets/vehicle/style.css | 67 +++++++++++++++++++ .../Commands/UserCommands.cs | 16 +++++ .../Events/EnterVehicle.cs | 8 +++ .../Managers/VehicleManager.cs | 3 + 10 files changed, 281 insertions(+) create mode 100644 ReallifeGamemode.Client/assets/html/vehiclemenu/lastPlayers.html create mode 100644 ReallifeGamemode.Client/assets/html/vehiclemenu/script.js create mode 100644 ReallifeGamemode.Client/assets/html/vehiclemenu/style.css create mode 100644 ReallifeGamemode.Client/assets/vehicle/application.js create mode 100644 ReallifeGamemode.Client/assets/vehicle/lastPlayers.html create mode 100644 ReallifeGamemode.Client/assets/vehicle/style.css diff --git a/ReallifeGamemode.Client/Gui/vehiclemenu/main.ts b/ReallifeGamemode.Client/Gui/vehiclemenu/main.ts index d5988b50..94cbf2eb 100644 --- a/ReallifeGamemode.Client/Gui/vehiclemenu/main.ts +++ b/ReallifeGamemode.Client/Gui/vehiclemenu/main.ts @@ -9,6 +9,38 @@ var screenRes = mp.game.graphics.getScreenResolution(0, 0); export default function vehicleMenu(globalData: IGlobalData) { let menuBrowser: BrowserMp = null; + var lastDriversBrowser: BrowserMp = null; + + mp.events.add('lookLastDrivers', (lastDriversParam) => { + var lastDrivers = JSON.parse(lastDriversParam); + + if (lastDriversBrowser !== null) { + lastDriversBrowser.destroy(); + lastDriversBrowser = null; + globalData.InMenu = false; + mp.gui.cursor.show(false, false); + mp.gui.chat.activate(true); + } + else if (!globalData.InMenu) { + globalData.InMenu = true; + lastDriversBrowser = mp.browsers.new('package://assets/vehicle/lastPlayers.html'); + mp.gui.chat.activate(false); + mp.gui.cursor.show(true, true); + } + }); + + mp.events.add("removeLookMenu", () => { + if (lastDriversBrowser == null) { + return; + } + else if (globalData.InMenu) { + lastDriversBrowser.destroy(); + lastDriversBrowser = null; + globalData.InMenu = false; + mp.gui.cursor.show(false, false); + mp.gui.chat.activate(true); + } + }); mp.events.add('ToggleVehicleMenu', () => { if (menuBrowser !== null) { diff --git a/ReallifeGamemode.Client/assets/html/vehiclemenu/lastPlayers.html b/ReallifeGamemode.Client/assets/html/vehiclemenu/lastPlayers.html new file mode 100644 index 00000000..f407ae18 --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/vehiclemenu/lastPlayers.html @@ -0,0 +1,33 @@ + + + + + + Eingabe | Life of German + + + + + + + + +
+
+

Letze Fahrer

+
+
+ • Hier
+ • könnten
+ • Ihre
+ • letzen Fahrer
+ • stehen
+

+ Viel Erfolg bei der Prüfung! +
+ +
+ + + + \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/vehiclemenu/script.js b/ReallifeGamemode.Client/assets/html/vehiclemenu/script.js new file mode 100644 index 00000000..82dbf11f --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/vehiclemenu/script.js @@ -0,0 +1,16 @@ + + + +function ad_row(id, name, faction, ping) { + 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 td4 = document.createElement('td'); + var test = faction; + td1.innerHTML = ''+driver; + tr.appendChild(td1); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/vehiclemenu/style.css b/ReallifeGamemode.Client/assets/html/vehiclemenu/style.css new file mode 100644 index 00000000..aa5f9d4f --- /dev/null +++ b/ReallifeGamemode.Client/assets/html/vehiclemenu/style.css @@ -0,0 +1,67 @@ +/* style.css für Tabliste */ +.greyFont { + color: gray; + font-size: 14px; + width: 250px; +} +div { + user-select: none; +} + +body { + overflow: hidden; + font-family: 'Roboto', sans-serif; + font-weight: 500; + color: #222; + margin: 0; + padding: 0; +} + +h2 { + font-family: 'Roboto', sans-serif; + font-weight: 700; + font-size: 18px; + color: white; + margin:5px; + padding: 5px; + border: 1px solid #808080; + width: 20.75em; +} +.TabWrapper { + background: rgba(0,0,0,0.6); + height: 600px; + width: 600px; + display: block; + padding: 5px; + position: absolute; + left: 32%; + top: 10%; +} +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/vehicle/application.js b/ReallifeGamemode.Client/assets/vehicle/application.js new file mode 100644 index 00000000..591f41a6 --- /dev/null +++ b/ReallifeGamemode.Client/assets/vehicle/application.js @@ -0,0 +1,7 @@ + +let close = document.getElementById('close'); + +close.onclick = function closeWindow() { + mp.trigger('removeDrivingSchool'); + console.log('Fenster geschlossen!'); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/vehicle/lastPlayers.html b/ReallifeGamemode.Client/assets/vehicle/lastPlayers.html new file mode 100644 index 00000000..2a0cff96 --- /dev/null +++ b/ReallifeGamemode.Client/assets/vehicle/lastPlayers.html @@ -0,0 +1,32 @@ + + + + + + Eingabe | Life of German + + + + + + + + +
+
+

Letze Fahrer

+
+
+ • Hier
+ • könnten
+ • Ihre
+ • letzen Fahrer
+ • stehen
+

+
+ +
+ + + + \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/vehicle/style.css b/ReallifeGamemode.Client/assets/vehicle/style.css new file mode 100644 index 00000000..aa5f9d4f --- /dev/null +++ b/ReallifeGamemode.Client/assets/vehicle/style.css @@ -0,0 +1,67 @@ +/* style.css für Tabliste */ +.greyFont { + color: gray; + font-size: 14px; + width: 250px; +} +div { + user-select: none; +} + +body { + overflow: hidden; + font-family: 'Roboto', sans-serif; + font-weight: 500; + color: #222; + margin: 0; + padding: 0; +} + +h2 { + font-family: 'Roboto', sans-serif; + font-weight: 700; + font-size: 18px; + color: white; + margin:5px; + padding: 5px; + border: 1px solid #808080; + width: 20.75em; +} +.TabWrapper { + background: rgba(0,0,0,0.6); + height: 600px; + width: 600px; + display: block; + padding: 5px; + position: absolute; + left: 32%; + top: 10%; +} +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.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 3c2bf091..671cac74 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; +using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; @@ -16,6 +17,21 @@ namespace ReallifeGamemode.Server.Commands { internal class UserCommands : Script { + [Command("look", "~m~look")] + public void CmdUserLook(Player player) + { + if (!player.IsLoggedIn()) return; + + Vehicle veh = NAPI.Pools.GetAllVehicles().Where(v => v.Position.DistanceTo(player.Position) <= 5).FirstOrDefault(); + + if (veh == null) + { + return; + } + + player.TriggerEvent("lookLastDrivers", JsonConvert.SerializeObject(VehicleManager.lastDriversInVehicle[veh])); + } + [Command("id", "~m~Benutzung: ~s~/id [Name]")] public void CmdUserId(Player player, String targetname) { diff --git a/ReallifeGamemode.Server/Events/EnterVehicle.cs b/ReallifeGamemode.Server/Events/EnterVehicle.cs index e6bce887..611948bd 100644 --- a/ReallifeGamemode.Server/Events/EnterVehicle.cs +++ b/ReallifeGamemode.Server/Events/EnterVehicle.cs @@ -2,6 +2,7 @@ using GTANetworkAPI; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.WeaponDeal; @@ -20,6 +21,13 @@ namespace ReallifeGamemode.Server.Events if (vehicle.HasMarkerBehind()) vehicle.RemoveMarkerBehind(); + if (!VehicleManager.lastDriversInVehicle.ContainsKey(vehicle)) + { + VehicleManager.lastDriversInVehicle.Add(vehicle, new List()); + } + + VehicleManager.lastDriversInVehicle[vehicle].Add(client.Name); + if (vehicle.GetServerVehicle() is FactionVehicle veh) { User u = client.GetUser(); diff --git a/ReallifeGamemode.Server/Managers/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index ffa29c54..034eb9cf 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -18,6 +18,9 @@ namespace ReallifeGamemode.Server.Managers { public class VehicleManager : Script { + + public static Dictionary> lastDriversInVehicle = new Dictionary>(); + private static readonly List _enabledMods = new List() { "ninef",