2025-02-21 13:54:49 +00:00
|
|
|
RegisterNetEvent(getScript()..":client:PolCharge", function()
|
2025-02-22 13:23:43 +00:00
|
|
|
local Playerinfo = getPlayer()
|
2024-01-28 12:27:47 +00:00
|
|
|
--Check if player is allowed to use /cashregister command
|
|
|
|
|
local allowed = false
|
2025-05-12 10:49:00 +01:00
|
|
|
for k in pairs(Config.PolCharge.FineJobs) do
|
|
|
|
|
if k == Playerinfo.job then
|
|
|
|
|
allowed = true
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not allowed then
|
|
|
|
|
triggerNotify(nil, locale("error", "no_job"), "error")
|
|
|
|
|
return
|
|
|
|
|
end
|
2024-01-28 12:27:47 +00:00
|
|
|
|
|
|
|
|
local newinputs = {} -- Begin qb-input creation here.
|
|
|
|
|
local nearbyList = {}
|
|
|
|
|
if Config.PolCharge.FineJobList then -- If nearby player list is wanted:
|
2025-05-12 10:49:00 +01:00
|
|
|
-- Retrieve a list of nearby players from server
|
2025-02-21 13:54:49 +00:00
|
|
|
local onlineList = triggerCallback(getScript()..":MakePlayerList")
|
2025-05-12 10:49:00 +01:00
|
|
|
-- Convert list of players nearby into one an input script understands + add distance info
|
2024-01-28 12:27:47 +00:00
|
|
|
for _, v in pairs(Core.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.General.PaymentRadius)) do
|
|
|
|
|
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
|
|
|
|
|
for i = 1, #onlineList do
|
|
|
|
|
if onlineList[i].value == GetPlayerServerId(v) then
|
2025-02-21 13:54:49 +00:00
|
|
|
if v ~= PlayerId() or debugMode then
|
2025-05-12 10:49:00 +01:00
|
|
|
nearbyList[#nearbyList+1] = {
|
|
|
|
|
value = onlineList[i].value,
|
|
|
|
|
label = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)',
|
|
|
|
|
text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)'
|
|
|
|
|
}
|
2024-01-28 12:27:47 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--If list is empty(no one nearby) show error and stop
|
2025-05-12 10:49:00 +01:00
|
|
|
if not nearbyList[1] then
|
|
|
|
|
triggerNotify(nil, locale("error" ,"no_one"), "error")
|
|
|
|
|
return
|
|
|
|
|
end
|
2024-01-28 12:27:47 +00:00
|
|
|
|
2025-05-12 10:49:00 +01:00
|
|
|
newinputs[#newinputs+1] = {
|
|
|
|
|
type = "select",
|
|
|
|
|
text = locale("menu" ,"cus_id"),
|
|
|
|
|
name = "citizen",
|
|
|
|
|
label = locale("menu" ,"cus_id"),
|
|
|
|
|
default = 1,
|
|
|
|
|
options = nearbyList
|
|
|
|
|
}
|
2024-01-28 12:27:47 +00:00
|
|
|
else
|
2025-05-12 10:49:00 +01:00
|
|
|
newinputs[#newinputs+1] = {
|
|
|
|
|
type = 'text',
|
|
|
|
|
isRequired = true,
|
|
|
|
|
name = 'citizen',
|
|
|
|
|
text = locale("menu" ,"cus_id")
|
|
|
|
|
}
|
2024-01-28 12:27:47 +00:00
|
|
|
end
|
2025-05-12 10:49:00 +01:00
|
|
|
newinputs[#newinputs+1] = {
|
|
|
|
|
type = 'number',
|
|
|
|
|
isRequired = true,
|
|
|
|
|
name = 'price',
|
|
|
|
|
text = locale("menu" ,"amount_charge")
|
|
|
|
|
}
|
2024-01-28 12:27:47 +00:00
|
|
|
|
2025-02-22 13:23:43 +00:00
|
|
|
local dialog = createInput(Jobs[Playerinfo.job].label, newinputs)
|
2024-01-28 12:27:47 +00:00
|
|
|
if dialog then
|
2025-05-12 10:49:00 +01:00
|
|
|
jsonPrint(dialog)
|
2024-01-28 12:27:47 +00:00
|
|
|
if dialog[1] then
|
|
|
|
|
dialog.citizen = dialog[1]
|
|
|
|
|
dialog.price = dialog[2]
|
|
|
|
|
end
|
2025-02-21 13:54:49 +00:00
|
|
|
TriggerServerEvent(getScript()..":server:PolCharge", dialog.citizen, dialog.price)
|
2024-01-28 12:27:47 +00:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
2025-05-14 20:23:41 +01:00
|
|
|
RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob, commPercent)
|
2024-01-28 12:27:47 +00:00
|
|
|
local Menu = {}
|
2025-05-12 10:49:00 +01:00
|
|
|
Menu[#Menu+1] = {
|
|
|
|
|
isMenuHeader = true,
|
|
|
|
|
header = "",
|
|
|
|
|
txt = locale("menu" ,"bank_charge")..amount
|
|
|
|
|
}
|
2024-01-28 12:27:47 +00:00
|
|
|
Menu[#Menu+1] = {
|
|
|
|
|
icon = "fas fa-circle-check",
|
2025-02-22 13:23:43 +00:00
|
|
|
header = locale("menu" ,"yes"),
|
2024-01-28 12:27:47 +00:00
|
|
|
txt = "",
|
|
|
|
|
onSelect = function()
|
2025-02-21 13:54:49 +00:00
|
|
|
TriggerServerEvent(getScript()..":server:PolPopup", {
|
2024-01-28 12:27:47 +00:00
|
|
|
accept = true,
|
|
|
|
|
amount = amount,
|
|
|
|
|
biller = biller,
|
2025-05-14 20:23:41 +01:00
|
|
|
commPercent = commPercent,
|
2024-01-28 12:27:47 +00:00
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
Menu[#Menu+1] = {
|
|
|
|
|
icon = "fas fa-circle-xmark",
|
2025-02-22 13:23:43 +00:00
|
|
|
header = locale("menu" ,"no"),
|
2024-01-28 12:27:47 +00:00
|
|
|
onSelect = function()
|
2025-02-21 13:54:49 +00:00
|
|
|
TriggerServerEvent(getScript()..":server:PolPopup", {
|
2024-01-28 12:27:47 +00:00
|
|
|
accept = false,
|
|
|
|
|
amount = amount,
|
|
|
|
|
biller = biller,
|
|
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
openMenu(Menu, {
|
2025-02-22 13:23:43 +00:00
|
|
|
header = "🧾 "..billerjob..locale("menu" ,"payment"),
|
|
|
|
|
headertxt = locale("menu" ,"accept_payment"),
|
2024-01-28 12:27:47 +00:00
|
|
|
onExit = function()
|
2025-02-21 13:54:49 +00:00
|
|
|
TriggerServerEvent(getScript()..":server:PolPopup", {
|
2024-01-28 12:27:47 +00:00
|
|
|
accept = false,
|
|
|
|
|
amount = amount,
|
|
|
|
|
biller = biller,
|
|
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
end)
|