1
0
Fork 0
forked from Simnation/Main

Update billing_client.lua

This commit is contained in:
Nordi98 2025-08-05 11:16:01 +02:00
parent 35facf8123
commit b43fa3c75e

View file

@ -1,3 +1,4 @@
-- Initialize QBCore
local QBCore = exports['qb-core']:GetCoreObject()
local isUiOpen = false
@ -51,23 +52,32 @@ function OpenBillingMenu()
})
end
-- Create player options for selection
-- Show the list of nearby players first
local playerOptions = {}
for _, player in ipairs(players) do
table.insert(playerOptions, {
value = player.id,
label = player.name .. ' (ID: ' .. player.id .. ')'
title = player.name,
description = 'ID: ' .. player.id,
onSelect = function()
-- When a player is selected, show the billing form
ShowBillingForm(player, accountOptions)
end
})
end
-- Create the input dialog
local input = lib.inputDialog('Create Bill', {
{
type = 'select',
label = 'Select Player',
options = playerOptions,
required = true
},
-- Register and show the player selection menu
lib.registerContext({
id = 'nearby_players_menu',
title = 'Select Player to Bill',
options = playerOptions
})
lib.showContext('nearby_players_menu')
end
-- Function to show the billing form after selecting a player
function ShowBillingForm(selectedPlayer, accountOptions)
local input = lib.inputDialog('Create Bill for ' .. selectedPlayer.name, {
{
type = 'number',
label = 'Amount ($)',
@ -99,16 +109,16 @@ function OpenBillingMenu()
-- Send the bill
local success = lib.callback.await('billing:server:sendBill', false, {
playerId = input[1],
amount = input[2],
reason = input[3],
account = input[4]
playerId = selectedPlayer.id,
amount = input[1],
reason = input[2],
account = input[3]
})
if success then
lib.notify({
title = 'Billing System',
description = 'Bill sent successfully',
description = 'Bill sent successfully to ' .. selectedPlayer.name,
type = 'success'
})
@ -196,22 +206,25 @@ end, false)
-- Helper function to get nearby players
function GetNearbyPlayers()
local playerPed = PlayerPedId()
local players = QBCore.Functions.GetPlayers()
local nearbyPlayers = {}
local playerCoords = GetEntityCoords(playerPed)
local players = {}
for _, player in ipairs(players) do
-- Get all players
local allPlayers = GetActivePlayers()
for _, player in ipairs(allPlayers) do
local targetPed = GetPlayerPed(player)
local targetCoords = GetEntityCoords(targetPed)
local distance = #(GetEntityCoords(playerPed) - targetCoords)
local distance = #(playerCoords - targetCoords)
if distance <= 5.0 and targetPed ~= playerPed then
local targetId = GetPlayerServerId(player)
local targetName = GetPlayerName(player)
table.insert(nearbyPlayers, {id = targetId, name = targetName})
table.insert(players, {id = targetId, name = targetName})
end
end
return nearbyPlayers
return players
end
-- Animation function