1
0
Fork 0
forked from Simnation/Main

Update billing_client.lua

This commit is contained in:
Nordi98 2025-08-05 11:19:51 +02:00
parent b43fa3c75e
commit 5bc835bc97

View file

@ -4,16 +4,44 @@ local QBCore = exports['qb-core']:GetCoreObject()
local isUiOpen = false
local cooldown = false
-- Command to open billing menu
-- Command to open main billing menu
RegisterCommand('bill', function()
OpenBillingMenu()
OpenMainBillingMenu()
end, false)
-- Keybind registration
RegisterKeyMapping('bill', 'Open Billing Menu', 'keyboard', 'F7') -- Default key is F7, can be changed in settings
-- Function to open the billing menu
function OpenBillingMenu()
-- Function to open the main billing menu
function OpenMainBillingMenu()
lib.registerContext({
id = 'main_billing_menu',
title = 'Billing System',
options = {
{
title = 'Create Bill',
description = 'Send a bill to a nearby player',
icon = 'file-invoice-dollar',
onSelect = function()
OpenCreateBillMenu()
end
},
{
title = 'My Bills',
description = 'View and pay your received bills',
icon = 'money-check',
onSelect = function()
ViewBills()
end
}
}
})
lib.showContext('main_billing_menu')
end
-- Function to open the create bill menu
function OpenCreateBillMenu()
if cooldown then
lib.notify({
title = 'Billing System',
@ -52,12 +80,13 @@ function OpenBillingMenu()
})
end
-- Show the list of nearby players first
-- Show the list of nearby players
local playerOptions = {}
for _, player in ipairs(players) do
table.insert(playerOptions, {
title = player.name,
description = 'ID: ' .. player.id,
icon = 'user',
onSelect = function()
-- When a player is selected, show the billing form
ShowBillingForm(player, accountOptions)
@ -69,6 +98,7 @@ function OpenBillingMenu()
lib.registerContext({
id = 'nearby_players_menu',
title = 'Select Player to Bill',
menu = 'main_billing_menu', -- Add back button to main menu
options = playerOptions
})
@ -127,6 +157,9 @@ function ShowBillingForm(selectedPlayer, accountOptions)
SetTimeout(5000, function()
cooldown = false
end)
-- Return to main menu
OpenMainBillingMenu()
else
lib.notify({
title = 'Billing System',
@ -146,6 +179,11 @@ function ViewBills()
description = 'You have no unpaid bills',
type = 'info'
})
-- Return to main menu after a short delay
SetTimeout(1000, function()
OpenMainBillingMenu()
end)
return
end
@ -155,6 +193,7 @@ function ViewBills()
table.insert(billOptions, {
title = bill.description,
description = ('Amount: $%s | Date: %s'):format(bill.amount, timestamp),
icon = 'file-invoice',
metadata = {
{label = 'Bill ID', value = bill.id},
{label = 'Type', value = bill.type},
@ -192,17 +231,13 @@ function ViewBills()
lib.registerContext({
id = 'billing_menu',
title = 'Your Bills',
menu = 'main_billing_menu', -- Add back button to main menu
options = billOptions
})
lib.showContext('billing_menu')
end
-- Command to view bills
RegisterCommand('bills', function()
ViewBills()
end, false)
-- Helper function to get nearby players
function GetNearbyPlayers()
local playerPed = PlayerPedId()