2022-02-05 15:44:29 +00:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
|
|
|
|
|
PlayerJob = {}
|
|
|
|
|
local onDuty = false
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
|
|
|
|
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
|
|
|
|
QBCore.Functions.GetPlayerData(function(PlayerData)
|
|
|
|
|
PlayerJob = PlayerData.job
|
2022-02-14 23:07:18 +00:00
|
|
|
PlayerGang = PlayerData.gang
|
2022-02-05 15:44:29 +00:00
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('QBCore:Client:OnJobUpdate')
|
|
|
|
|
AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo)
|
|
|
|
|
PlayerJob = JobInfo
|
|
|
|
|
onDuty = PlayerJob.onduty
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('QBCore:Client:SetDuty')
|
|
|
|
|
AddEventHandler('QBCore:Client:SetDuty', function(duty)
|
|
|
|
|
onDuty = duty
|
|
|
|
|
end)
|
|
|
|
|
|
2022-02-14 23:07:18 +00:00
|
|
|
RegisterNetEvent('QBCore:Client:OnGangUpdate')
|
|
|
|
|
AddEventHandler('QBCore:Client:OnGangUpdate', function(GangInfo)
|
|
|
|
|
PlayerGang = GangInfo
|
|
|
|
|
end)
|
|
|
|
|
|
2022-02-05 15:44:29 +00:00
|
|
|
--Keeps track of duty on script restarts
|
2022-02-06 15:47:07 +00:00
|
|
|
AddEventHandler('onResourceStart', function(resource)
|
2022-02-14 23:07:18 +00:00
|
|
|
if GetCurrentResourceName() == resource then QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang onDuty = PlayerJob.onduty end) end end)
|
2022-02-05 15:44:29 +00:00
|
|
|
|
|
|
|
|
Citizen.CreateThread(function()
|
|
|
|
|
local jobroles = {}
|
2022-02-06 15:47:07 +00:00
|
|
|
for k, v in pairs(Config.Jobs) do jobroles[tostring(k)] = 0 end
|
2022-02-08 20:16:31 +00:00
|
|
|
exports['qb-target']:AddBoxZone("JimBank", vector3(251.75, 222.17, 106.2), 0.6, 2.0, { name="JimBank", heading = 340.0, debugPoly=false, minZ = 105.75, maxZ = 107.29, },
|
2022-02-14 23:07:18 +00:00
|
|
|
{ options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Receipts", job = jobroles } }, distance = 2.0 })
|
2022-02-05 15:44:29 +00:00
|
|
|
end)
|
|
|
|
|
|
2022-02-25 10:10:08 +00:00
|
|
|
RegisterNetEvent('jim-payments:client:Charge', function(data)
|
2022-02-05 15:44:29 +00:00
|
|
|
if not onDuty then TriggerEvent("QBCore:Notify", "Not Clocked in!", "error") return end -- Require to be on duty when making a payment
|
2022-02-17 12:43:15 +00:00
|
|
|
local onlineList = {}
|
|
|
|
|
local nearbyList = {}
|
|
|
|
|
QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end
|
|
|
|
|
for k, v in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do
|
|
|
|
|
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
|
|
|
|
for i = 1, #onlineList do
|
|
|
|
|
if onlineList[i].value == GetPlayerServerId(v) then
|
|
|
|
|
if v ~= PlayerId() then
|
2022-02-25 10:10:08 +00:00
|
|
|
nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' }
|
2022-02-17 12:43:15 +00:00
|
|
|
end
|
2022-02-14 23:07:18 +00:00
|
|
|
end
|
2022-02-17 12:43:15 +00:00
|
|
|
end
|
|
|
|
|
dist = nil
|
2022-02-05 15:44:29 +00:00
|
|
|
end
|
2022-02-25 10:10:08 +00:00
|
|
|
if data.img == nil then img = "" else img = data.img end
|
2022-02-17 12:43:15 +00:00
|
|
|
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
2022-02-23 20:35:50 +00:00
|
|
|
local dialog = exports['qb-input']:ShowInput({ header = img..PlayerJob.label.." Cash Register", submitText = "Send",
|
2022-02-17 12:43:15 +00:00
|
|
|
inputs = {
|
|
|
|
|
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
|
|
|
|
{ type = 'radio', name = 'billtype', text = 'Payment Type', options = { { value = "cash", text = "Cash" }, { value = "card", text = "Card" } } },
|
|
|
|
|
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Charge' },}
|
|
|
|
|
})
|
|
|
|
|
if dialog then
|
|
|
|
|
if not dialog.citizen or not dialog.price then return end
|
|
|
|
|
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype)
|
|
|
|
|
end
|
|
|
|
|
end)
|
2022-02-05 16:10:11 +00:00
|
|
|
end)
|
2022-02-09 12:54:06 +00:00
|
|
|
|
2022-02-06 15:47:07 +00:00
|
|
|
RegisterNetEvent('jim-payments:Tickets:Menu', function()
|
2022-02-09 12:54:06 +00:00
|
|
|
local amount = nil
|
|
|
|
|
while amount == nil do QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) amount = cb end) Citizen.Wait(1) end
|
2022-02-06 15:47:07 +00:00
|
|
|
for k, v in pairs(Config.Jobs) do if k ~= PlayerJob.name then
|
|
|
|
|
else exports['qb-menu']:openMenu({
|
2022-02-11 17:49:37 +00:00
|
|
|
{ isMenuHeader = true, header = "🧾 "..PlayerJob.label.." Receipts 🧾", txt = "Do you want trade your receipts for payment?" },
|
2022-02-09 12:54:06 +00:00
|
|
|
{ isMenuHeader = true, header = "", txt = "Amount of Tickets: "..amount.."<br>Total Payment: $"..(Config.Jobs[PlayerJob.name].PayPerTicket * amount) },
|
2022-02-08 19:19:05 +00:00
|
|
|
{ header = "Yes", txt = "", params = { event = "jim-payments:Tickets:Sell:yes" } },
|
|
|
|
|
{ header = "No", txt = "", params = { event = "jim-payments:Tickets:Sell:no" } }, })
|
2022-02-06 15:47:07 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent('jim-payments:Tickets:Sell') end)
|
2022-02-17 12:43:15 +00:00
|
|
|
RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end)
|