mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
Added callbacks to grab characters name
This adds callback triggers for grabbing the players Character name instead of their user name Also adds a callback trigger for the amount of tickets in a persons pockets for the trading tickets menu + cosmetic changes
This commit is contained in:
27
client.lua
27
client.lua
@@ -38,16 +38,25 @@ RegisterNetEvent('jim-payments:client:Charge', function()
|
||||
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
||||
local playerList = {}
|
||||
for k,v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
||||
dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
--TriggerEvent("QBCore:Notify", "["..GetPlayerServerId(v).."] - "..GetPlayerName(v).." ("..math.floor(dist+0.5).."m)", "error")
|
||||
--Distance info, cosmetic for adding the "(5m)" when opening the register
|
||||
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
||||
|
||||
--Moved the script to client, and needed to grab full character name not the username
|
||||
local name = nil
|
||||
while name == nil do QBCore.Functions.TriggerCallback('jim-payments:Name:Find', function(cb) name = cb end, GetPlayerServerId(v)) Citizen.Wait(1) end
|
||||
|
||||
--Debugging notification, this shows the info it finds regardless of it adds to the list or not
|
||||
--TriggerEvent("QBCore:Notify", "["..GetPlayerServerId(v).."] - "..name.." ("..math.floor(dist+0.5).."m)", "error")
|
||||
|
||||
if v ~= PlayerId() then
|
||||
playerList[#playerList+1] = { value = GetPlayerServerId(v), text = "["..GetPlayerServerId(v).."] - "..GetPlayerName(v).." ("..math.floor(dist+0.5).."m)" }
|
||||
playerList[#playerList+1] = { value = GetPlayerServerId(v), text = "["..GetPlayerServerId(v).."] - "..name.." ("..math.floor(dist+0.5).."m)" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if playerList[1] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
local dialog = exports['qb-input']:ShowInput({ header = "Charge Customer", submitText = "Send",
|
||||
local dialog = exports['qb-input']:ShowInput({ header = PlayerJob.label.." Cash Register", submitText = "Send",
|
||||
inputs = {
|
||||
{ text = "Citizen", name = "citizen", type = "select", options = playerList },
|
||||
{ text = "Charge Customer:", name = "citizen", type = "select", options = playerList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = 'Amount to Charge' },
|
||||
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } }, }
|
||||
})
|
||||
@@ -56,10 +65,14 @@ RegisterNetEvent('jim-payments:client:Charge', function()
|
||||
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||
local amount = nil
|
||||
while amount == nil do QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) amount = cb end) Citizen.Wait(1) end
|
||||
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
||||
else exports['qb-menu']:openMenu({
|
||||
{ isMenuHeader = true, header = PlayerJob.label.." Ticket Payment", txt = "Do you want trade your tickets for payment?" },
|
||||
{ isMenuHeader = true, header = "", txt = "Amount of Tickets: "..amount.."<br>Total Payment: $"..(Config.Jobs[PlayerJob.name].PayPerTicket * amount) },
|
||||
{ header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
||||
{ header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
||||
end
|
||||
@@ -67,4 +80,4 @@ RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
||||
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|
||||
|
||||
Reference in New Issue
Block a user