diff --git a/ReallifeGamemode.Client/Gui/licenses.ts b/ReallifeGamemode.Client/Gui/licenses.ts
new file mode 100644
index 00000000..b977d8c9
--- /dev/null
+++ b/ReallifeGamemode.Client/Gui/licenses.ts
@@ -0,0 +1,34 @@
+import { isNull } from "util";
+
+
+export default function licenses(globalData: GlobalData): void {
+
+ var licenseBrowser: BrowserMp = null;
+ var licenseTimer;
+ var globalName;
+ var globalInfo;
+
+ mp.events.add("ShowLicenses", (name, info) => {
+ if (licenseBrowser == null) {
+ licenseBrowser = mp.browsers.new('package://assets/html/licenses/scheine.html');
+ globalName = name;
+ globalInfo = info;
+
+ }
+ });
+
+ mp.events.add("CEF:LicenseLoaded", () => {
+ licenseBrowser.execute(`add_licenses('${JSON.stringify(globalInfo)}');`);
+ licenseBrowser.execute(`add_licensesholder('${JSON.stringify(globalName)}');`);
+ licenseTimer = setInterval(DestroyLicenses, 7000);
+ });
+
+
+ function DestroyLicenses() {
+ licenseBrowser.destroy()
+ licenseBrowser = null;
+ clearInterval(licenseTimer);
+ mp.events.callRemote("CLIENT:InteractionMenu_EndShow");
+ }
+
+}
\ No newline at end of file
diff --git a/ReallifeGamemode.Client/Gui/playerlist.ts b/ReallifeGamemode.Client/Gui/playerlist.ts
index 99293c0c..82673a71 100644
--- a/ReallifeGamemode.Client/Gui/playerlist.ts
+++ b/ReallifeGamemode.Client/Gui/playerlist.ts
@@ -4,16 +4,15 @@
* @copyright (c) 2008 - 2018 Life of German
*/
-export default function playerList(globalData: GlobalData) {
+export default function playerList(globalData: GlobalData): void {
var playerlistBrowser: BrowserMp = null;
var pList;
mp.events.add("showPlayerlist", (playersJson) => {
+ if (!globalData.InMenu) {
+ if (playerlistBrowser === null) {
- if (playerlistBrowser == null) {
- if (!globalData.InMenu) {
- globalData.InMenu = true;
playerlistBrowser = mp.browsers.new('package://assets/html/Playerlist/Tabliste.html');
mp.gui.chat.activate(false);
mp.gui.cursor.show(true, true);
@@ -21,15 +20,14 @@ export default function playerList(globalData: GlobalData) {
pList.forEach((player) => {
playerlistBrowser.execute(`ad_row('${JSON.stringify(player.Id)}','${JSON.stringify(player.Name)}',0,0,'${JSON.stringify(player.Ping)}');`);
});
- }
- } else {
- playerlistBrowser.destroy();
- playerlistBrowser = null;
- mp.gui.chat.activate(true);
- mp.gui.cursor.show(false, false);
- globalData.InMenu = false;
- }
+ } else {
+ playerlistBrowser.destroy()
+ playerlistBrowser = null;
+ mp.gui.cursor.show(false, false);
+ mp.gui.chat.activate(true);
+ }
+ }
});
mp.events.add("CEF:fetchPlayerList", () => {
diff --git a/ReallifeGamemode.Client/Interaction/interactionmenu.ts b/ReallifeGamemode.Client/Interaction/interactionmenu.ts
index 68ef8de9..1f1643cc 100644
--- a/ReallifeGamemode.Client/Interaction/interactionmenu.ts
+++ b/ReallifeGamemode.Client/Interaction/interactionmenu.ts
@@ -22,10 +22,13 @@ export default function (globalData: GlobalData) {
var serviceItem = new UIMenuItem("Service rufen", "Rufe einen Dienstleister an");
var factionItem = new UIMenuItem("Fraktion", "Verwalte deine Fraktion");
+
var groupItem = new UIMenuItem("Gruppe", "Verwalte deine Gruppe");
var paycheckItem = new UIMenuItem("Gehaltsscheck", "Schaue dir deinen Verdienst der letzten Stunde an");
+ var licenseItem = new UIMenuItem("Lizensen", "Lizensen Informationen");
+
mp.events.add("SERVER:InteractionMenu_OpenMenu", (accountDataJson: string, faction: string, group: string, factionInvite: boolean, groupInvite: boolean) => {
var accountData: AccountData = JSON.parse(accountDataJson);
@@ -39,6 +42,9 @@ export default function (globalData: GlobalData) {
menu.AddItem(accountItem);
menu.BindMenuToItem(getAccountMenu(accountData), accountItem);
+ menu.AddItem(licenseItem);
+ menu.BindMenuToItem(getLicenseMenu(accountData.licenses, menu), licenseItem);
+
if (faction) {
factionItem.SetRightLabel(faction);
menu.AddItem(factionItem);
@@ -148,6 +154,52 @@ export default function (globalData: GlobalData) {
return accountMenu;
}
+ function getLicenseMenu(data: Licenses, parentMenu: NativeUI.Menu): NativeUI.Menu {
+ var licenseMenu = new NativeUI.Menu("Lizensen", mp.players.local.name, new Point(50, 50), null, null);
+
+ var menuItem = new UIMenuItem("Auto Führerschein");
+ if (data.drivingLicenseCar == false) {
+ menuItem.SetRightLabel("~r~nicht erhalten");
+ } else if (data.drivingLicenseCar == true) {
+ menuItem.SetRightLabel("~g~erhalten");
+ }
+ licenseMenu.AddItem(menuItem);
+
+ menuItem = new UIMenuItem("Motorrad Führerschein");
+ if (data.drivingLicenseBike == false) {
+ menuItem.SetRightLabel("~r~nicht erhalten");
+ } else if (data.drivingLicenseBike == true) {
+ menuItem.SetRightLabel("~g~erhalten");
+ }
+ licenseMenu.AddItem(menuItem);
+
+ menuItem = new UIMenuItem("Flugschein Flugzeug");
+ if (data.flightLicensePlane == false) {
+ menuItem.SetRightLabel("~r~nicht erhalten");
+ } else if (data.flightLicensePlane == true) {
+ menuItem.SetRightLabel("~g~erhalten");
+ }
+ licenseMenu.AddItem(menuItem);
+
+ licenseMenu.AddItem(new UIMenuItem("Lizensen an Spieler zeigen"));
+
+ licenseMenu.Visible = false;
+
+ licenseMenu.ItemSelect.on((item, index) => {
+ if (index === 3) {
+ var input = new InputHelper("Welchen Spieler möchtest du deine Lizensen zeigen (Name / ID)?", globalData);
+ input.show();
+ input.getValue(name => {
+ mp.events.callRemote("CLIENT:InteractionMenu_Show", "License", name);
+ parentMenu.Close();
+ });
+ }
+
+ });
+
+ return licenseMenu;
+ }
+
function getFactionMenu(faction: string, parentMenu: NativeUI.Menu): NativeUI.Menu {
var factionMenu = new NativeUI.Menu("Fraktion", faction, new Point(50, 50), null, null);
factionMenu.AddItem(new UIMenuItem("Spieler einladen"));
@@ -217,4 +269,5 @@ export default function (globalData: GlobalData) {
return servicesMenu;
}
-}
\ No newline at end of file
+
+}
diff --git a/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj b/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj
index 514e3f56..e9b302cb 100644
--- a/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj
+++ b/ReallifeGamemode.Client/ReallifeGamemode.Client.csproj
@@ -31,7 +31,7 @@
+
+ " + name + "
"); + +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/global.d.ts b/ReallifeGamemode.Client/global.d.ts index fe4c05c1..e50d8282 100644 --- a/ReallifeGamemode.Client/global.d.ts +++ b/ReallifeGamemode.Client/global.d.ts @@ -16,6 +16,7 @@ declare interface AccountData { groupRank: string; job: string; paycheck: Paycheck; + licenses: Licenses; } declare interface Paycheck { @@ -28,6 +29,12 @@ declare interface Paycheck { rentalFees: number; } +declare interface Licenses { + drivingLicenseCar: boolean; + drivingLicenseBike: boolean; + flightLicensePlane: boolean; +} + declare interface FactionRanks { factionId: number, ranks: FactionRank[] diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index 1fadef44..a88cf8da 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -82,7 +82,8 @@ Infobox(globalData); import playerList from './Gui/playerlist'; playerList(globalData); - +import license from './Gui/licenses'; +license(globalData); import vehicleMenu from './Gui/vehiclemenu/main'; vehicleMenu(globalData); diff --git a/ReallifeGamemode.Client/inventory/inventory.ts b/ReallifeGamemode.Client/inventory/inventory.ts index 401eea64..76885be6 100644 --- a/ReallifeGamemode.Client/inventory/inventory.ts +++ b/ReallifeGamemode.Client/inventory/inventory.ts @@ -24,7 +24,17 @@ export default function inventory(globalData: GlobalData): void { mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => { if (!globalData.InMenu) { - if (invBrowser !== null) { + if (invBrowser === null) { + + mp.gui.cursor.show(true, true); + + Players = playersArr; + itemIdArr = iIdArr; + itemAmountArr = iAmountArr; + itemNameArr = iNameArr; + invWeight = iWeight; + } else { + try { invBrowser.destroy() invBrowser = null; @@ -33,16 +43,8 @@ export default function inventory(globalData: GlobalData): void { mp.gui.cursor.show(false, false); } return; + } - - mp.gui.cursor.show(true, true); - - Players = playersArr; - itemIdArr = iIdArr; - itemAmountArr = iAmountArr; - itemNameArr = iNameArr; - invWeight = iWeight; - invBrowser = mp.browsers.new("package://assets/html/inventory/inventory.html"); } }); var offer = 0; diff --git a/ReallifeGamemode.Server/DrivingSchool/Licenses.cs b/ReallifeGamemode.Server/DrivingSchool/Licenses.cs new file mode 100644 index 00000000..93745523 --- /dev/null +++ b/ReallifeGamemode.Server/DrivingSchool/Licenses.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ReallifeGamemode.Server.DrivingSchool +{ + public class Licenses + { + [JsonProperty("drivingLicenseCar")] + public bool CarLicense { get; set; } + + [JsonProperty("drivingLicenseBike")] + public bool BikeLicense { get; set; } + + [JsonProperty("flightLicensePlane")] + public bool PlaneLicense { get; set; } + + + public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense) + { + this.CarLicense = CarLicense; + this.BikeLicense = BikeLicense; + this.PlaneLicense = PlaneLicense; + } + + } +} diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index e737e9ac..4cf208a3 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -14,6 +14,7 @@ using ReallifeGamemode.Database; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Inventory.Interfaces; +using ReallifeGamemode.Server.DrivingSchool; /** * @overview Life of German Reallife - Event Key (Key.cs) * @author VegaZ @@ -111,6 +112,8 @@ namespace ReallifeGamemode.Server.Events Paycheck paycheck = null; if (Economy.Paychecks.ContainsKey(u.Id)) paycheck = Economy.Paychecks[u.Id]; + Licenses licenses = new Licenses(u.DriverLicenseVehicle, u.DriverLicenseBike, u.FlyingLicensePlane); + var accountData = new { regDate = u.RegistrationDate.ToShortDateString(), @@ -120,7 +123,8 @@ namespace ReallifeGamemode.Server.Events group = u.Group?.Name ?? "Keine", groupRank = u.GroupRank.GetName(), job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner", - paycheck + paycheck, + licenses }; string faction = u.FactionLeader ? u.Faction.Name : null; diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 9b52bfc2..977cebf8 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -99,6 +99,54 @@ namespace ReallifeGamemode.Server.Managers } } } + [RemoteEvent("CLIENT:InteractionMenu_EndShow")] + public void InteractionMenuEndShow(Client client) + { + client.ResetData("ShowActive"); + } + + [RemoteEvent("CLIENT:InteractionMenu_Show")] + public void InteractionMenuShow(Client player, string type, string nameOrId) + { + if (type != "License") + return; + + Client target = ClientService.GetClientByNameOrId(nameOrId); + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + User targetUser = target.GetUser(); + User playerUser = player.GetUser(); + + if (type == "License") + { + if (!playerUser.DriverLicenseBike && !playerUser.DriverLicenseVehicle && !playerUser.FlyingLicensePlane) + { + ChatService.ErrorMessage(player, "Sie besitzen keine Scheine"); + return; + } + if (player.Position.DistanceTo(target.Position) > 5) + { + ChatService.ErrorMessage(player, "Spieler zu weit entfernt"); + return; + } + if (target.HasData("ShowActive")) + { + ChatService.ErrorMessage(player, "Spieler ist beschäftigt"); + return; + } + target.SetData("ShowActive", true); + List