From 0905c7489c2ae2cae502002e86bffd3e6a43383b Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 27 Jan 2024 21:57:05 +0000 Subject: [PATCH] v3.0 Beta Push --- client/atms.lua | 336 ++++++++++---------------------- client/banks.lua | 340 ++++++++++++++++++++++++++++++++ client/charge.lua | 145 ++++++++++++++ client/client.lua | 121 ++---------- client/polcharge.lua | 1 + client/tickets.lua | 20 ++ config.lua | 387 +++++++++++++------------------------ fxmanifest.lua | 38 +++- locales/da.lua | 24 +-- locales/de.lua | 26 +-- locales/en.lua | 28 +-- server/atmserver.lua | 59 +++--- server/chargerserver.lua | 214 ++++++++++++++++++++ server/polchargeserver.lua | 1 + server/server.lua | 289 --------------------------- shared/banklocs.lua | 63 ++++++ shared/shared.lua | 120 ------------ version.txt | 1 + 18 files changed, 1129 insertions(+), 1084 deletions(-) create mode 100644 client/banks.lua create mode 100644 client/charge.lua create mode 100644 client/polcharge.lua create mode 100644 client/tickets.lua create mode 100644 server/chargerserver.lua create mode 100644 server/polchargeserver.lua delete mode 100644 server/server.lua create mode 100644 shared/banklocs.lua delete mode 100644 shared/shared.lua create mode 100644 version.txt diff --git a/client/atms.lua b/client/atms.lua index 3141498..6576d50 100644 --- a/client/atms.lua +++ b/client/atms.lua @@ -1,246 +1,110 @@ --- This script is a simple replacement for QB-Banking and QB-ATMs --- It uses QB-Input and server callbacks to retreive info about accounts and cash --- This requires QB-Target and has the location of every ATM, ATM prop and bank window - local Targets = {} -local Peds = {} -local BankLoc = Config.VanBankLocations -local ATMLoc = Config.VanATMLocations +if Config.ATMs.enable then + CreateThread(function() -- Automatic detection of models and make targets and blips + while true do + local pedCoords = GetEntityCoords(PlayerPedId()) + for _, v in pairs(GetGamePool('CObject')) do + for _, model in pairs(Config.ATMs.ATMModels) do + if GetEntityModel(v) == model then + local name, entCoords = GetCurrentResourceName()..":ATMLocation:"..v, GetEntityCoords(v) + if #(pedCoords - entCoords) <= 150 then + if not Targets[name] then + Targets[name] = + createCircleTarget({name, vec3(entCoords.x, entCoords.y, entCoords.z+1.03), 0.5, { name=name, debugPoly=Config.System.Debug, useZ=true, },}, + { { action = function() lookEnt(v) TriggerEvent("jim-payments:Client:ATM") end, + icon = "fas fa-money-check-alt", label = Loc[Config.Lan].target["atm"], + }, }, 1.5) + end + if Config.ATMs.showBlips then + if not DoesBlipExist(GetBlipFromEntity(v)) then + makeEntityBlip({entity = v, sprite = 434, col = 3, name = "ATM" }) + end + end + else + removeZoneTarget(name) + Targets[name] = nil + if DoesBlipExist(GetBlipFromEntity(v)) then RemoveBlip(GetBlipFromEntity(v)) end + end + end + end + end + Wait(5000) + end + end) +end -local bossroles = {} -local gangroles = {} -CreateThread(function() - if Config.useATM then - if Config.ATMBlips then - for _, v in pairs(Config.WallATMLocations) do - makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = Loc[Config.Lan].blip["blip_atm"] }) - end - for _, v in pairs(Config.ATMLocations) do - makeBlip({coords = v, sprite = 108, col = 3, scale = 0.55, disp = 6, name = Loc[Config.Lan].blip["blip_atm"] }) - end - end - end - if Config.useBanks then - if Config.BankBlips then - for _, v in pairs(Config.BankLocations) do - for _, b in pairs(v) do - makeBlip({coords = b, sprite = 108, col = 2, scale = 0.55, disp = 6, name = Loc[Config.Lan].blip["blip_bank"] }) - break - end - end - end - end - if Config.useATM or Config.useBanks then - for k in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs - if QBCore.Shared.Jobs[tostring(k)] then - for l in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do -- Grabs the list of grades - if QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then -- Checks the grade if is boss - if bossroles[tostring(k)] then -- checks if the line exists - if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the - else bossroles[tostring(k)] = tonumber(l) - end - end - end - end - end - for k in pairs(QBCore.Shared.Gangs) do - if QBCore.Shared.Gangs[tostring(k)] then - for l in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do - if tostring(k) ~= "none" then - if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then - if gangroles[tostring(k)] then - if gangroles[tostring(k)] > tonumber(l) then gangroles[tostring(k)] = tonumber(l) end - else gangroles[tostring(k)] = tonumber(l) - end - end - end - end - end - end - end - if Config.useATM then - exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = Loc[Config.Lan].target["atm"], id = "atm" },}, distance = 1.5, }) - for k,v in pairs(Config.WallATMLocations) do - Targets["jimwallatm"..k] = - exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(v.x, v.y, v.z+0.2), 0.5, { name="jimwallatm"..k, debugPoly=Config.Debug, useZ=true, }, - { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = Loc[Config.Lan].target["atm"], id = "atm" }, - --{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = Loc[Config.Lan].target["transfer_money"], id = "transfer" }, - }, distance = 1.5 }) - end - for k,v in pairs(Config.ATMLocations) do - Targets["jimatm"..k] = - exports['qb-target']:AddCircleZone("jimatm"..k, vector3(v.x, v.y, v.z+0.2), 0.5, { name="jimatm"..k, debugPoly=Config.Debug, useZ=true, }, - { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = Loc[Config.Lan].target["atm"], id = "atm" }, - --{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = Loc[Config.Lan].target["transfer_money"], id = "transfer" }, - }, distance = 1.5 }) - end - end - if Config.useBanks then - for k,v in pairs(Config.BankLocations) do - for l, b in pairs(v) do - Targets["jimbank"..k..l] = - exports['qb-target']:AddCircleZone("jimbank"..k..l, vector3(b.x, b.y, b.z+0.2), 2.0, { name="jimbank"..k..l, debugPoly=Config.Debug, useZ=true, }, - { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-piggy-bank", label = Loc[Config.Lan].target["bank"], id = "bank" }, - { event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = Loc[Config.Lan].target["transfer"], id = "transfer" }, - { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-dollar", label = Loc[Config.Lan].target["saving"], id = "savings" }, - - { event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = Loc[Config.Lan].target["soc_saving"], id = "society", job = bossroles }, - { event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = Loc[Config.Lan].target["soc_trans"], id = "societytransfer", job = bossroles }, - - { event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = Loc[Config.Lan].target["gang_acct"], id = "gang", gang = gangroles }, - { event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = Loc[Config.Lan].target["gang_trans"], id = "gangtransfer", gang = gangroles }, }, - distance = 2.5 }) - if Config.Peds then - local i = math.random(1, #Config.PedPool) - if not Config.Gabz then CreateModelHide(b.xyz, 1.0, `v_corp_bk_chair3`, true) end - if not Peds["jimbank"..k..l] then Peds["jimbank"..k..l] = makePed(Config.PedPool[i], b, false, false) end - end - end - end - end -end) - -RegisterNetEvent('jim-payments:Client:ATM:use', function(data) +RegisterNetEvent('jim-payments:Client:ATM', function() local setheader = nil --this grabs all the info from names to savings account numbers in the databases - local p = promise.new() - QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p) - if Config.Banking == "qb" then - local p = promise.new() - QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p) - local p2 = promise.new() - QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.gsociety = Citizen.Await(p2) - end - local atmbartime = 2500 - local bartext = "" - local setoptions = {} + local info = triggerCallback("jim-payments:GetInfo") - if data.id == "atm" then - setoptions = { { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, } - setview = "

"..Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["citizenid"]..info.cid..Loc[Config.Lan].menu["header_balance_bank"]..cv(info.bank)..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_atm"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - for k, v in pairs(Config.ATMModels) do - if IsObjectNearPoint(v, GetEntityCoords(PlayerPedId()), 1.6) then - local obj = GetClosestObjectOfType(GetEntityCoords(PlayerPedId()), 1.6, v, false, false, false) - local atmCoords = GetEntityCoords(obj) - lookEnt(obj) - bartext = Loc[Config.Lan].menu["acc_atm"] - end - end + playAnim("amb@prop_human_atm@male@enter", "enter", 2000, 1) - elseif data.id == "bank" then - setoptions = { { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_acc"]..info.account.."
"..info.cid..Loc[Config.Lan].menu["header_balance_bank"]..cv(info.bank)..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_bank"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_bank"] + if progressBar({ label = Loc[Config.Lan].menu["acc_atm"], time = 3000 }) then + local Menu = {} - elseif data.id == "transfer" then - setoptions = { { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_acc"]..info.account.."
"..info.cid..Loc[Config.Lan].menu["header_balance_bank"]..cv(info.bank)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_trans"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'text', isRequired = true, name = 'account', text = Loc[Config.Lan].menu["header_account_no"] }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - - bartext = Loc[Config.Lan].menu["acc_trans"] - - elseif data.id == "savings" then - setoptions = { { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_info"]..info.aid.."
"..info.cid..Loc[Config.Lan].menu["saving_balance"]..cv(info.savbal)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_saving"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_saving"] - - elseif data.id == "society" then - setoptions = { { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_soc"]..PlayerJob.label..Loc[Config.Lan].menu["header_balance"]..PlayerJob.label.." - $"..cv(info.society)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) - setheader = Loc[Config.Lan].menu["header_soc_bank"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_boss"] - - - elseif data.id == "societytransfer" then - setoptions = { { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_soc"]..PlayerJob.label..Loc[Config.Lan].menu["header_balance"]..PlayerJob.label.." - $"..cv(info.society)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_trans"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'text', isRequired = true, name = 'account', text = Loc[Config.Lan].menu["header_account_no"] }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_boss_trans"] - - - elseif data.id == "gang" then - setheader = Loc[Config.Lan].menu["header_soc_bank"] - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_soc"]..PlayerGang.label..Loc[Config.Lan].menu["header_balance"]..PlayerGang.label.." - $"..cv(info.gsociety)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..Loc[Config.Lan].menu["header_option"] - setoptions = { { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } } - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_gang"] - - - elseif data.id == "gangtransfer" then - setoptions = { { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } } - setview = Loc[Config.Lan].menu["welcome"]..info.name..Loc[Config.Lan].menu["header_soc"]..PlayerGang.label..Loc[Config.Lan].menu["header_balance"]..PlayerGang.label.." - $"..cv(info.gsociety)..Loc[Config.Lan].menu["header_option"] - setheader = Loc[Config.Lan].menu["header_trans"] - setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions }, - { type = 'text', isRequired = true, name = 'account', text = Loc[Config.Lan].menu["header_account_no"] }, - { type = 'number', isRequired = true, name = 'amount', text = Loc[Config.Lan].menu["header_trans_amount"] }, } - bartext = Loc[Config.Lan].menu["acc_gang_trans"] - - end - - loadAnimDict('amb@prop_human_atm@male@enter') - TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true) - unloadAnimDict('amb@prop_human_atm@male@enter') - QBCore.Functions.Progressbar("accessing_atm", bartext, atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() - local dialog = exports['qb-input']:ShowInput({ header = setheader, txt = "test", submitText = Loc[Config.Lan].menu["transfer"], inputs = setinputs }) - if dialog then - if not dialog.amount then return end - loadAnimDict('amb@prop_human_atm@male@exit') - TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true) - unloadAnimDict('amb@prop_human_atm@male@enter') - Wait(1000) - TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, data.id, info.society, info.gsociety) - end - end, function() triggerNotify(nil, Loc[Config.Lan].error["cancel"], "error") - end, data.icon) + Menu[#Menu+1] = { + isMenuHeader = true, + header = Loc[Config.Lan].menu["welcome"]..info.name, + txt = info.cid, + } + Menu[#Menu+1] = { + isMenuHeader = true, + header = Loc[Config.Lan].menu["header_balance"], + txt = Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash) + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].menu["withdraw"], + onSelect = function() + atmWithdrawl(info) + end, + } + local header = Loc[Config.Lan].menu["header_atm"] + if Config.System.Menu == "qb" then header = "
" + elseif Config.System.Menu == "ox" then header = '!['..''.. ']('..Config.General.menuLogo..')' + end + openMenu(Menu, { header = header, canClose = true, onExit = function() playAnim("amb@prop_human_atm@male@exit", "exit", 3000, 1) end, }) + else + triggerNotify(nil, Loc[Config.Lan].error["cancel"], "error") + end end) -RegisterNetEvent('jim-payments:client:ATM:give', function() - local onlineList = {} - local nearbyList = {} - QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) onlineList = cb if onlineList[1] == nil then Wait(200) end - for _, id in pairs(QBCore.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.PaymentRadius)) do - local dist = #(GetEntityCoords(GetPlayerPed(id)) - GetEntityCoords(PlayerPedId())) - for i = 1, #onlineList do - if onlineList[i].value == GetPlayerServerId(id) then - if id ~= PlayerId() or Config.Debug then - nearbyList[#nearbyList+1] = { value = onlineList[i].value, text = onlineList[i].text..' ('..math.floor(dist+0.05)..'m)' } - end - end - end - dist = nil - end - if not nearbyList[1] then triggerNotify(nil, Loc[Config.Lan].error["no_one"], "error") return end - local dialog = exports['qb-input']:ShowInput({ header = Loc[Config.Lan].menu["give_cash"], submitText = Loc[Config.Lan].menu["give"], - inputs = { - { text = " ", name = "citizen", type = "select", options = nearbyList }, - { type = 'number', isRequired = true, name = 'price', text = Loc[Config.Lan].menu["amount_pay"] }, } - }) - if dialog then - if not dialog.citizen or not dialog.price then return end - TriggerServerEvent('jim-payments:server:ATM:give', dialog.citizen, dialog.price) - end - end) -end) +function atmWithdrawl(info) + local setimage = Loc[Config.Lan].menu["header_atm"] + if Config.System.Menu == "qb" then setimage = "
" + elseif Config.System.Menu == "ox" then setimage = '!['..''.. ']('..Config.General.menuLogo..')' + end + local dialog = createInput(Loc[Config.Lan].menu["header_atm"], { + { type = 'radio', + name = 'billtype', + text = + Config.System.Menu == "ox" and Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br.. + Loc[Config.Lan].menu["cash_balance"]..cv(info.cash)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, + } }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"], + min = 0, + max = info.bank, + }, + }) + if dialog then + if dialog[1] then + dialog.billtype = dialog[1] + dialog.amount = dialog[2] or 1 + end + if not dialog.amount then return end + playAnim("amb@prop_human_atm@male@exit", "exit", 3000, 1) + Wait(1000) + TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, "atm", info.society, info.gsociety) + end +end -AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end - for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end - for k in pairs(Peds) do unloadModel(GetEntityModel(Peds[k])) DeletePed(Peds[k]) end -end) diff --git a/client/banks.lua b/client/banks.lua new file mode 100644 index 0000000..27b2803 --- /dev/null +++ b/client/banks.lua @@ -0,0 +1,340 @@ +Peds = {} + +onPlayerLoaded(function() Core.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end) +RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end) +RegisterNetEvent('QBCore:Client:SetDuty', function(duty) onDuty = duty end) +RegisterNetEvent('QBCore:Client:OnGangUpdate', function(GangInfo) PlayerGang = GangInfo end) + +AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() ~= resource then return end + Core.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang onDuty = PlayerJob.onduty end) +end) + +if Config.Banks.enable then + for k, v in pairs(BankLocations) do + for i = 1, #v do + local name = GetCurrentResourceName()..":BankLocation:"..k..i + if Config.General.Peds then + if not Config.Gabz then CreateModelHide(v[i].xyz, 1.0, `v_corp_bk_chair3`, true) end + if not Peds[name] then + Peds[name] = makePed(Config.General.PedPool[math.random(1, #Config.General.PedPool)], v[i], false, false) + if GetResourceState("jim-talktonpc"):find("start") then + exports["jim-talktonpc"]:createDistanceMessage("hi", Peds[name], 3.0, false) + end + end + end + local jobroles = {} local gangroles = {} + for k, v in pairs(Config.Receipts.Jobs) do if v.gang then gangroles[k] = 0 else jobroles[k] = 0 end end + createCircleTarget( + { name, vector3(v[i].x, v[i].y, v[i].z+0.2), 2.0, { name = name, debugPoly = Config.System.Debug, useZ = true, }, }, { + { action = function() + if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then + exports["jim-talktonpc"]:createCam(Peds[name], true, "generic", true) + end + TriggerEvent("jim-payments:Client:Bank", { ped = Config.General.Peds and Peds[name] }) + end, + icon = "fas fa-piggy-bank", label = Loc[Config.Lan].target["bank"] }, + { action = function() TriggerEvent("jim-payments:Tickets:Menu", { gang = false }) end, + icon = "fas fa-receipt", label = Loc[Config.Lan].target["cashin_boss"], job = jobroles, + }, + { action = function() TriggerEvent("jim-payments:Tickets:Menu", { gang = true }) end, + icon = "fas fa-receipt", label = Loc[Config.Lan].target["cashin_gang"], gang = gangroles, + }, + }, 2.5) + if Config.Banks.showBlips then + makeBlip({coords = v[i], sprite = 814, col = 2, scale = 0.7, disp = 6, name = Loc[Config.Lan].blip["blip_bank"] }) + end + end + end +end + +RegisterNetEvent('jim-payments:Client:Bank', function(data) local setheader = nil + --this grabs all the info from names to savings account numbers in the databases + local info = triggerCallback("jim-payments:GetInfo") + if Config.Banking == "qb" then -- Callbacks to get society cash info + local p = promise.new() + QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) info.society = Citizen.Await(p) + local p2 = promise.new() + QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) info.gsociety = Citizen.Await(p2) + end + + playAnim("amb@prop_human_atm@male@enter", "enter", 2000, 1) + if data.ped then info.ped = data.ped end + if progressBar({ label = Loc[Config.Lan].menu["acc_bank"], time = 3000 }) then + local Menu = {} + + Menu[#Menu+1] = { + isMenuHeader = true, + header = Loc[Config.Lan].menu["welcome"]..info.name, + txt = Loc[Config.Lan].menu["header_acc"].." "..info.account..br..info.cid, + } + Menu[#Menu+1] = { + isMenuHeader = true, + header = Loc[Config.Lan].menu["header_acc"]..Loc[Config.Lan].menu["header_balance"], + txt = Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash) + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].menu["deposit"].."/"..Loc[Config.Lan].menu["withdraw"], + icon = "fas fa-piggy-bank", + onSelect = function() info.id = "bank" bankTransaction(info) end, + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["transfer"], + icon = "fas fa-arrow-right-arrow-left", + onSelect = function() info.id = "transfer" bankTransaction(info) end, + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["saving"], + icon = "fas fa-money-check-dollar", + onSelect = function() info.id = "savings" bankTransaction(info) end, + } + if PlayerJob.isboss then + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["soc_saving"], + txt = PlayerJob.label, + icon = "fas fa-building", + onSelect = function() info.id = "society" bankTransaction(info) end, + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["soc_trans"], + txt = PlayerJob.label, + icon = "fas fa-arrow-right-arrow-left", + onSelect = function() info.id = "societytransfer" bankTransaction(info) end, + } + end + if PlayerGang.isboss then + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["gang_acct"], + txt = PlayerGang.label, + icon = "fas fa-building", + onSelect = function() info.id = "gang" bankTransaction(info) end, + } + Menu[#Menu+1] = { + header = Loc[Config.Lan].target["gang_trans"], + txt = PlayerGang.label, + icon = "fas fa-arrow-right-arrow-left", + onSelect = function() info.id = "gangtransfer" bankTransaction(info) end, + } + end + local header = Loc[Config.Lan].menu["header_atm"] + if Config.System.Menu == "qb" then header = "
" + elseif Config.System.Menu == "ox" then header = '!['..''.. ']('..Config.General.menuLogo..')' + end + openMenu(Menu, { header = header, canClose = true, onExit = function() + if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then + exports["jim-talktonpc"]:stopCam() + end + playAnim("amb@prop_human_atm@male@exit", "exit", 3000, 1) + end, }) + else + triggerNotify(nil, Loc[Config.Lan].error["cancel"], "error") + end +end) + +function bankTransaction(info) + local setimage = Loc[Config.Lan].menu["header_atm"] + if Config.System.Menu == "qb" then setimage = "
" + elseif Config.System.Menu == "ox" then setimage = '!['..''.. ']('..Config.General.menuLogo..')' + end + + playAnim("amb@prop_human_atm@male@idle_a", "idle_a", nil, 1) + exports["jim-talktonpc"]:injectEmotion("thanks", info.ped) + local setinputs, setheader = {}, "" + + if info.id == "bank" then + setheader = Loc[Config.Lan].menu["header_bank"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..Loc[Config.Lan].menu["cash_balance"]..cv(info.cash) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br.. + Loc[Config.Lan].menu["cash_balance"]..cv(info.cash)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, + { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } + }, + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + + elseif info.id == "transfer" then + setheader = Loc[Config.Lan].menu["header_trans"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } + }, + }, + { type = 'text', + isRequired = true, + name = 'account', + text = Loc[Config.Lan].menu["header_account_no"] + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"], + min = 0, + max = info.bank, + }, + } + + elseif info.id == "savings" then + setheader = Loc[Config.Lan].menu["header_saving"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and Loc[Config.Lan].menu["saving_balance"]..cv(info.savbal)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + Loc[Config.Lan].menu["saving_balance"]..cv(info.savbal)..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, + { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } + } + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + + elseif info.id == "society" then + setheader = PlayerJob.label.." - "..Loc[Config.Lan].menu["header_soc_bank"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and PlayerJob.label.." - $"..cv(info.society)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + PlayerJob.label.." - $"..cv(info.society)..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, + { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } + } + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + + elseif info.id == "societytransfer" then + setheader = PlayerJob.label.." - "..Loc[Config.Lan].menu["header_trans"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and PlayerJob.label.." - $"..cv(info.society)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + PlayerJob.label.." - $"..cv(info.society)..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } } + }, + { type = 'text', + isRequired = true, + name = 'account', + text = Loc[Config.Lan].menu["header_account_no"] + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + + elseif info.id == "gang" then + setheader = PlayerGang.label.." - "..Loc[Config.Lan].menu["header_soc_bank"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and PlayerGang.label.." - $"..cv(info.gsociety)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + PlayerGang.label.." - $"..cv(info.gsociety)..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] }, + { value = "deposit", text = Loc[Config.Lan].menu["deposit"] } + } + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + + elseif info.id == "gangtransfer" then + setheader = PlayerGang.label.." - "..Loc[Config.Lan].menu["header_soc_bank"] + setinputs = { + { type = 'radio', + name = 'billtype', + text = Config.System.Menu == "ox" and PlayerGang.label.." - $"..cv(info.gsociety)..Loc[Config.Lan].menu["bank_balance"]..cv(info.bank) + or + setimage.. + Loc[Config.Lan].menu["header_balance"]..br.. + PlayerGang.label.." - $"..cv(info.gsociety)..br.. + Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)..br..br.. + Loc[Config.Lan].menu["header_option"], + options = { + { value = "transfer", text = Loc[Config.Lan].menu["transfer"] } + } + }, + { type = 'text', + isRequired = true, + name = 'account', + text = Loc[Config.Lan].menu["header_account_no"] + }, + { type = 'number', + isRequired = true, + name = 'amount', + text = Loc[Config.Lan].menu["header_trans_amount"] + }, + } + end + + local dialog = createInput(setheader, setinputs) + if dialog then + if dialog[1] then + dialog.billtype = dialog[1] + dialog.amount = dialog[2] or 1 + end + if not dialog.amount then + TriggerEvent("jim-payments:Client:Bank", { ped = info.ped }) + return + end + if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then + exports["jim-talktonpc"]:stopCam() + end + playAnim("amb@prop_human_atm@male@exit", "exit", 3000, 1) + Wait(1000) + TriggerServerEvent('jim-payments:server:ATM:use', dialog.amount, dialog.billtype, dialog.account, info.id, info.society, info.gsociety) + end +end \ No newline at end of file diff --git a/client/charge.lua b/client/charge.lua new file mode 100644 index 0000000..a11cc0d --- /dev/null +++ b/client/charge.lua @@ -0,0 +1,145 @@ +local BankPed = nil +local Till = {} + +function spawnCustomRegisters() + for k, v in pairs(Config.CustomCashRegisters) do + for i = 1, #v do + local job, gang = v[i].gang and nil or k, v[i].gang and k or nil + createBoxTarget({"CustomRegister: "..k..i, v[i].coords.xyz, 0.47, 0.34, { name="CustomRegister: "..k..i, heading = v[i].coords[4], debugPoly=Config.Debug, minZ=v[i].coords.z-0.1, maxZ=v[i].coords.z+0.4}}, { + { onSelect = function() TriggerEvent("jim-payments:client:Charge", { job = job, gang = gang, img = ""}) end, icon = "fas fa-credit-card", label = Loc[Config.Lan].target["charge"], } + }, 2.0) + if v[i].prop then makeProp({prop = "prop_till_03", coords = v[i].coords}, 1, false) end + end + end +end +onPlayerLoaded(function() spawnCustomRegisters() end) + +--Keeps track of duty on script restarts +AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end + spawnCustomRegisters() +end) + +local billPrev = "cash" +RegisterNetEvent('jim-payments:client:Charge', function(data, outside) + --Check if player is using /cashregister command + local dialog + --if not outside and not onDuty and data.gang == nil then triggerNotify(nil, Loc[Config.Lan].error["not_onduty"], "error") return end + local newinputs = {} -- Begin qb-input creation here. + local nearbyList = {} + if Config.General.List then -- If nearby player list is wanted: + --Retrieve a list of nearby players from server + local onlineList = triggerCallback("jim-payments:MakePlayerList") + --Convert list of players nearby into one qb-input understands + add distance info + 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 + if v ~= PlayerId() or Config.System.Debug then + 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)' } + end + end + end + end + --If list is empty(no one nearby) show error and stop + if not nearbyList[1] then triggerNotify(nil, Loc[Config.Lan].error["no_one"], "error") return end + end + --Check if image was given when opening the regsiter + local img = "" + if Config.System.Menu == "qb" then + img = "
" + elseif Config.System.Menu == "ox" then + img = "" + end + --Grab Player Job name or Gang Name if needed + local label = PlayerJob.label + local gang = false + if data.gang then label = PlayerGang.label gang = true end + if Config.General.List then + newinputs[#newinputs+1] = { type = "select", text = Loc[Config.Lan].menu["cus_id"], name = "citizen", label = Loc[Config.Lan].menu["cus_id"], default = 1, options = nearbyList } + else + newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = Loc[Config.Lan].menu["cus_id"] } + end + newinputs[#newinputs+1] = { + type = 'select', + name = 'billtype', + text = Loc[Config.Lan].menu["type"], + default = billPrev, + options = { + { value = "cash", text = Loc[Config.Lan].menu["cash"] }, + { value = "bank", text = Loc[Config.Lan].menu["card"] } + } + } + newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = Loc[Config.Lan].menu["amount_charge"] } + + local dialog = createInput(img, newinputs) + + if dialog then + if dialog[1] then + dialog.citizen = dialog[1] + dialog.billtype = dialog[2] + dialog.price = dialog[3] + end + billPrev = dialog.billtype + TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype, data.img, outside, gang) + end +end) + +RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside) + local setimage = "" + if Config.System.Menu == "qb" then + setimage = "
" + elseif Config.System.Menu == "ox" then + setimage = '!['..''.. ']('..(img and img or "")..')' + end + + local Menu = {} + Menu[#Menu+1] = { + isMenuHeader = true, + header = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"], + txt = Loc[Config.Lan].menu["accept_payment"] + } + Menu[#Menu+1] = { + isMenuHeader = true, + header = "", + txt = billtype:gsub("^%l", string.upper)..Loc[Config.Lan].menu["payment_amount"]..amount + } + Menu[#Menu+1] = { + icon = "fas fa-circle-check", + header = Loc[Config.Lan].menu["yes"], + txt = "", + onSelect = function() + TriggerServerEvent("jim-payments:server:PayPopup", { + accept = true, + amount = amount, + biller = biller, + billtype = billtype, + outside = outside + }) + end, + } + Menu[#Menu+1] = { + icon = "fas fa-circle-xmark", + header = Loc[Config.Lan].menu["no"], + onSelect = function() + TriggerServerEvent("jim-payments:server:PayPopup", { + accept = false, + amount = amount, + biller = biller, + billtype = billtype, + outside = outside + }) + end, + } + openMenu(Menu, { + header = setimage, + onExit = function() + TriggerServerEvent("jim-payments:server:PayPopup", { + accept = false, + amount = amount, + biller = biller, + billtype = billtype, + outside = outside + }) + end, + }) +end) \ No newline at end of file diff --git a/client/client.lua b/client/client.lua index d5a24bc..b0758fe 100644 --- a/client/client.lua +++ b/client/client.lua @@ -1,28 +1,5 @@ -local QBCore = exports['qb-core']:GetCoreObject() -RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end) - -PlayerJob = {} -PlayerGang = {} - -local onDuty = false -local BankPed = nil -local Targets = {} -local Till = {} - -RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() QBCore.Functions.GetPlayerData(function(PlayerData) PlayerJob = PlayerData.job PlayerGang = PlayerData.gang end) end) -RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) PlayerJob = JobInfo onDuty = PlayerJob.onduty end) -RegisterNetEvent('QBCore:Client:SetDuty', function(duty) onDuty = duty end) -RegisterNetEvent('QBCore:Client:OnGangUpdate', function(GangInfo) PlayerGang = GangInfo end) - ---Keeps track of duty on script restarts -AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() ~= resource then return end - QBCore.Functions.GetPlayerData(function(PlayerData) - PlayerJob = PlayerData.job - PlayerGang = PlayerData.gang - onDuty = PlayerJob.onduty - end) -end) +--[[ CreateThread(function() local jobroles = {} local gangroles = {} --Build Job/Gang Checks for cashin location @@ -57,82 +34,12 @@ CreateThread(function() end end) -RegisterNetEvent('jim-payments:client:Charge', function(data, outside) - --Check if player is using /cashregister command - local dialog - if not outside and not onDuty and data.gang == nil then triggerNotify(nil, Loc[Config.Lan].error["not_onduty"], "error") return end - local newinputs = {} -- Begin qb-input creation here. - if Config.List then -- If nearby player list is wanted: - --Retrieve a list of nearby players from server - local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:MakePlayerList', function(cb) p:resolve(cb) end) - local onlineList = Citizen.Await(p) - local nearbyList = {} - --Convert list of players nearby into one qb-input understands + add distance info - for _, 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() or Config.Debug then - 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)' } - end - end - end - end - --If list is empty(no one nearby) show error and stop - if not nearbyList[1] then triggerNotify(nil, Loc[Config.Lan].error["no_one"], "error") return end - newinputs[#newinputs+1] = { text = " ", name = "citizen", label = Loc[Config.Lan].menu["cus_id"], type = "select", options = nearbyList } - else -- If Config.List is false, create input text box for ID's - if Config.Menu == "qb" then - newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = Loc[Config.Lan].menu["cus_id"] } - elseif Config.Menu == "ox" then - newinputs[#newinputs+1] = {type = 'input', required = true, name = 'citizen', label = Loc[Config.Lan].menu["cus_id"], text = Loc[Config.Lan].menu["cus_id"]} - end - end - --Check if image was given when opening the regsiter - local img = data.img or "" - --Continue adding payment options to qb-input - if Config.Menu == "qb" then - newinputs[#newinputs+1] = { type = 'radio', name = 'billtype', text = Loc[Config.Lan].menu["type"], options = { { value = "cash", text = Loc[Config.Lan].menu["cash"] }, { value = "bank", text = Loc[Config.Lan].menu["card"] } } } - elseif Config.Menu == "ox" then - newinputs[#newinputs+1] = {type = 'select', - options = { - { value = 'cash', label = "Cash" }, - { value = 'bank', label = "Bank" } - }, - required = true, - label = "Payment Type" - } - end - if Config.Menu == "qb" then - newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = Loc[Config.Lan].menu["amount_charge"] } - elseif Config.Menu == "ox" then - newinputs[#newinputs+1] = {type = 'number', required = true, label = Loc[Config.Lan].menu["amount_charge"], text = Loc[Config.Lan].menu["amount_charge"] } - end - --Grab Player Job name or Gang Name if needed - local label = PlayerJob.label - local gang = false - if data.gang then label = PlayerGang.label gang = true end - if Config.Menu == "qb" then - dialog = exports['qb-input']:ShowInput({ header = img..label..Loc[Config.Lan].menu["cash_reg"], submitText = Loc[Config.Lan].menu["send"], inputs = newinputs}) - elseif Config.Menu == "ox" then - dialog = exports.ox_lib:inputDialog(label..Loc[Config.Lan].menu["cash_reg"], newinputs) - end - if dialog then - local inputs = { - citizen = dialog.citizen or dialog[1], - price = dialog.price or dialog[3], - billtype = dialog.billtype or dialog[2], - } - if not inputs.citizen or not inputs.price then return end - TriggerServerEvent('jim-payments:server:Charge', inputs.citizen, inputs.price, inputs.billtype, data.img, outside, gang) - end -end) RegisterNetEvent('jim-payments:client:PolCharge', function() --Check if player is allowed to use /cashregister command local allowed = false for k in pairs(Config.FineJobs) do if k == PlayerJob.name then allowed = true end end - if not allowed then triggerNotify(nil, Loc[Config.Lan].error["no_job"], "error") return end + if not allowed then triggerNotify(nil, nil, Loc[Config.Lan].error["no_job"], "error") return end local newinputs = {} -- Begin qb-input creation here. if Config.FineJobList then -- If nearby player list is wanted: @@ -152,7 +59,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function() end end --If list is empty(no one nearby) show error and stop - if not nearbyList[1] then triggerNotify(nil, Loc[Config.Lan].error["no_one"], "error") return end + if not nearbyList[1] then triggerNotify(nil, nil, Loc[Config.Lan].error["no_one"], "error") return end newinputs[#newinputs+1] = { text = " ", name = "citizen", type = "select", options = nearbyList } else -- If Config.List is false, create input text box for ID's newinputs[#newinputs+1] = { type = 'text', isRequired = true, required = true, name = 'citizen', label = Loc[Config.Lan].menu["person_id"], text = Loc[Config.Lan].menu["person_id"] } @@ -166,7 +73,7 @@ RegisterNetEvent('jim-payments:client:PolCharge', function() --Grab Player Job name or Gang Name if needed local label = PlayerJob.label local gang = false - local dialog + local dialog if Config.Menu == "qb" then dialog = exports['qb-input']:ShowInput({ header = label..Loc[Config.Lan].menu["charge"], submitText = Loc[Config.Lan].menu["send"], inputs = newinputs}) elseif Config.Menu == "ox" then @@ -186,7 +93,7 @@ RegisterNetEvent('jim-payments:Tickets:Menu', function(data) --Get ticket info local p = promise.new() QBCore.Functions.TriggerCallback('jim-payments:Ticket:Count', function(cb) p:resolve(cb) end) local amount = Citizen.Await(p) - if not amount then triggerNotify(nil, Loc[Config.Lan].error["no_ticket"], "error") amount = 0 return else amount = amount.amount end + if not amount then triggerNotify(nil, nil, Loc[Config.Lan].error["no_ticket"], "error") amount = 0 return else amount = amount.amount end local sellable = false local name = "" local label = "" --Check/adjust for job/gang names @@ -241,13 +148,13 @@ RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billty title = Loc[Config.Lan].menu["yes"], icon = "fas fa-circle-check", serverEvent = "jim-payments:server:PayPopup", - args = { - accept = true, - amount = amount, - biller = biller, - billtype = billtype, - gang = gang, - outside = outside + args = { + accept = true, + amount = amount, + biller = biller, + billtype = billtype, + gang = gang, + outside = outside } }, { @@ -283,7 +190,7 @@ RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, biller {readOnly = true, title = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"], description = Loc[Config.Lan].menu["accept_charge"] }, { readOnly = true, title = "", description = Loc[Config.Lan].menu["bank_charge"]..amount }, { icon = "fas fa-circle-check", title = Loc[Config.Lan].menu["yes"], description = "", serverEvent = "jim-payments:server:PolPopup", args = { accept = true, amount = amount, biller = biller } }, - { icon = "fas fa-circle-xmark", title = Loc[Config.Lan].menu["no"], description = "", serverEvent = "jim-payments:server:PolPopup", args = { accept = false, amount = amount, biller = biller } }, + { icon = "fas fa-circle-xmark", title = Loc[Config.Lan].menu["no"], description = "", serverEvent = "jim-payments:server:PolPopup", args = { accept = false, amount = amount, biller = biller } }, } }) lib.showContext('polpopup') @@ -298,3 +205,5 @@ AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() t for i = 1, #Till do DeleteEntity(Till[i]) end unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed) end) + +]] \ No newline at end of file diff --git a/client/polcharge.lua b/client/polcharge.lua new file mode 100644 index 0000000..83ea894 --- /dev/null +++ b/client/polcharge.lua @@ -0,0 +1 @@ +-- wip \ No newline at end of file diff --git a/client/tickets.lua b/client/tickets.lua new file mode 100644 index 0000000..18d71ae --- /dev/null +++ b/client/tickets.lua @@ -0,0 +1,20 @@ +RegisterNetEvent('jim-payments:Tickets:Menu', function(data) + local hasItem, hasTable = hasItem("payticket", 1) + if not hasItem then triggerNotify(nil, Loc[Config.Lan].error["no_ticket"], "error") return end + local amount, sellable, name, label = hasTable["payticket"].count, false, "", "" + for k, v in pairs(Config.Receipts.Jobs) do + sellable = (data.gang and v.gang and k == PlayerGang.name) or (not data.gang and not v.gang and k == PlayerJob.name) + if sellable then name, label = k, (data.gang and PlayerGang.label) or (not data.gang and PlayerJob.label) break end + end + if sellable then local Menu = {} + Menu[#Menu+1] = { + isMenuHeader = true, + txt = Loc[Config.Lan].menu["ticket_amount"]..amount..Loc[Config.Lan].menu["total_pay"]..(Config.Receipts.Jobs[name].PayPerTicket * amount) + } + Menu[#Menu+1] = { + icon = "fas fa-circle-check", header = Loc[Config.Lan].menu["yes"], + onSelect = function() TriggerServerEvent('jim-payments:Tickets:Sell') end, + } + openMenu(Menu, { header = "🧾 "..label..Loc[Config.Lan].menu["receipt"], headertxt = Loc[Config.Lan].menu["trade_confirm"], canClose = true, }) + end +end) \ No newline at end of file diff --git a/config.lua b/config.lua index 4351fe1..f9eb4c6 100644 --- a/config.lua +++ b/config.lua @@ -1,4 +1,4 @@ -print("^2Jim^7-^2Payments ^7v^42^7.^48^7.^45 ^7- ^2Payments Script by ^1Jimathy^7") +print("^2Jim^7-^2Payments ^7v^4"..GetResourceMetadata(GetCurrentResourceName(), 'version', nil):gsub("%.", "^7.^4").."^7 - ^2Payments Script by ^1Jimathy^7") -- If you need support I now have a discord available, it helps me keep track of issues and give better support. @@ -6,282 +6,153 @@ print("^2Jim^7-^2Payments ^7v^42^7.^48^7.^45 ^7- ^2Payments Script by ^1Jimathy^ Config = { Lan = "en", - Debug = false, - Notify = "qb", -- "qb" | "okok" | "t" | "infinity" | "rr" - Menu = "ox", + System = { + Debug = true, - --------------------------------- - -- Default Job Payment Systems -- - --------------------------------- + Menu = "qb", -- "qb", "ox", "gta" + Notify = "gta", -- "qb", "ox", "gta", "esx" + ProgressBar = "gta", -- "qb", "ox", "gta", "esx" + }, - Banking = "qb-banking", - -- "qb-management" - This is for the older version of QBCore - -- "qb-banking" - This is for the latest QBCore updates + General = { + Banking = "qb-banking", + -- "qb-management" -- This is for the older version of QBCore + -- "qb-banking" -- This is for the latest QBCore updates -- "renewed" - -- "fd" - currently default supported - -- "okok" - make sure to add societies to Config.Societies in okokBanking, This is for the latest QBCore updates + -- "fd" -- currently default supported + -- "okok" -- make sure to add societies to Config.Societies in okokBanking, This is for the latest QBCore updates - ApGov = false, -- Toggle support for AP-Goverment Tax + ApGov = false, -- Toggle support for AP-Goverment Tax - List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry - PaymentRadius = 15, -- This is how far the playerlist will check for nearby players (based on the person charging) + List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry + PaymentRadius = 15, -- This is how far the playerlist will check for nearby players (based on the person charging) + + Usebzzz = false, -- enable if you're using the prop from bzzz + + Enablecommand = true, -- Enables the /cashregister command + + PhoneBank = false, -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices + -- This doesn't affect Cash payments as they by default use a confirmation window + -- This is helpful for phones that don't support invoices well + + Peds = true, -- "true" to enable peds spawning in banks + PedPool = { -- If Peds is true, use this pool of ped models to pick from + "IG_Bankman", + "U_M_M_BankMan", + "S_F_M_Shop_HIGH", + "S_M_M_HighSec_02", + "S_M_M_HighSec_03", + "S_M_M_HighSec_04", + "A_F_Y_Business_01", + "A_F_Y_Business_02", + "A_F_Y_Business_03", + "A_F_Y_Business_04", + "A_M_M_Business_01", + "A_M_Y_Business_02", + "A_M_Y_Business_03", + "U_F_M_CasinoShop_01", + }, + + PhoneType = "qb", -- Change this setting to make invoices work with your phone script [still testing this currently] + -- "qb" for qb-phone + -- "gks" for GKSPhone + + useBanks = false, -- Enable this to use my banking stuff + + BankBlips = false, -- Enable this if you disabled qb-banking and need bank locations + + Gabz = true, -- "true" to enable Gabz Bank locations + -- this corrects the ATM/Bank Cashier + Ticket Cash in locations + + menuLogo = "https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png", - Peds = true, -- "true" to enable peds spawning in banks - PedPool = { - `IG_Bankman`, - `U_M_M_BankMan`, - `S_F_M_Shop_HIGH`, - `S_M_M_HighSec_02`, - `S_M_M_HighSec_03`, - `S_M_M_HighSec_04`, - `A_F_Y_Business_01`, - `A_F_Y_Business_02`, - `A_F_Y_Business_03`, - `A_F_Y_Business_04`, - `A_M_M_Business_01`, - `A_M_Y_Business_02`, - `A_M_Y_Business_03`, - `U_F_M_CasinoShop_01`, }, - Usebzzz = false, -- enable if you're using the prop from bzzz - Enablecommand = true, -- Enables the cashregister command + ATMs = { + enable = true, + showBlips = true, - PhoneBank = false, -- Set this to false to use the popup payment system FOR CARD/BANK PAYMENTS instead of using phone invoices - -- This doesn't affect Cash payments as they by default use confirmation now - -- This is helpful for phones that don't support invoices well + ATMModels = { `prop_atm_01`, `prop_atm_02`, `prop_atm_03`, `prop_fleeca_atm`, `gabz_sm_pb_atmframe` }, - PhoneType = "qb", -- Change this setting to make invoices work with your phone script [still testing this currently] - -- "qb" for qb-phone - -- "gks"" for GKSPhone - - CashInLocation = vector4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank - - TicketSystem = true, -- Enable this if you want to use the ticket system false - TicketSystemAll = true, -- Enable this to give tickets to all workers clocked in - - Commission = true, -- Set this to true to enable Commissions and give the person charging a percentage of the total - CommissionAll = false, -- Set this to true to give commission to workers clocked in - CommissionDouble = false, -- Set this to true if you want the person charging to get double Commission - CommissionLimit = false, -- If true, this limits the Commission to only be given if over the "MinAmountForTicket". - -- If false, Commission will be given for any amount - - -- MinAmountforTicket should be your cheapest item - -- PayPerTicket should never be higher than MinAmountforTicket - -- Commission is a percentage eg "0.10" becomes 10% - Jobs = { - -- Jim Businesses | https://jimathy666.tebex.io/ - ['bakery'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['beanmachine'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 , Commission = 0.10, }, - ['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['upnatom'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['hornys'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - - -- JixelTay Businesses | https://jixeltay.tebex.io/ - ['cigarbar'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['cluckinbell'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['smokeshop'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['pearls'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['kois'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['whitewidow'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - ['bestbuds'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, - - -- Jim Mechanic | https://jimathy666.tebex.io/ - ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - ['tuners'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - ['ottos'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - ['lscustoms'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - ['bennys'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - - -- Gangs | Example of a gang being supported - ['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, }, - ------------------------------ - -- Custom Job Cash Register -- - ------------------------------ - -- This adds the ability to add multiple locations for each job - -- Basically adding ready made locations, all you need to a vector4 and to confrim if you need a new prop in that location - CustomCashRegisters = { - -- ["jobname"] = { -- Player job role restriction - -- { coords = vector4(0, 0, 0, 0), prop = true, }, -- vector4 to place the till and the way it faces - -- { coords = vector4(0, 0, 0, 0), prop = true, }, -- "prop = true" spawns a prop at the coords - -- }, + Banks = { + enable = true, + showBlips = true, + }, - -- The /polcharge command requires specific jobs to be set - -- No tickets for these, it's just commission (0.25 = 25%) - FineJobs = { - ['police'] = { Commission = 0.25, }, - ['ambulance'] = { Commission = 0.25, }, - }, - FineJobConfirmation = false, --"true" makes it so fines need confirmation, "false" skips this ands just removes the money - FineJobList = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry - - --------------------- - -- Banking Systems -- - --------------------- - useATM = false, -- Enable this to use the scripts ATM's and controls - useBanks = false, -- Enable this to use my banking stuff - BankBlips = false, -- Enable this if you disabled qb-banking and need bank locations - ATMBlips = false, -- Enable this if you are a pyscho and need every ATM to be on the map too - - Gabz = false, -- "true" to enable Gabz Bank locations - -- this corrects the ATM/Bank Cashier + Ticket Cash in location - - ATMModels = { `prop_atm_01`, `prop_atm_02`, `prop_atm_03`, `prop_fleeca_atm` }, - ATMLocations = { - --PACIFIC BANK 10 ATMS - vector3(265.9, 213.86, 106.28), - vector3(265.56, 212.98, 106.28), - vector3(265.19, 211.91, 106.28), - vector3(264.86, 211.03, 106.28), - vector3(264.52, 210.06, 106.28), - vector3(236.64, 219.72, 106.29), - vector3(237.04, 218.72, 106.29), - vector3(237.5, 217.87, 106.29), - vector3(237.93, 216.94, 106.29), - vector3(238.36, 216.03, 106.29), - }, - --QB-Target doesn't seem to like ALL ATM Props so need to manually add locations - WallATMLocations = { - vector3(-386.54, 6046.29, 31.5), - vector3(-282.82, 6226.24, 31.49), - vector3(-132.74, 6366.79, 31.48), - vector3(-95.76, 6457.41, 31.46), - vector3(-97.52, 6455.65, 31.47), - vector3(155.95, 6642.99, 31.6), - vector3(173.92, 6638.16, 31.57), - vector3(2558.65, 350.92, 108.62), - vector3(1077.78, -776.64, 58.35), - vector3(1138.14, -468.88, 66.73), - vector3(1166.93, -455.96, 66.81), - vector3(285.37, 143.07, 104.17), - vector3(-165.43, 234.81, 94.92), - vector3(-165.4, 232.73, 94.92), - vector3(-1410.41, -98.76, 52.43), - vector3(-1409.85, -100.51, 52.38), - vector3(-1206.0, -324.94, 37.86), - vector3(-1205.23, -326.55, 37.86), - vector3(-2072.28, -317.27, 13.32), - vector3(-2974.7, 380.15, 15.0), - vector3(-2959.01, 487.45, 15.46), - vector3(-2956.87, 487.36, 15.46), - vector3(-3043.98, 594.32, 7.74), - vector3(-3241.35, 997.74, 12.55), - vector3(-1305.59, -706.64, 25.32), - vector3(-537.85, -854.69, 29.28), - vector3(-709.98, -818.71, 23.73), - vector3(-712.87, -818.71, 23.73), - vector3(-526.71, -1223.18, 18.45), - vector3(-256.47, -715.94, 33.55), - vector3(-259.13, -723.29, 33.54), - vector3(-203.82, -861.3, 30.27), - vector3(111.38, -774.96, 31.44), - vector3(114.56, -776.13, 31.42), - vector3(112.46, -819.65, 31.34), - vector3(118.93, -883.68, 31.12), - vector3(-846.97, -340.29, 38.68), - vector3(-846.41, -341.41, 38.68), - vector3(-262.21, -2012.17, 30.15), - vector3(-273.23, -2024.32, 30.15), - vector3(24.46, -945.94, 29.36), - vector3(-254.48, -692.74, 33.61), - vector3(-1569.95, -546.94, 34.96), - vector3(-1570.91, -547.63, 34.96), - vector3(289.14, -1282.29, 29.6), - vector3(289.18, -1256.84, 29.44), - vector3(296.04, -896.22, 29.24), - vector3(296.74, -894.26, 29.24), - vector3(-301.63, -829.73, 32.43), - vector3(-303.23, -829.44, 32.43), - vector3(5.27, -919.87, 29.56), - vector3(-1200.61, -885.62, 13.26), + CustomCashRegisters = { + -- ["jobname"] = { -- Player job role restriction + -- { coords = vector4(0, 0, 0, 0), }, -- vector4 to place the till and the way it faces + -- { coords = vector4(0, 0, 0, 0), prop = true, }, -- "prop = true" spawns a prop at the coords + -- }, }, - BankLocations = { - ["legion"] = { - vector4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca + Receipts = { + TicketSystem = true, -- Enable this if you want to use the ticket system false + TicketSystemAll = true, -- Enable this to give tickets to all workers clocked in + + Commission = true, -- Set this to true to enable Commissions and give the person charging a percentage of the total + CommissionAll = false, -- Set this to true to give commission to workers clocked in + CommissionDouble = false, -- Set this to true if you want the person charging to get double Commission + CommissionLimit = false, -- If true, this limits the Commission to only be given if over the "MinAmountForTicket". + -- If false, Commission will be given for any amount + + CashInLocations = { + vec4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank }, - ["hawick"] = { - vector4(313.81, -280.43, 54.16, 342.29), -- Hawick Fleeca + + CashInAnywhere = true, + + -- MinAmountforTicket should be your cheapest item + -- PayPerTicket should never be higher than MinAmountforTicket + -- Commission is a percentage eg "0.10" becomes 10% + Jobs = { + -- Jim Businesses | https://jimathy666.tebex.io/ + ['bakery'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['beanmachine'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['burgershot'] = { MinAmountforTicket = 50, PayPerTicket = 50 , Commission = 0.10, }, + ['catcafe'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['henhouse'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['pizzathis'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['popsdiner'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['upnatom'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['hornys'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + + -- JixelTay Businesses | https://jixeltay.tebex.io/ + ['cigarbar'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['cluckinbell'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['smokeshop'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['pearls'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['kois'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['whitewidow'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + ['bestbuds'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, + + -- Jim Mechanic | https://jimathy666.tebex.io/ + ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, + ['tuners'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, + ['ottos'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, + ['lscustoms'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, + ['bennys'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, + + -- Gangs | Example of a gang being supported + ['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, }, - ["vinewood"] = { - vector4(-351.4, -51.24, 49.04, 338.4), -- Vinewood Fleeca - }, - ["delperro"] = { - vector4(-1212.11, -332.01, 37.78, 25.33), -- Del Perro Fleeca - }, - ["route1"] = { - vector4(-2961.17, 482.9, 15.7, 84.68), -- Route 1 Fleeca - }, - ["route68"] = { - vector4(1175.03, 2708.2, 38.09, 180.0), -- Route 68 Fleeca - }, - ["paleto"] = { - vector4(-111.22, 6470.03, 31.63, 133.86), -- Paleto Bank - }, - ["pacific"] = { - vector4(243.58, 226.25, 106.29, 169.06), -- Pacific Bank Window 1 - vector4(247.08, 224.98, 106.29, 157.75), -- Pacific Bank Window 2 + + }, + PolCharge = { + -- The /polcharge command requires specific jobs to be set + -- No tickets for these, it's just commission (0.25 = 25%) + FineJobs = { + ['police'] = { Commission = 0.25, }, + ['ambulance'] = { Commission = 0.25, }, }, + FineJobConfirmation = false, --"true" makes it so fines need confirmation, "false" skips this ands just removes the money + FineJobList = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry }, } --- If Gabz banks enabled, load these locations instead -if Config.Gabz then - Config.CashInLocation = vector4(269.28, 217.24, 106.28, 69.0) - Config.BankLocations = { - ["legion"] = { - vector4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca - }, - ["hawick"] = { - vector4(313.81, -280.43, 54.16, 342.29), -- Hawick Fleeca - }, - ["vinewood"] = { - vector4(-351.4, -51.24, 49.04, 338.4), -- Vinewood Fleeca - }, - ["delperro"] = { - vector4(-1212.11, -332.01, 37.78, 25.33), -- Del Perro Fleeca - }, - ["route1"] = { - vector4(-2961.17, 482.9, 15.7, 84.68), -- Route 1 Fleeca - }, - ["route68"] = { - vector4(1175.03, 2708.2, 38.09, 180.0), -- Route 68 Fleeca - }, - ["paleto"] = { - vector4(-110.72, 6469.82, 31.63, 222.94), -- Paleto Bank (GABZ) - 1 - vector4(-108.98, 6471.56, 31.63, 222.92), -- Paleto Bank (GABZ) - 2 - }, - ["pacific"] = { - vector4(258.55, 227.63, 106.28, 160.96), -- Pacficic Gabz 1+2 - vector4(263.21, 225.93, 106.28, 158.25), -- Pacficic Gabz 3+4 - vector4(267.95, 224.24, 106.28, 158.5), -- Pacficic Gabz 5+6 - vector4(263.71, 212.63, 106.28, 337.53), -- Pacficic Gabz 7+8 - vector4(259.02, 214.32, 106.28, 337.82), -- Pacficic Gabz 9+10 - vector4(254.27, 216.06, 106.28, 336.37), -- Pacficic Gabz 11+12 - }, - } - Config.ATMLocations = { - vector3(239.02, 212.37, 106.28), - vector3(239.46, 213.6, 106.28), - vector3(239.9, 214.82, 106.28), - vector3(240.35, 216.03, 106.28), - vector3(241.42, 218.96, 106.28), - vector3(241.86, 220.16, 106.28), - vector3(242.3, 221.41, 106.28), - vector3(242.76, 222.63, 106.28), - vector3(263.46, 203.86, 106.28), - vector3(263.96, 205.03, 106.28), - vector3(264.37, 206.28, 106.28), - vector3(264.77, 207.51, 106.28), - } -end -Loc = {} +PlayerGang, PlayerJob, onDuty = {}, {}, nil \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 1ba523c..1defdba 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,12 +1,40 @@ name "Jim-Payments" author "Jimathy" -version "v2.8.7" +version "3.0" description "Payment Script By Jimathy" fx_version "cerulean" game "gta5" lua54 'yes' -shared_scripts { 'config.lua', 'shared/*.lua', 'locales/*.lua' } -client_scripts { 'client/*.lua', } -server_scripts { '@oxmysql/lib/MySQL.lua', 'server/*.lua' } -shared_scripts { '@ox_lib/init.lua','config.lua', 'shared/*.lua', 'locales/*.lua' } +server_script '@oxmysql/lib/MySQL.lua' + +shared_scripts { + 'locales/*.lua', + 'config.lua', + + -- Required core scripts + '@ox_lib/init.lua', + '@ox_core/imports/client.lua', + '@es_extended/imports.lua', + '@qbx_core/modules/playerdata.lua', + + --Jim Bridge + '@jim_bridge/exports.lua', + '@jim_bridge/functions.lua', + '@jim_bridge/wrapper.lua', + '@jim_bridge/crafting.lua', + 'shared/*.lua', +} +client_scripts { + '@PolyZone/client.lua', + '@PolyZone/BoxZone.lua', + '@PolyZone/EntityZone.lua', + '@PolyZone/CircleZone.lua', + '@PolyZone/ComboZone.lua', + + 'client/*.lua', +} + +server_script 'server/*.lua' + +dependency 'jim_bridge' \ No newline at end of file diff --git a/locales/da.lua b/locales/da.lua index d7f747a..4a15d42 100644 --- a/locales/da.lua +++ b/locales/da.lua @@ -1,4 +1,6 @@ -- Provided by iplayer1337fivem on Github +Loc = Loc or {} + Loc["da"] = { error = { ["cancel"] = "Afbestilt", @@ -95,21 +97,20 @@ Loc["da"] = { ["acc_boss_trans"] = "Adgang til society-overførsler", ["acc_gang"] = "Adgang til gang-society-konto", ["acc_gang_trans"] = "Adgang til gangoverførsler", - ["header_soc"] = "

- Society-konto -
", - ["header_balance"] = "

- Balancer -
🏢", + ["header_soc"] = "- Society-konto -", ["header_soc_bank"] = "🏢 Society Bank 🏢", ["amount_pay"] = "💵 Beløb at betale", ["give_cash"] = "Giv nogen kontanter", ["give"] = "Giv", ["welcome"] = "Velkommen tilbage, ", - ["citizenid"] = "

- Borger-ID -
", - ["header_acc"] = "

- Konto -
", - ["header_info"] = "

- Kontoinformation -
Opsparings-ID: ", - ["header_balance_bank"] = "

- Balancer -
🏦Bank - DKK", - ["header_option"] = "

- Valg -", - ["cash_balance"] = "
💵Kontanter - DKK", - ["bank_balance"] = "
🏦Bank - DKK", - ["saving_balance"] = "

- Balancer -
💰Opsparing - DKK", + ["citizenid"] = "- Borger-ID -", + ["header_acc"] = "- Konto -", + ["header_info"] = "- Kontoinformation -Opsparings-ID: ", + ["header_balance_bank"] = "- Balancer -🏦Bank - DKK", + ["header_option"] = "- Valg -", + ["cash_balance"] = "💵Kontanter - DKK", + ["bank_balance"] = "🏦Bank - DKK", + ["saving_balance"] = "- Balancer -💰Opsparing - DKK", ["cus_id"] = "# Kundens ID #", ["type"] = "Betalingstype", ["amount_charge"] = "💵 Beløb at opkræve", @@ -123,7 +124,8 @@ Loc["da"] = { ["accept_payment"] = "Vil du acceptere betalingen?", ["accept_charge"] = "Vil du acceptere opkrævningen?", ["ticket_amount"] = "Antal billetter: ", - ["total_pay"] = "
Total betaling: DKK", + ["total_pay"] = "Total betaling: DKK", + ["confirm"] = "Ja", ["yes"] = "Ja", ["no"] = "Nej", ["cash"] = "Kontanter", diff --git a/locales/de.lua b/locales/de.lua index 150ad79..b257906 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,3 +1,5 @@ +Loc = Loc or {} + Loc["de"] = { error = { ["cancel"] = "Abgebrochen", @@ -94,21 +96,20 @@ Loc["de"] = { ["acc_boss_trans"] = "Zugang zu Firmenkontotransfers", ["acc_gang"] = "Zugriff auf das Gangkonto", ["acc_gang_trans"] = "Zugang zu Gangkontotransfers", - ["header_soc"] = "

- Firmenkonto -
", - ["header_balance"] = "

- Kontostand -
🏢", + ["header_soc"] = "- Firmenkonto -", ["header_soc_bank"] = "🏢 Firmen Banking 🏢", ["amount_pay"] = "💵 Zu zahlender Betrag'", ["give_cash"] = "Jemandem Bargeld geben", ["give"] = "Geben", ["welcome"] = "Willkommen zurück, ", - ["citizenid"] = "

- Ausweisnummer -
", - ["header_acc"] = "

- Konto -
", - ["header_info"] = "

- Konto Info -
Ersparnis-ID: ", - ["header_balance_bank"] = "

- Kontostand -
🏦Bank - $", - ["header_option"] = "

- Optionen -", - ["cash_balance"] = "
💵Bargeld - $", - ["bank_balance"] = "
🏦Bank - $", - ["saving_balance"] = "

- Kontostand -
💰Ersparnisses - $", + ["citizenid"] = "- Ausweisnummer -", + ["header_acc"] = "- Konto -", + ["header_info"] = "- Konto Info -Ersparnis-ID: ", + ["header_balance_bank"] = "- Kontostand -🏦Bank - $", + ["header_option"] = "- Optionen -", + ["cash_balance"] = "💵Bargeld - $", + ["bank_balance"] = "🏦Bank - $", + ["saving_balance"] = "- Kontostand -💰Ersparnisses - $", ["cus_id"] = "# Kunden ID #", ["type"] = "Zahlungsart", ["amount_charge"] = "💵 Zu berechnender Betrag", @@ -122,7 +123,8 @@ Loc["de"] = { ["accept_payment"] = "Möchten Sie die Zahlung akzeptieren?", ["accept_charge"] = "Möchten Sie die Gebühr akzeptieren?", ["ticket_amount"] = "Anzahl der Tickets: ", - ["total_pay"] = "
Gesamte Zahlung: $", + ["total_pay"] = "Gesamte Zahlung: $", + ["confirm"] = "Ja", ["yes"] = "Ja", ["no"] = "Nein", ["cash"] = "Bargeld", @@ -130,4 +132,4 @@ Loc["de"] = { ["payment_amount"] = " Zahlung: $", ["bank_charge"] = "Bankgebühr: $", }, -} +} diff --git a/locales/en.lua b/locales/en.lua index 34c9cf6..a583d79 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,3 +1,5 @@ +Loc = Loc or {} + Loc["en"] = { error = { ["cancel"] = "Cancelled", @@ -76,7 +78,7 @@ Loc["en"] = { }, menu = { ["close"] = "Close", - ["withdraw"] = "Withdrawl", + ["withdraw"] = "Withdrawal", ["deposit"] = "Deposit", ["transfer"] = "Transfer", ["transfer_money"] = "Transfer Money", @@ -94,21 +96,20 @@ Loc["en"] = { ["acc_boss_trans"] = "Accessing Society Transfers", ["acc_gang"] = "Accessing Gang Society Account", ["acc_gang_trans"] = "Accessing Gang Transfers", - ["header_soc"] = "

- Society Account -
", - ["header_balance"] = "

- Balances -
🏢", - ["header_soc_bank"] = "🏢 Society Banking 🏢", + ["header_soc"] = "Society Account -", + ["header_soc_bank"] = "Society Banking", ["amount_pay"] = "💵 Amount to Pay'", ["give_cash"] = "Give someone cash", ["give"] = "Give", ["welcome"] = "Welcome back, ", - ["citizenid"] = "

- Citizen ID -
", - ["header_acc"] = "

- Account -
", - ["header_info"] = "

- Account Info -
Savings ID: ", - ["header_balance_bank"] = "

- Balances -
🏦Bank - $", - ["header_option"] = "

- Options -", - ["cash_balance"] = "
💵Cash - $", - ["bank_balance"] = "
🏦Bank - $", - ["saving_balance"] = "

- Balances -
💰Savings - $", + ["citizenid"] = "Citizen ID -", + ["header_acc"] = "Account -", + ["header_info"] = "Account Info - Savings ID: ", + ["header_balance"] = "Balances -", + ["header_option"] = "Options -", + ["cash_balance"] = "💵Cash - $", + ["bank_balance"] = "🏦Bank - $", + ["saving_balance"] = "💰Savings - $", ["cus_id"] = "# Customer ID #", ["type"] = "Payment Type", ["amount_charge"] = "💵 Amount to Charge", @@ -123,6 +124,7 @@ Loc["en"] = { ["accept_charge"] = "Do you want accept the charge?", ["ticket_amount"] = "Amount of Tickets: ", ["total_pay"] = "
Total Payment: $", + ["confirm"] = "Confirm", ["yes"] = "Yes", ["no"] = "No", ["cash"] = "Cash", @@ -130,4 +132,4 @@ Loc["en"] = { ["payment_amount"] = " Payment: $", ["bank_charge"] = "Bank Charge: $", }, -} +} \ No newline at end of file diff --git a/server/atmserver.lua b/server/atmserver.lua index 5347748..66d39a8 100644 --- a/server/atmserver.lua +++ b/server/atmserver.lua @@ -1,17 +1,6 @@ -local function cv(amount) - local formatted = amount - while true do - formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') - if (k==0) then - break - end - end - return formatted -end - RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety) local src = source - local Player = QBCore.Functions.GetPlayer(src) + local Player = Core.Functions.GetPlayer(src) local cashB = Player.Functions.GetMoney("cash") local bankB = Player.Functions.GetMoney("bank") local amount = tonumber(amount) @@ -95,12 +84,12 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba baccount = newiban amount = tonumber(newAmount) - local Player = QBCore.Functions.GetPlayer(src) + local Player = Core.Functions.GetPlayer(src) if (society - amount) >= 0 then local query = '%"account":"' .. baccount .. '"%' local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query}) if result[1] then - local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) + local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid) if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount) elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount) elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount) @@ -153,12 +142,12 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba baccount = newiban amount = tonumber(newAmount) - local Player = QBCore.Functions.GetPlayer(src) + local Player = Core.Functions.GetPlayer(src) if (gsociety - amount) >= 0 then local query = '%"account":"' .. baccount .. '"%' local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query}) if result[1] then - local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) + local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid) if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.gang.name), amount) elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) @@ -188,12 +177,12 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba baccount = newiban amount = tonumber(newAmount) - local Player = QBCore.Functions.GetPlayer(src) + local Player = Core.Functions.GetPlayer(src) if (Player.PlayerData.money.bank - amount) >= 0 then local query = '%"account":"' .. baccount .. '"%' local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query}) if result[1] then - local Reciever = QBCore.Functions.GetPlayerByCitizenId(result[1].citizenid) + local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid) Player.Functions.RemoveMoney('bank', amount) if Reciever then Reciever.Functions.AddMoney('bank', amount) @@ -211,8 +200,8 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba end end) -QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb) - local Player = QBCore.Functions.GetPlayer(source) +createCallback('jim-payments:GetInfo', function(source, cb) + local Player = Core.Functions.GetPlayer(source) local name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname local cid = Player.PlayerData.citizenid.." ["..source.."]" local cash = Player.Functions.GetMoney("cash") @@ -221,7 +210,7 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb) local society = 0 local gsociety = 0 - if Config.Banking == "qb-banking" then + if Config.General.Banking == "qb-banking" then local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts') for _, v in pairs(result) do if Player.PlayerData.job.name == v.account_name then society = v.account_balance end @@ -233,7 +222,7 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb) end -- If qb-management, grab info directly from database - elseif not Config.Banking == "renewed" then + elseif not Config.General.Banking == "renewed" then local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds') for _, v in pairs(result) do if Player.PlayerData.job.name == v.job_name then society = v.amount end @@ -257,22 +246,24 @@ QBCore.Functions.CreateCallback('jim-payments:ATM:Find', function(source, cb) accountID = result[1].citizenid savingBalance = result[1].account_balance end - cb({name = name, - cash = cash, - bank = bank, - account = account, - cid = cid, - savbal = savingBalance, - aid = accountID, - society = society, - gsociety = gsociety}) + local retTable = {name = name, + cash = cash, + bank = bank, + account = account, + cid = cid, + savbal = savingBalance, + aid = accountID, + society = society, + gsociety = gsociety} + if GetResourceState(OXLibExport):find("start") then return retTable + else return cb(retTable) end end) -QBCore.Commands.Add("cashgive", Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end) +Core.Commands.Add("cashgive", Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end) RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price) - local Player = QBCore.Functions.GetPlayer(source) - local Reciever = QBCore.Functions.GetPlayer(tonumber(citizen)) + local Player = Core.Functions.GetPlayer(source) + local Reciever = Core.Functions.GetPlayer(tonumber(citizen)) local amount = tonumber(price) local balance = Player.Functions.GetMoney("cash") diff --git a/server/chargerserver.lua b/server/chargerserver.lua new file mode 100644 index 0000000..b4d14b4 --- /dev/null +++ b/server/chargerserver.lua @@ -0,0 +1,214 @@ +AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end + for k in pairs(Config.Receipts.Jobs) do + if not Jobs[k] and not Gangs[k] then + print("Jim-Payments: Config.Receipts.Jobs searched for job/gang '"..k.."' and couldn't find it in the Shared") + end + end +end) + +registerCommand("cashregister", { Loc[Config.Lan].command["cash_reg"], {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, {}, true) end }) + +createCallback('jim-payments:MakePlayerList', function(source, cb) + local onlineList = {} + for _, v in pairs(Core.Functions.GetPlayers()) do + local Player = getPlayer(v) + onlineList[#onlineList+1] = { + value = tonumber(v), + text = "["..v.."] - "..Player.name + } + end + if GetResourceState(OXLibExport):find("start") then return onlineList + else cb(onlineList) end +end) + +RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang) + print(citizen, price, billtype, img, outside, gang) + local src = source + local biller = Core.Functions.GetPlayer(src) + local billed = Core.Functions.GetPlayer(tonumber(citizen)) + local amount = tonumber(price) + local balance = billed.Functions.GetMoney(billtype) + if amount and amount > 0 then + if balance < amount then + triggerNotify(nil, Loc[Config.Lan].error["customer_nocash"], "error", src) + triggerNotify(nil, Loc[Config.Lan].error["you_nocash"], "error", tonumber(citizen)) + return + end + local label = biller.PlayerData.job.label + if gang == true then label = biller.PlayerData.gang.label end + if Config.General.PhoneBank == false or gang == true or billtype == "cash" then + TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img, label, gang, outside) + else + if Config.General.PhoneType == "qb" then + MySQL.Async.insert( + 'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)', + {billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid}, function(id) + if id then + TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.PlayerData.source, id, biller.PlayerData.charinfo.firstname, biller.PlayerData.job.name, biller.PlayerData.citizenid, amount, GetInvokingResource()) + end + end) + TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source) + elseif Config.General.PhoneType == "gks" then + MySQL.Async.execute('INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', { + ['@citizenid'] = billed.PlayerData.citizenid, + ['@amount'] = amount, + ['@society'] = biller.PlayerData.job.name, + ['@sender'] = biller.PlayerData.charinfo.firstname, + ['@sendercitizenid'] = biller.PlayerData.citizenid, + ['@label'] = biller.PlayerData.job.label, + }) + TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = Loc[Config.Lan].success["inv_succ"], img= '/html/static/img/icons/logo.png' }) + TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' }) + end + triggerNotify(nil, Loc[Config.Lan].success["inv_succ"], 'success', src) + triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.PlayerData.source) + end + else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end +end) + +RegisterServerEvent("jim-payments:server:PayPopup", function(data) + local src = source + local billed = Core.Functions.GetPlayer(src) + local biller = Core.Functions.GetPlayer(tonumber(data.biller)) + local newdata = { + senderCitizenId = biller.PlayerData.citizenid, + society = data.gang and biller.PlayerData.gang.name or biller.PlayerData.job.name, + amount = data.amount + } + if data.accept then + billed.Functions.RemoveMoney(tostring(data.billtype), data.amount) + if Config.General.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", data.amount) end + TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang) + triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller) + elseif not data.accept then + triggerNotify(nil, Loc[Config.Lan].success["declined"], "error", src) + triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller) + end +end) + +RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang) local src = source + local billed = Core.Functions.GetPlayer(src) -- This should always be from the person who accepted the payment + local takecomm = math.floor(data.amount * Config.Receipts.Jobs[data.society].Commission) + if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here + local billerGang, billerJob, amountChange, newAmount = tostring(biller.PlayerData.gang.name), tostring(biller.PlayerData.job.name), (data.amount - takecomm), 0 + + if gang then + if Config.General.Banking == "renewed" then + exports['Renewed-Banking']:addAccountMoney(billerGang, amountChange) + newAmount = exports['Renewed-Banking']:getAccountMoney(billerGang) + + elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then + exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange) + newAmount = exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange) + if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end + + elseif Config.General.Banking == "fd" then + exports["fd_banking"]:AddGangMoney(billerGang, amountChange) + newAmount = exports["fd_banking"]:GetGangAccount(billerGang) + + elseif Config.General.Banking == "okok" then + exports['okokBanking']:AddMoney(billerGang, amountChange) + newAmount = exports['okokBanking']:GetAccount(billerGang) + end + elseif not gang then + if Config.General.Banking == "renewed" then + exports['Renewed-Banking']:addAccountMoney(billerJob, amountChange) + newAmount = exports['Renewed-Banking']:getAccountMoney(billerJob) + + elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then + exports[Config.General.Banking]:AddMoney(billerJob, amountChange) + newAmount = exports[Config.General.Banking]:GetAccount(billerJob, amountChange) + if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end + + elseif Config.General.Banking == "fd" then + exports["fd_banking"]:AddMoney(billerJob, amountChange) + newAmount = exports["fd_banking"]:GetAccount(billerJob) + + elseif Config.General.Banking == "okok" then + exports['okokBanking']:AddMoney(billerJob, amountChange) + newAmount = exports['okokBanking']:GetAccount(billerJob) + end + + end + print("^5Debug^7: ^3"..Config.General.Banking.."^7(^3"..(gang and "Gang" or "Job").."^7): ^2Adding ^7$"..amountChange.." ^2to account ^7'^6"..(gang and billerGang or billerJob).."^7' ($"..newAmount..")") + if Config.System.Debug then + end + elseif not biller then --Find the biller from their citizenid + for _, v in pairs(Core.Functions.GetPlayers()) do + local Player = Core.Functions.GetPlayer(v) + if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end + end + triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.PlayerData.source) + end + + -- If ticket system enabled, do this + if (biller.PlayerData.job.onduty or gang) and Config.Receipts.TicketSystem then + if data.amount >= Config.Receipts.Jobs[data.society].MinAmountforTicket then + if Config.Receipts.TicketSystemAll then + for _, v in pairs(Core.Functions.GetPlayers()) do + local Player = Core.Functions.GetPlayer(v) + if Player ~= nil or Player ~= billed then + if gang then + if Player.PlayerData.gang.name == data.society then + TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source) + triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source) + end + else + if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then + TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source) + triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source) + end + end + end + end + else + TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, biller.PlayerData.source) + triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.PlayerData.source) + end + end + end + + -- Commission section, does each config option separately + local comm = tonumber(Config.Receipts.Jobs[data.society].Commission) + if Config.Receipts.Commission and comm ~= 0 then + if Config.Receipts.CommissionLimit and data.amount < Config.Receipts.Jobs[data.society].MinAmountforTicket then return end + if Config.Receipts.CommissionDouble then + biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2))) + triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source) + else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm)) + triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source) + end + if Config.Receipts.CommissionAll then + for _, v in pairs(Core.Functions.GetPlayers()) do + local Player = Core.Functions.GetPlayer(v) + if Player and Player ~= biller then + if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then + Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm)) + triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.PlayerData.source) + end + end + end + end + end +end) + +RegisterServerEvent('jim-payments:Tickets:Sell', function() + local Player = Core.Functions.GetPlayer(source) + if not Player.Functions.GetItemByName("payticket") then triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', source) return + else + tickets = Player.Functions.GetItemByName("payticket").amount + Player.Functions.RemoveItem('payticket', tickets) + pay = (tickets * Config.Receipts.Jobs[Player.PlayerData.job.name].PayPerTicket) + Player.Functions.AddMoney('bank', pay, 'ticket-payment') + TriggerClientEvent('inventory:client:ItemBox', source, Core.Shared.Items['payticket'], "remove", tickets) + triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', source) + end +end) + +CreateThread(function() + if Config.Usebzzz then + Core.Functions.CreateUseableItem('terminal', function(source, item) + TriggerClientEvent("jim-payments:client:Charge", source, {}, true) + end) + end +end) \ No newline at end of file diff --git a/server/polchargeserver.lua b/server/polchargeserver.lua new file mode 100644 index 0000000..e6dec08 --- /dev/null +++ b/server/polchargeserver.lua @@ -0,0 +1 @@ +-- Wip \ No newline at end of file diff --git a/server/server.lua b/server/server.lua deleted file mode 100644 index 66e25e2..0000000 --- a/server/server.lua +++ /dev/null @@ -1,289 +0,0 @@ - -local function cv(amount) - local formatted = amount - while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end - return formatted -end - -AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() ~= resource then return end - for k in pairs(Config.Jobs) do - if not QBCore.Shared.Jobs[k] and not QBCore.Shared.Gangs[k] then - print("Jim-Payments: Config.Jobs searched for job/gang '"..k.."' and couldn't find it in the Shared") - end - end -end) - - -CreateThread(function() - if Config.Enablecommand then - QBCore.Commands.Add("cashregister", Loc[Config.Lan].command["cash_reg"], {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, {}, true) end) - end -end) - -QBCore.Commands.Add("polcharge", Loc[Config.Lan].command["charge"], {}, false, function(source) TriggerClientEvent("jim-payments:client:PolCharge", source) end) - -RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang) - local billed = QBCore.Functions.GetPlayer(source) -- This should always be from the person who accepted the payment - local takecomm = math.floor(tonumber(data.amount) * Config.Jobs[data.society].Commission) - if biller then -- If this is found, it ISN'T a phone payment, so add money to society here - if gang then - if Config.Banking == "renewed" then - exports['Renewed-Banking']:addAccountMoney(tostring(biller.PlayerData.gang.name), data.amount - takecomm) - if Config.Debug then - print("^5Debug^7: ^3Renewed-Banking^7(^3Gang^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports['Renewed-Banking']:getAccountMoney(biller.PlayerData.gang.name).."^7)") end - elseif Config.Banking == "qb-management" then - exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Gang^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports["qb-management"]:GetGangAccount(biller.PlayerData.gang.name).."^7)") end - elseif Config.Banking == "qb-banking" then - exports["qb-banking"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3QB-Banking^7(^3Gang^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports["qb-banking"]:GetGangAccount(biller.PlayerData.gang.name).."^7)") end - elseif Config.Banking == "fd" then - exports.fd_banking:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3FD-Banking^7(^3Gang^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7' ($^6"..exports.fd_banking:GetGangAccount(biller.PlayerData.gang.name).."^7)") end - elseif Config.Banking == "okok" then - exports['okokBanking']:AddMoney(tostring(biller.PlayerData.gang.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3okokBanking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['okokBanking']:GetAccount(biller.PlayerData.gang.name).."^7)") end - end - elseif not gang then - if Config.Banking == "renewed" - then exports['Renewed-Banking']:addAccountMoney(tostring(biller.PlayerData.job.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3Renewed-Banking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..tostring(exports['Renewed-Banking']:getAccountMoney(biller.PlayerData.job.name)).."^7)") end - elseif Config.Banking == "qb-management" then - exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "qb-banking" then - exports["qb-banking"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3QB-Banking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6^7)") end - elseif Config.Banking == "fd" then - exports.fd_banking:AddMoney(tostring(biller.PlayerData.job.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3FD-Banking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports.fd_banking:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "okok" then - exports['okokBanking']:AddMoney(tostring(biller.PlayerData.job.name), data.amount - takecomm) - if Config.Debug then print("^5Debug^7: ^3okokBanking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['okokBanking']:GetAccount(biller.PlayerData.job.name).."^7)") end - end - end - elseif not biller then --Find the biller from their citizenid - for _, v in pairs(QBCore.Functions.GetPlayers()) do - local Player = QBCore.Functions.GetPlayer(v) - if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end - end - triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.PlayerData.source) - end - - -- If ticket system enabled, do this - if (biller.PlayerData.job.onduty or gang) and Config.TicketSystem then - if data.amount >= Config.Jobs[data.society].MinAmountforTicket then - if Config.TicketSystemAll then - for _, v in pairs(QBCore.Functions.GetPlayers()) do - local Player = QBCore.Functions.GetPlayer(v) - if Player ~= nil or Player ~= billed then - if gang then - if Player.PlayerData.gang.name == data.society then - if Player.Functions.AddItem('payticket', 1) then TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) end - triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source) - end - else - if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then - if Player.Functions.AddItem('payticket', 1) then TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) end - triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source) - end - end - end - end - else - if biller.Functions.AddItem('payticket', 1) then TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) end - triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.PlayerData.source) - end - end - end - - -- Commission section, does each config option separately - local comm = tonumber(Config.Jobs[data.society].Commission) - if Config.Commission and comm ~= 0 then - if Config.CommissionLimit and data.amount < Config.Jobs[data.society].MinAmountforTicket then return end - if Config.CommissionDouble then - biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2))) - triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source) - else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm)) - triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source) - end - if Config.CommissionAll then - for _, v in pairs(QBCore.Functions.GetPlayers()) do - local Player = QBCore.Functions.GetPlayer(v) - if Player and Player ~= biller then - if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then - Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm)) - triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.PlayerData.source) - end - end - end - end - end -end) - -RegisterServerEvent('jim-payments:Tickets:Sell', function() - local Player = QBCore.Functions.GetPlayer(source) - if not Player.Functions.GetItemByName("payticket") then triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', source) return - else - tickets = Player.Functions.GetItemByName("payticket").amount - Player.Functions.RemoveItem('payticket', tickets) - pay = (tickets * Config.Jobs[Player.PlayerData.job.name].PayPerTicket) - Player.Functions.AddMoney('bank', pay, 'ticket-payment') - TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['payticket'], "remove", tickets) - triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', source) - end -end) - -QBCore.Functions.CreateCallback('jim-payments:Ticket:Count', function(source, cb) - cb(QBCore.Functions.GetPlayer(source).Functions.GetItemByName('payticket')) -end) - -RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang) - local src = source - local biller = QBCore.Functions.GetPlayer(src) - local billed = QBCore.Functions.GetPlayer(tonumber(citizen)) - local amount = tonumber(price) - local balance = billed.Functions.GetMoney(billtype) - if amount and amount > 0 then - if balance < amount then - triggerNotify(nil, Loc[Config.Lan].error["customer_nocash"], "error", src) - triggerNotify(nil, Loc[Config.Lan].error["you_nocash"], "error", tonumber(citizen)) - return - end - local label = biller.PlayerData.job.label - if gang == true then label = biller.PlayerData.gang.label end - if Config.PhoneBank == false or gang == true or billtype == "cash" then - TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img, label, gang, outside) - else - if Config.PhoneType == "qb" then - MySQL.Async.insert( - 'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)', - {billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid}, function(id) - if id then - TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.PlayerData.source, id, biller.PlayerData.charinfo.firstname, biller.PlayerData.job.name, biller.PlayerData.citizenid, amount, GetInvokingResource()) - end - end) - TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source) - elseif Config.PhoneType == "gks" then - MySQL.Async.execute('INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', { - ['@citizenid'] = billed.PlayerData.citizenid, - ['@amount'] = amount, - ['@society'] = biller.PlayerData.job.name, - ['@sender'] = biller.PlayerData.charinfo.firstname, - ['@sendercitizenid'] = biller.PlayerData.citizenid, - ['@label'] = biller.PlayerData.job.label, - }) - TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = Loc[Config.Lan].success["inv_succ"], img= '/html/static/img/icons/logo.png' }) - TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' }) - end - triggerNotify(nil, Loc[Config.Lan].success["inv_succ"], 'success', src) - triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.PlayerData.source) - end - else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end -end) - -RegisterServerEvent("jim-payments:server:PayPopup", function(data) - local src = source - local billed = QBCore.Functions.GetPlayer(src) - local biller = QBCore.Functions.GetPlayer(tonumber(data.biller)) - local newdata = { senderCitizenId = biller.PlayerData.citizenid, society = biller.PlayerData.job.name, amount = data.amount } - if data.gang == true then newdata.society = biller.PlayerData.gang.name end - if data.accept == true then - billed.Functions.RemoveMoney(tostring(data.billtype), data.amount) - if Config.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", data.amount) end - TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang) - triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller) - elseif data.accept == false then - triggerNotify(nil, Loc[Config.Lan].success["declined"], nil, src) - triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller) - end -end) - -RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price) - local src = source - local biller = QBCore.Functions.GetPlayer(src) - local billed = QBCore.Functions.GetPlayer(tonumber(citizen)) - local price = math.floor(tonumber(price)) - local commission = math.floor(price * Config.FineJobs[biller.PlayerData.job.name].Commission) - if price > 0 then - if not Config.FineJobConfirmation then - if billed.Functions.RemoveMoney("bank", price) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..price.."^7") end end - if Config.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", price) end - if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end - - if Config.Banking == "renewed" then - exports['Renewed-Banking']:addAccountMoney(tostring(biller.PlayerData.job.name), (price - commission)) - if Config.Debug then print("^5Debug^7: ^3Renewed-Banking^7(^3Job^7): ^2Adding ^7$^6"..(price - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['Renewed-Banking']:getAccountMoney((biller.PlayerData.job.name).."^7)")) end - elseif Config.Banking == "qb-management" then - exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), (price - commission)) - if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..(price - takecomm).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "qb-banking" then - exports["qb-banking"]:AddMoney(tostring(biller.PlayerData.job.name), (price - commission)) - if Config.Debug then print("^5Debug^7: ^3QB-Banking^7(^3Job^7): ^2Adding ^7$^6"..(price - takecomm).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-banking"]:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "fd" then - exports.fd_banking:AddMoney(tostring(biller.PlayerData.job.name), (price - commission)) - if Config.Debug then print("^5Debug^7: ^3FD-Banking^7(^3Job^7): ^2Adding ^7$^6"..(price - takecomm).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports.fd_banking:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "okok" then - exports['okokBanking']:AddMoney(tostring(biller.PlayerData.job.name), (price - commission)) - if Config.Debug then print("^5Debug^7: ^3okokBanking^7(^3Job^7): ^2Adding ^7$^6"..(price - takecomm).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['okokBanking']:GetAccount(biller.PlayerData.job.name).."^7)") end - - end - triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["charged"]..(price - commission), "success", src) - triggerNotify(nil, Loc[Config.Lan].success["you_charged"]..(price - commission), nil, billed.PlayerData.source) - else - TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, price, src, biller.PlayerData.job.label) - end - else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end -end) - -RegisterServerEvent("jim-payments:server:PolPopup", function(data) - local src = source - local billed = QBCore.Functions.GetPlayer(src) - local biller = QBCore.Functions.GetPlayer(tonumber(data.biller)) - data.amount = math.floor(data.amount) - local commission = math.floor(tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission) - if data.accept == true then - if billed.Functions.RemoveMoney("bank", data.amount) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billed.PlayerData.source.."^7) ^2charged ^7$^6"..data.amount.."^7") end end - if Config.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", data.amount) end - triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["charge_end"], "success", data.biller) - if biller.Functions.AddMoney("bank", commission) then if Config.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Commission^2 of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end - - if Config.Banking == "renewed" then - exports['Renewed-Banking']:addAccountMoney(tostring(biller.PlayerData.job.name), data.amount - commission) - if Config.Debug then print("^5Debug^7: ^3Renewed-Banking^7(^3Job^7): ^2Adding ^7$^6"..(data.amount - commission).." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['Renewed-Banking']:getAccountMoney((biller.PlayerData.job.name).."^7)")) end - elseif Config.Banking == "qb-management" then - exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission) - if Config.Debug then print("^5Debug^7: ^3QB-Management^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-management"]:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "qb-banking" then - exports["qb-banking"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission) - if Config.Debug then print("^5Debug^7: ^3QB-Banking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports["qb-banking"]:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "fd" then - exports.fd_banking:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission) - if Config.Debug then print("^5Debug^7: ^3FD-Banking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports.fd_banking:GetAccount(biller.PlayerData.job.name).."^7)") end - elseif Config.Banking == "okok" then - exports['okokBanking']:AddMoney(tostring(biller.PlayerData.job.name), data.amount - commission) - if Config.Debug then print("^5Debug^7: ^3okokBanking^7(^3Job^7): ^2Adding ^7$^6"..data.amount - takecomm.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7' ($^6"..exports['okokBanking']:GetAccount(biller.PlayerData.job.name).."^7)") end - end - else - triggerNotify(nil, Loc[Config.Lan].error["declined_payment"], nil, src) - triggerNotify(nil, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount..Loc[Config.Lan].success["charge_end"], "error", data.biller) - end -end) - -QBCore.Functions.CreateCallback('jim-payments:MakePlayerList', function(source, cb) - local onlineList = {} - for _, v in pairs(QBCore.Functions.GetPlayers()) do - local P = QBCore.Functions.GetPlayer(v) - onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..P.PlayerData.charinfo.firstname..' '..P.PlayerData.charinfo.lastname } - end - cb(onlineList) -end) - - -CreateThread(function() - if Config.Usebzzz then - QBCore.Functions.CreateUseableItem('terminal', function(source, item) - TriggerClientEvent("jim-payments:client:Charge", source, {}, true) - end) - end -end) diff --git a/shared/banklocs.lua b/shared/banklocs.lua new file mode 100644 index 0000000..1669d43 --- /dev/null +++ b/shared/banklocs.lua @@ -0,0 +1,63 @@ +BankLocations = { + ["legion"] = { + vec4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca + }, + ["hawick"] = { + vec4(313.81, -280.43, 54.16, 342.29), -- Hawick Fleeca + }, + ["vinewood"] = { + vec4(-351.4, -51.24, 49.04, 338.4), -- Vinewood Fleeca + }, + ["delperro"] = { + vec4(-1212.11, -332.01, 37.78, 25.33), -- Del Perro Fleeca + }, + ["route1"] = { + vec4(-2961.17, 482.9, 15.7, 84.68), -- Route 1 Fleeca + }, + ["route68"] = { + vec4(1175.03, 2708.2, 38.09, 180.0), -- Route 68 Fleeca + }, + ["paleto"] = { + vec4(-111.22, 6470.03, 31.63, 133.86), -- Paleto Bank + }, + ["pacific"] = { + vec4(243.58, 226.25, 106.29, 169.06), -- Pacific Bank Window 1 + vec4(247.08, 224.98, 106.29, 157.75), -- Pacific Bank Window 2 + }, +} + +if Config.General.Gabz then + Config.Receipts.CashInLocation = vec4(269.28, 217.24, 106.28, 69.0) + BankLocations = { + ["legion"] = { + vec4(149.5, -1042.08, 29.37, 342.74), -- Legion Fleeca + }, + ["hawick"] = { + vec4(313.81, -280.43, 54.16, 342.29), -- Hawick Fleeca + }, + ["vinewood"] = { + vec4(-351.4, -51.24, 49.04, 338.4), -- Vinewood Fleeca + }, + ["delperro"] = { + vec4(-1212.11, -332.01, 37.78, 25.33), -- Del Perro Fleeca + }, + ["route1"] = { + vec4(-2961.17, 482.9, 15.7, 84.68), -- Route 1 Fleeca + }, + ["route68"] = { + vec4(1175.03, 2708.2, 38.09, 180.0), -- Route 68 Fleeca + }, + ["paleto"] = { + vec4(-110.72, 6469.82, 31.63, 222.94), -- Paleto Bank (GABZ) - 1 + vec4(-108.98, 6471.56, 31.63, 222.92), -- Paleto Bank (GABZ) - 2 + }, + ["pacific"] = { + vec4(258.55, 227.63, 106.28, 160.96), -- Pacficic Gabz 1+2 + vec4(263.21, 225.93, 106.28, 158.25), -- Pacficic Gabz 3+4 + vec4(267.95, 224.24, 106.28, 158.5), -- Pacficic Gabz 5+6 + vec4(263.71, 212.63, 106.28, 337.53), -- Pacficic Gabz 7+8 + vec4(259.02, 214.32, 106.28, 337.82), -- Pacficic Gabz 9+10 + vec4(254.27, 216.06, 106.28, 336.37), -- Pacficic Gabz 11+12 + }, + } +end \ No newline at end of file diff --git a/shared/shared.lua b/shared/shared.lua deleted file mode 100644 index 842b82d..0000000 --- a/shared/shared.lua +++ /dev/null @@ -1,120 +0,0 @@ -QBCore = exports['qb-core']:GetCoreObject() - -local time = 1000 -function loadModel(model) if not HasModelLoaded(model) then - if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end - while not HasModelLoaded(model) do - if time > 0 then time -= 1 RequestModel(model) - else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break - end - Wait(10) - end -end end -function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end -function loadAnimDict(dict) if not HasAnimDictLoaded(dict) then if Config.Debug then print("^5Debug^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end end -function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end -function loadPtfxDict(dict) if not HasNamedPtfxAssetLoaded(dict) then if Config.Debug then print("^5Debug^7: ^2Loading Ptfx Dictionary^7: '^6"..dict.."^7'") end while not HasNamedPtfxAssetLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end end -function unloadPtfxDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end - -function lookEnt(entity) - if type(entity) == "vector3" then - if not IsPedHeadingTowardsPosition(PlayerPedId(), entity, 10.0) then - TaskTurnPedToFaceCoord(PlayerPedId(), entity, 1500) - if Config.Debug then print("^5Debug^7: ^2Turning Player to^7: '^6"..json.encode(entity).."^7'") end - Wait(1500) - end - else - if DoesEntityExist(entity) then - if not IsPedHeadingTowardsPosition(PlayerPedId(), GetEntityCoords(entity), 30.0) then - TaskTurnPedToFaceCoord(PlayerPedId(), GetEntityCoords(entity), 1500) - if Config.Debug then print("^5Debug^7: ^2Turning Player to^7: '^6"..entity.."^7'") end - Wait(1500) - end - end - end -end - -function destroyProp(entity) - if Config.Debug then print("^5Debug^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end - SetEntityAsMissionEntity(entity) Wait(5) - DetachEntity(entity, true, true) Wait(5) - DeleteObject(entity) -end - -function makeProp(data, freeze, synced) - loadModel(data.prop) - local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z, synced or false, synced or false, 0) - SetEntityHeading(prop, data.coords.w+180.0) - FreezeEntityPosition(prop, freeze or 0) - if Config.Debug then print("^5Debug^7: ^6Prop ^2Created ^7: '^6"..prop.."^7'") end - return prop -end - -function makePed(model, coords, freeze, collision, scenario, anim) - loadModel(model) - local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, false, false) - SetEntityInvincible(ped, true) - SetBlockingOfNonTemporaryEvents(ped, true) - FreezeEntityPosition(ped, freeze or true) - if collision then SetEntityNoCollisionEntity(ped, PlayerPedId(), false) end - if scenario then TaskStartScenarioInPlace(ped, scenario, 0, true) end - if anim then - loadAnimDict(anim[1]) - TaskPlayAnim(ped, anim[1], anim[2], 1.0, 1.0, -1, 1, 0.2, 0, 0, 0) - end - if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6"..model.."^7'") end - return ped -end - -function makeBlip(data) - local blip = AddBlipForCoord(data.coords) - SetBlipAsShortRange(blip, true) - SetBlipSprite(blip, data.sprite or 1) - SetBlipColour(blip, data.col or 0) - SetBlipScale(blip, data.scale or 0.7) - SetBlipDisplay(blip, (data.disp or 6)) - BeginTextCommandSetBlipName('STRING') - AddTextComponentString(tostring(data.name)) - EndTextCommandSetBlipName(blip) - if Config.Debug then print("^5Debug^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end - return blip -end - -function triggerNotify(title, message, type, src) - if Config.Notify == "okok" then - if not src then exports['okokNotify']:Alert(title, message, 6000, type or 'info') - else TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type or 'info') end - elseif Config.Notify == "qb" then - if not src then TriggerEvent("QBCore:Notify", message, "primary") - else TriggerClientEvent("QBCore:Notify", src, message, "primary") end - elseif Config.Notify == "t" then - if not src then exports['t-notify']:Custom({title = title, style = type, message = message, sound = true}) - else TriggerClientEvent('t-notify:client:Custom', src, { style = type, duration = 6000, title = title, message = message, sound = true, custom = true}) end - elseif Config.Notify == "infinity" then - if not src then TriggerEvent('infinity-notify:sendNotify', message, type) - else TriggerClientEvent('infinity-notify:sendNotify', src, message, type) end - elseif Config.Notify == "rr" then - if not src then exports.rr_uilib:Notify({msg = message, type = type, style = "dark", duration = 6000, position = "top-right", }) - else TriggerClientEvent("rr_uilib:Notify", src, {msg = message, type = type, style = "dark", duration = 6000, position = "top-right", }) end - end -end - -function pairsByKeys(t) - local a = {} - for n in pairs(t) do a[#a+1] = n end - table.sort(a) - local i = 0 - local iter = function() i += 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end - return iter -end - -function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end - -function cv(amount) - local formatted = amount - while true do - formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') - if (k==0) then break end - end - return formatted -end \ No newline at end of file diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..f398a20 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +3.0 \ No newline at end of file