From 9c1953ab928111c954f3ab6141820ec4c33a723e Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Tue, 19 Jul 2022 14:52:02 +0100 Subject: [PATCH] Custom cash register spawning support built in --- README.md | 19 +++++++++++-------- client.lua | 24 +++++++++++++++++++++++- config.lua | 14 ++++++++++---- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ae2a9cf..63a3a03 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,24 @@ Enchanced QB-Input payment system from my other scripts now free on its own ![General](https://i.imgur.com/37d2mE3.jpeg) ![General](https://i.imgur.com/AIdXzxX.jpeg) ![General](https://i.imgur.com/RYADcI2.jpeg) ![General](https://i.imgur.com/ICbQyeQ.jpeg) + # Installation -To make use of this payment system you need trigger the event +To make use of this payment system you in a job that wasn't created by me -```jim-payments:client:Charge``` +All you need to do is pick the job, grab a vector4 and confirm if you need a prop or not -for example with qb-target +For example: ```lua -exports['qb-target']:AddBoxZone("Receipt", vector3(1589.14, 6458.26, 26.01), 0.6, 0.6, { name="Receipt", heading = 335.0, debugPoly=debugPoly, minZ = 26.01, maxZ = 26.81, }, -{ options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = "popsdiner" } }, distance = 2.0 }) + CustomCashRegisters = { -- Located in the config.lua + ["burgershot"] = { -- Player job role restriction + { coords = vector4(-1185.5, -878.54, 13.91, 305.53), prop = true, }, -- vector4 to place the till and the way it faces + { coords = vector4(-1184.34, -880.51, 13.93, 302.04), prop = true, }, -- "prop = true" spawns a prop at the coords + }, + }, ``` -It currently requires you to be on duty to charge someone -This does not need to be added to **MY** job scripts, they already have built in support +This does not need to be done for **MY** job scripts, they already have built in support -------------- @@ -76,7 +80,6 @@ Choose wether to use atm's, choose wether to use banking locations Choose wether to add bank blips (if you want to disable qb-banking) Choose wether to add ATM blips (if you like $ signs) - -------------- New Commission system added diff --git a/client.lua b/client.lua index 71a7c6f..2c6cb78 100644 --- a/client.lua +++ b/client.lua @@ -5,6 +5,8 @@ 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) @@ -28,6 +30,7 @@ CreateThread(function() --Build Job/Gang Checks for cashin location for k, v in pairs(Config.Jobs) do if v.gang then gangroles[tostring(k)] = 0 else jobroles[tostring(k)] = 0 end end --Create Target at location + Targets["JimBank"] = exports['qb-target']:AddCircleZone("JimBank", vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z), 2.0, { name="JimBank", debugPoly=Config.Debug, useZ=true, }, { options = { { event = "jim-payments:Tickets:Menu", icon = "fas fa-receipt", label = "Cash in Job Receipts", job = jobroles, }, @@ -40,6 +43,23 @@ CreateThread(function() if not BankPed then BankPed = CreatePed(0, Config.PedPool[i], vector3(Config.CashInLocation.x, Config.CashInLocation.y, Config.CashInLocation.z-1), Config.CashInLocation[4], false, false) end if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6Ticket Trade^7'") end end + + --Spawn Custom Cash Register Targets + for k, v in pairs(Config.CustomCashRegisters) do + for i = 1, #v do + Targets["CustomRegister: "..k..i] = + exports['qb-target']:AddBoxZone("CustomRegister: "..k..i, v[i].coords, 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 }, + { options = { { event = "jim-payments:client:Charge", icon = "fas fa-credit-card", label = "Charge Customer", job = k, img = "" }, }, + distance = 2.0 + }) + if v[i].prop then + loadModel(`prop_till_03`) + till[#till+1] = CreateObject(`prop_till_03`, v[i].coords.x, v[i].coords.y, v[i].coords.z, 0, 0, 0) + SetEntityHeading(till[#till],v[i].coords[4]+180.0) + FreezeEntityPosition(till[#till], true) + end + end + end end) RegisterNetEvent('jim-payments:client:Charge', function(data, outside) @@ -170,5 +190,7 @@ RegisterNetEvent('jim-payments:Tickets:Sell:yes', function() TriggerServerEvent( RegisterNetEvent('jim-payments:Tickets:Sell:no', function() exports['qb-menu']:closeMenu() end) AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end - exports['qb-target']:RemoveZone("JimBank") unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed) + for k in pairs(Targets) do exports['qb-target']:RemoveZone(k) end + for i = 1, #till do DeleteEntity(till[i]) end + unloadModel(GetEntityModel(BankPed)) DeletePed(BankPed) end) \ No newline at end of file diff --git a/config.lua b/config.lua index d3bb5e1..21e9bc1 100644 --- a/config.lua +++ b/config.lua @@ -5,7 +5,7 @@ print("^2Jim^7-^2Payments v^42^7.^47 ^7- ^2Payments Script by ^1Jimathy^7") -- https://discord.gg/xKgQZ6wZvS Config = { - Debug = false, + Debug = true, Manage = true, -- "true" if using qb-management -- "false" if using qb-bossmenu @@ -50,8 +50,8 @@ Config = { 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 + 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 Gabz = false, -- "true" to enable Gabz Bank locations @@ -68,9 +68,15 @@ Config = { ['tequilala'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, ['vanilla'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, }, ['mechanic'] = { MinAmountforTicket = 1000, PayPerTicket = 500, Commission = 0.10, }, - ['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, + ['lostmc'] = { MinAmountforTicket = 50, PayPerTicket = 50, Commission = 0.10, gang = true, }, -- Example of a gang being supported }, + -- 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 = { + + }, + -- The /polcharge command requires specific jobs to be set -- No tickets for these, it's just commission FineJobs = {