[+] Add Driving License to Interaction Menu and as 'Object' to show other Players via the Interaction menu
This commit is contained in:
34
ReallifeGamemode.Client/Gui/licenses.ts
Normal file
34
ReallifeGamemode.Client/Gui/licenses.ts
Normal file
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="rage-sharp" >
|
||||
<Reference Include="rage-sharp">
|
||||
<HintPath>..\Import\rage-sharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
35
ReallifeGamemode.Client/assets/css/licenses/schein.css
Normal file
35
ReallifeGamemode.Client/assets/css/licenses/schein.css
Normal file
@@ -0,0 +1,35 @@
|
||||
html, body {
|
||||
overflow: hidden;
|
||||
}
|
||||
#schein {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
animation: 1s ease-out 0s 1 slideInFromLeft;
|
||||
}
|
||||
|
||||
#erworbene {
|
||||
overflow: hidden;
|
||||
Position: absolute;
|
||||
right: 15%;
|
||||
top: 46%;
|
||||
}
|
||||
|
||||
#name {
|
||||
overflow: hidden;
|
||||
Position: absolute;
|
||||
left: 40%;
|
||||
top: 24.4%;
|
||||
}
|
||||
|
||||
|
||||
@keyframes slideInFromLeft {
|
||||
0% {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
26
ReallifeGamemode.Client/assets/html/licenses/scheine.html
Normal file
26
ReallifeGamemode.Client/assets/html/licenses/scheine.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<link rel="stylesheet" href="package://assets/css/licenses/schein.css">
|
||||
</head>
|
||||
<body scroll="no">
|
||||
<div id="schein">
|
||||
|
||||
<img src="package://assets/img/licenses/schein.png">
|
||||
|
||||
<div id="name">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="erworbene">
|
||||
<p id="0"></p>
|
||||
<p id="1"></p>
|
||||
<p id="2"></p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
||||
<script src="package://assets/js/licenses/scheine.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
ReallifeGamemode.Client/assets/img/licenses/schein.png
Normal file
BIN
ReallifeGamemode.Client/assets/img/licenses/schein.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
34
ReallifeGamemode.Client/assets/js/licenses/scheine.js
Normal file
34
ReallifeGamemode.Client/assets/js/licenses/scheine.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
mp.trigger('CEF:LicenseLoaded');
|
||||
});
|
||||
|
||||
|
||||
|
||||
function add_licenses(info) {
|
||||
infoArr = JSON.parse(info);
|
||||
console.log(infoArr);
|
||||
for (var i = 0; i < infoArr.length; i++) {
|
||||
var Schein = "";
|
||||
if (infoArr[i] == true) {
|
||||
if (i == 0) {
|
||||
Schein = "Auto";
|
||||
} else if (i == 1) {
|
||||
Schein = "Motorrad";
|
||||
} else if (i == 2) {
|
||||
Schein = "Flugzeug";
|
||||
}
|
||||
}
|
||||
$('#'+i).append(""+Schein);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function add_licensesholder(info) {
|
||||
name = JSON.parse(info);
|
||||
|
||||
$('#name').append("<p>" + name + "</p>");
|
||||
|
||||
}
|
||||
7
ReallifeGamemode.Client/global.d.ts
vendored
7
ReallifeGamemode.Client/global.d.ts
vendored
@@ -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[]
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
28
ReallifeGamemode.Server/DrivingSchool/Licenses.cs
Normal file
28
ReallifeGamemode.Server/DrivingSchool/Licenses.cs
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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<bool> licenses = new List<bool>();
|
||||
licenses.Add(playerUser.DriverLicenseVehicle);
|
||||
licenses.Add(playerUser.DriverLicenseBike);
|
||||
licenses.Add(playerUser.FlyingLicensePlane);
|
||||
target.TriggerEvent("ShowLicenses", player.Name, licenses.ToArray());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Invite")]
|
||||
public void InteractionMenuInviteFaction(Client player, string type, string nameOrId)
|
||||
|
||||
Reference in New Issue
Block a user