diff --git a/ReallifeGamemode.Client/Interaction/interactionmenu.ts b/ReallifeGamemode.Client/Interaction/interactionmenu.ts index fbb28f5e..606cd303 100644 --- a/ReallifeGamemode.Client/Interaction/interactionmenu.ts +++ b/ReallifeGamemode.Client/Interaction/interactionmenu.ts @@ -324,7 +324,6 @@ export default function (globalData: IGlobalData) { function getVehiclesMenu(vehicles: VehicleData[], parentMenu: NativeUI.Menu): NativeUI.Menu { var menu = new Menu("Fahrzeuge", "Finde oder verkaufe deine Fahrzeuge", new Point(50, 50), null, null); - menu.Visible = false; var collection = new ItemsCollection(["Finden", "Verkaufen"]); @@ -340,6 +339,60 @@ export default function (globalData: IGlobalData) { var id = item.Data.id; var selection = item.SelectedValue; + if (selection === "Verkaufen") { + var confirmMenu = new Menu("Fahrzeug verkaufen", "Bist du sicher?", new Point(50, 50)); + + menu.Visible = false; + + var descItem = new UIMenuItem("Willst du das Auto wirklich verkaufen?"); + confirmMenu.AddItem(descItem); + + var priceItem = new UIMenuItem("Verkaufspreis"); + priceItem.SetRightLabel("~g~$ " + moneyFormat(vehicles.find(x => x.Id == id).Price * 0.6)); + confirmMenu.AddItem(priceItem); + + var yesItem = new UIMenuItem("Verkaufen"); + yesItem.BackColor = new Color(0, 100, 0); + yesItem.HighlightedBackColor = new Color(0, 150, 0); + confirmMenu.AddItem(yesItem); + + var cancelItem = new UIMenuItem("Abbrechen"); + cancelItem.BackColor = new Color(213, 0, 0); + cancelItem.HighlightedBackColor = new Color(229, 57, 53); + confirmMenu.AddItem(cancelItem); + + confirmMenu.Open(); + + var closing = false; + + confirmMenu.ItemSelect.on((item, index) => { + if (item != yesItem && item != cancelItem) { + return; + } + + if (item == yesItem) { + mp.events.callRemote("CLIENT:InteractionMenu_VehicleInteraction", id, selection); + confirmMenu.Close(); + parentMenu.Close(true); + closing = true; + return; + } + + confirmMenu.Close(); + menu.Visible = true; + }); + + confirmMenu.MenuClose.on(() => { + if (closing) { + return; + } + + menu.Visible = true; + }) + + return; + } + mp.events.callRemote("CLIENT:InteractionMenu_VehicleInteraction", id, selection); parentMenu.Close(true); @@ -347,6 +400,7 @@ export default function (globalData: IGlobalData) { return menu; } + function getTicketMenu(ticket_amount: number, parentMenu: NativeUI.Menu): NativeUI.Menu { var ticketMenu = new NativeUI.Menu("Ticket", `Ticket in Höhe von ${ticket_amount}$`, new Point(50, 50), null, null); ticketMenu.AddItem(new UIMenuItem("Ticket annehmen")); diff --git a/ReallifeGamemode.Client/global.d.ts b/ReallifeGamemode.Client/global.d.ts index 9bc07c6e..aa9dd2e8 100644 --- a/ReallifeGamemode.Client/global.d.ts +++ b/ReallifeGamemode.Client/global.d.ts @@ -25,6 +25,7 @@ declare type AccountData = { declare type VehicleData = { Id: number; Model: number; + Price: number; }; declare type Paycheck = { diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 24bc7eed..e428bd2d 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -128,7 +128,8 @@ namespace ReallifeGamemode.Server.Events var vehicles = dbContext.UserVehicles.Where(veh => veh.UserId == u.Id).OrderBy(veh => veh.Id).Select(v => new { v.Id, - v.Model + v.Model, + Price = v.Price ?? 0 }); Paycheck paycheck = null; @@ -262,7 +263,7 @@ namespace ReallifeGamemode.Server.Events UpdateCharacterCloth.LoadCharacterDefaults(player); } } - + if (nearestWeapon != null) // Weapon Point {