Add Paycheck to interaction menu
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
import InputHelper from '../inputhelper';
|
||||
import moneyFormat from '../moneyformat';
|
||||
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
@@ -23,6 +24,8 @@ export default function (globalData: GlobalData) {
|
||||
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");
|
||||
|
||||
|
||||
mp.events.add("SERVER:InteractionMenu_OpenMenu", (accountDataJson: string, faction: string, group: string, factionInvite: boolean, groupInvite: boolean) => {
|
||||
var accountData: AccountData = JSON.parse(accountDataJson);
|
||||
@@ -48,6 +51,39 @@ export default function (globalData: GlobalData) {
|
||||
menu.BindMenuToItem(getGroupMenu(group, menu), groupItem);
|
||||
}
|
||||
|
||||
if (accountData.paycheck) {
|
||||
var p = accountData.paycheck;
|
||||
var paycheckMenu = new Menu("Gehaltsscheck", "Dein Verdienst der letzten Stunde", new Point(50, 50), null, null);
|
||||
paycheckMenu.Visible = false;
|
||||
|
||||
var item: NativeUI.UIMenuItem = new UIMenuItem("Lohn");
|
||||
item.SetRightLabel("~g~+ $" + moneyFormat(p.wage));
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
item = new UIMenuItem("Finanzhilfe");
|
||||
item.SetRightLabel("~g~+ $" + moneyFormat(p.financialHelp));
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
item = new UIMenuItem("Fahrzeugsteuer");
|
||||
item.SetRightLabel("~r~- $" + moneyFormat(p.vehicleTaxation));
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
item = new UIMenuItem("Grundsteuer");
|
||||
item.SetRightLabel("~r~- $" + moneyFormat(p.propertyTaxation));
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
item = new UIMenuItem("Mietkosten");
|
||||
item.SetRightLabel("~r~- $" + moneyFormat(p.rentalFees));
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
item = new UIMenuItem("Einkommenssteuer");
|
||||
item.SetRightLabel((p.financialInterest * 100).toString() + "%");
|
||||
paycheckMenu.AddItem(item);
|
||||
|
||||
menu.AddItem(paycheckItem);
|
||||
menu.BindMenuToItem(paycheckMenu, paycheckItem);
|
||||
}
|
||||
|
||||
var items: Array<string> = new Array<string>();
|
||||
if (factionInvite) items.push("Fraktion");
|
||||
if (groupInvite) items.push("Gruppe");
|
||||
@@ -58,8 +94,7 @@ export default function (globalData: GlobalData) {
|
||||
menu.AddItem(acceptItem);
|
||||
}
|
||||
|
||||
menu.Visible = true;
|
||||
mp.gui.chat.show(false);
|
||||
menu.Open();
|
||||
globalData.InMenu = true;
|
||||
|
||||
menu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
|
||||
@@ -71,7 +106,6 @@ export default function (globalData: GlobalData) {
|
||||
|
||||
menu.MenuClose.on(() => {
|
||||
globalData.InMenu = false;
|
||||
mp.gui.chat.show(true);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
11
ReallifeGamemode.Client/global.d.ts
vendored
11
ReallifeGamemode.Client/global.d.ts
vendored
@@ -15,6 +15,17 @@ declare interface AccountData {
|
||||
group: string;
|
||||
groupRank: string;
|
||||
job: string;
|
||||
paycheck: Paycheck;
|
||||
}
|
||||
|
||||
declare interface Paycheck {
|
||||
financialHelp: number;
|
||||
financialInterest: number;
|
||||
vehicleTaxation: number;
|
||||
propertyTaxation: number;
|
||||
wage: number;
|
||||
amount: number;
|
||||
rentalFees: number;
|
||||
}
|
||||
|
||||
declare interface FactionRanks {
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
this.browser.destroy();
|
||||
this.data.InInput = false;
|
||||
this.created = false;
|
||||
this.browser = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +61,10 @@
|
||||
|
||||
private valueGetter(): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
setInterval(() => {
|
||||
if (this.value !== undefined) resolve(this.value);
|
||||
}, 50);
|
||||
while (this.value !== undefined) {
|
||||
mp.game.wait(1);
|
||||
}
|
||||
resolve(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Grundsteuer (Haus) : ~r~-$" + Economy.Paychecks[user.Id].PropertyTaxation);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Mietkosten : ~r~-$" + Economy.Paychecks[user.Id].RentalFees);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Einkommen Steuer : ~r~" + (int)(Economy.Paychecks[user.Id].FinancialInterest * 100) + " %");
|
||||
ChatService.SendMessage(client, "");
|
||||
ChatService.SendMessage(client, " ");
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Ausgaben : ~r~-$" + (Economy.Paychecks[user.Id].Wage - Economy.Paychecks[user.Id].Amount));
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Inventory;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
@@ -105,6 +106,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
Paycheck paycheck = null;
|
||||
if (Economy.Paychecks.ContainsKey(u.Id)) paycheck = Economy.Paychecks[u.Id];
|
||||
|
||||
var accountData = new
|
||||
{
|
||||
regDate = u.RegistrationDate.ToShortDateString(),
|
||||
@@ -113,7 +117,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
factionRank = u.GetFactionRank().RankName,
|
||||
group = u.Group?.Name ?? "Keine",
|
||||
groupRank = u.GroupRank.GetName(),
|
||||
job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner"
|
||||
job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner",
|
||||
paycheck
|
||||
};
|
||||
|
||||
string faction = u.FactionLeader ? u.Faction.Name : null;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
@@ -12,12 +13,25 @@ namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
public class Paycheck
|
||||
{
|
||||
[JsonProperty("financialHelp")]
|
||||
public float FinancialHelp { get; set; } = 0;
|
||||
|
||||
[JsonProperty("financialInterest")]
|
||||
public float FinancialInterest { get; set; } = 0;
|
||||
|
||||
[JsonProperty("vehicleTaxation")]
|
||||
public int VehicleTaxation { get; set; } = 0;
|
||||
|
||||
[JsonProperty("propertyTaxation")]
|
||||
public float PropertyTaxation { get; set; } = 0;
|
||||
|
||||
[JsonProperty("wage")]
|
||||
public int Wage { get; set; } = 0;
|
||||
|
||||
[JsonProperty("amount")]
|
||||
public int Amount { get; set; } = 0;
|
||||
|
||||
[JsonProperty("rentalFees")]
|
||||
public int RentalFees { get; set; } = 0;
|
||||
|
||||
public Paycheck(float FinancialHelp, float FinancialInterest, int VehicleTaxation, float PropertyTaxation, int Wage, int Amount, int RentalFees)
|
||||
|
||||
Reference in New Issue
Block a user