Refresh TicketSystem
This commit is contained in:
@@ -31,7 +31,7 @@ export default function (globalData: IGlobalData) {
|
||||
|
||||
var vehiclesItem = new UIMenuItem("Fahrzeuge", "Zeige deine Fahrzeuge an");
|
||||
|
||||
var ticketItem = new UIMenuItem("Ticket annehmen", "Strafticket annehmen");
|
||||
var ticketItem = new UIMenuItem("Strafticket", "Strafticket annehmen/ablehnen");
|
||||
|
||||
mp.events.add("SERVER:InteractionMenu_OpenMenu", (accountDataJson: string, faction: string, group: string, factionInvite: boolean, groupInvite: boolean, ticket_boolean: boolean, ticket_amount: number) => {
|
||||
var accountData: AccountData = JSON.parse(accountDataJson);
|
||||
@@ -334,7 +334,7 @@ export default function (globalData: IGlobalData) {
|
||||
return menu;
|
||||
}
|
||||
function getTicketMenu(ticket_amount: number, parentMenu: NativeUI.Menu): NativeUI.Menu {
|
||||
var factionMenu = new NativeUI.Menu("Ticket", `Ticket in Höhe von ${ticket_amount}`, new Point(50, 50), null, null);
|
||||
var factionMenu = new NativeUI.Menu("Ticket", `Ticket in Höhe von ${ticket_amount}$`, new Point(50, 50), null, null);
|
||||
factionMenu.AddItem(new UIMenuItem("Ticket annehmen"));
|
||||
factionMenu.AddItem(new UIMenuItem("Ticket ablehnen"));
|
||||
factionMenu.Visible = false;
|
||||
|
||||
@@ -14,6 +14,7 @@ using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using System.Buffers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)
|
||||
@@ -378,17 +379,32 @@ namespace ReallifeGamemode.Server.Managers
|
||||
string reason = (string)JsonConvert.DeserializeObject(jsonReason);
|
||||
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
|
||||
string playername = NAPI.Player.GetPlayerName(player);
|
||||
|
||||
string targetname = NAPI.Player.GetPlayerName(target);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
else if (target == player)
|
||||
{
|
||||
player.SendNotification("~r~Du kannst dir selbst keine Punkte setzen!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (amount > 0 && amount < 10000)
|
||||
{
|
||||
player.SendNotification($"~w~Du hast ~y~{targetname} ~w~ein Ticket in Höhe von ~b~{amount}$ ~w~gestellt. Grund: ~g~{reason}~w~.");
|
||||
target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ein Ticket in Höhe von ~y~{amount}$ ~w~gestellt.", true);
|
||||
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Strafticket im Interaktionsmenü annehmen.", true);
|
||||
//target.SendChatMessage("Du kannst mit '/accept ticket' das Strafticket annehmen.");
|
||||
target.SetData("ticket_boolean", true);
|
||||
//target.SetData("ticket_amount", amount);
|
||||
//target.SetSharedData("ticket_amount", amount);
|
||||
NAPI.Data.SetEntityData(target, "ticket_amount", amount);
|
||||
NAPI.Data.SetEntityData(target, "ticket_player", player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du kannst nur zwischen 1$ und 10000$ angeben!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[RemoteEvent("CLIENT:InteractionMenu_LSPD_Points3")]
|
||||
@@ -492,6 +508,21 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
target.SendNotification($"~g~Du hast das Ticket über ~b~{ticket_amount}$ ~g~angenommen und bezahlt.", true);
|
||||
player.SendNotification($"~y~{targetname} ~g~hat das Ticket über ~b~{ticket_amount}$ ~g~angenommen und bezahlt.", true);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
target.GetUser(dbContext).BankAccount.Balance -= ticket_amount;
|
||||
if (player.GetUser().FactionId == 1)
|
||||
{
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1).First().BankAccount.Balance += (int)(ticket_amount / 100 * 70);
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 3).First().BankAccount.Balance += (int)(ticket_amount / 100 * 30);
|
||||
}
|
||||
if (player.GetUser().FactionId == 1)
|
||||
{
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 3).First().BankAccount.Balance += (int)(ticket_amount / 100 * 70);
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1).First().BankAccount.Balance += (int)(ticket_amount / 100 * 30);
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
target.ResetData("ticket_boolean");
|
||||
NAPI.Data.ResetEntityData(target, "ticket_amount");
|
||||
NAPI.Data.ResetEntityData(target, "ticket_player");
|
||||
|
||||
Reference in New Issue
Block a user