PolCharge fixes + debug

This commit is contained in:
Jim Shield
2022-07-11 19:59:57 +01:00
committed by GitHub
parent da1a19eb2c
commit b543803194
4 changed files with 65 additions and 44 deletions

View File

@@ -21,15 +21,17 @@ local function cv(amount)
return formatted return formatted
end end
local function loadModel(model) if Config.Debug then print("Debug: Loading Model: '"..model.."'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end local function loadModel(model) if not HasModelLoaded(model) then if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
local function unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) end local function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
local function loadAnimDict(dict) 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
local function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
local bossroles = {} local bossroles = {}
local gangroles = {} local gangroles = {}
CreateThread(function() CreateThread(function()
if Config.useATM then if Config.useATM then
if Config.ATMBlips then if Config.ATMBlips then
for k, v in pairs(Config.WallATMLocations) do for _, v in pairs(Config.WallATMLocations) do
blip = AddBlipForCoord(v) blip = AddBlipForCoord(v)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -40,7 +42,7 @@ CreateThread(function()
AddTextComponentString("ATM") AddTextComponentString("ATM")
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
end end
for k, v in pairs(Config.ATMLocations) do for _, v in pairs(Config.ATMLocations) do
blip = AddBlipForCoord(v) blip = AddBlipForCoord(v)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -55,8 +57,8 @@ CreateThread(function()
end end
if Config.useBanks then if Config.useBanks then
if Config.BankBlips then if Config.BankBlips then
for k,v in pairs(Config.BankLocations) do for _, v in pairs(Config.BankLocations) do
for l, b in pairs(v) do for _, b in pairs(v) do
blip = AddBlipForCoord(b) blip = AddBlipForCoord(b)
SetBlipSprite(blip, 108) SetBlipSprite(blip, 108)
SetBlipDisplay(blip, 4) SetBlipDisplay(blip, 4)
@@ -72,9 +74,9 @@ CreateThread(function()
end end
end end
if Config.useATM or Config.useBanks then if Config.useATM or Config.useBanks then
for k, v in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs for k in pairs(QBCore.Shared.Jobs) do ---Grabs the list of jobs
if QBCore.Shared.Jobs[tostring(k)] then if QBCore.Shared.Jobs[tostring(k)] then
for l, b in pairs(QBCore.Shared.Jobs[tostring(k)].grades) do -- Grabs the list of grades 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 QBCore.Shared.Jobs[tostring(k)].grades[l].isboss == true then -- Checks the grade if is boss
if bossroles[tostring(k)] ~= nil then -- checks if the line exists if bossroles[tostring(k)] ~= nil then -- checks if the line exists
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the
@@ -84,9 +86,9 @@ CreateThread(function()
end end
end end
end end
for k, v in pairs(QBCore.Shared.Gangs) do for k in pairs(QBCore.Shared.Gangs) do
if QBCore.Shared.Gangs[tostring(k)] then if QBCore.Shared.Gangs[tostring(k)] then
for l, b in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do for l in pairs(QBCore.Shared.Gangs[tostring(k)].grades) do
if tostring(k) ~= "none" then if tostring(k) ~= "none" then
if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then if QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then
if gangroles[tostring(k)] ~= nil then if gangroles[tostring(k)] ~= nil then
@@ -135,7 +137,7 @@ CreateThread(function()
local i = math.random(1, #Config.PedPool) local i = math.random(1, #Config.PedPool)
loadModel(Config.PedPool[i]) loadModel(Config.PedPool[i])
if Peds["jimbank"..k..l] == nil then Peds["jimbank"..k..l] = CreatePed(0, Config.PedPool[i], vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)-1.03), b[4], false, false) end if Peds["jimbank"..k..l] == nil then Peds["jimbank"..k..l] = CreatePed(0, Config.PedPool[i], vector3(tonumber(b.x), tonumber(b.y), tonumber(b.z)-1.03), b[4], false, false) end
if Config.Debug then print("Ped Created - 'jimbank"..k..l.."'") end if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6"..k..l.."^7'") end
end end
end end
end end
@@ -143,13 +145,15 @@ CreateThread(function()
end) end)
local function PlayATMAnimation(animation) local function PlayATMAnimation(animation)
if animation == 'enter' then RequestAnimDict('amb@prop_human_atm@male@enter') if animation == 'enter' then
while not HasAnimDictLoaded('amb@prop_human_atm@male@enter') do Wait(1) end loadAnimDict('amb@prop_human_atm@male@enter')
if HasAnimDictLoaded('amb@prop_human_atm@male@enter') then TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@enter', "enter", 1.0,-1.0, 1500, 1, 1, true, true, true) end 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')
end end
if animation == 'exit' then RequestAnimDict('amb@prop_human_atm@male@exit') if animation == 'exit' then
while not HasAnimDictLoaded('amb@prop_human_atm@male@exit') do Wait(1) end loadAnimDict('amb@prop_human_atm@male@exit')
if HasAnimDictLoaded('amb@prop_human_atm@male@exit') then TaskPlayAnim(PlayerPedId(), 'amb@prop_human_atm@male@exit', "exit", 1.0,-1.0, 3000, 1, 1, true, true, true) end 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')
end end
end end

View File

@@ -20,8 +20,8 @@ AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName(
end) end)
end) end)
local function loadModel(model) if Config.Debug then print("Debug: Loading Model: '"..model.."'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end local function loadModel(model) if not HasModelLoaded(model) then if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
local function unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) end local function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
CreateThread(function() CreateThread(function()
local jobroles = {} local gangroles = {} local jobroles = {} local gangroles = {}
@@ -38,7 +38,7 @@ CreateThread(function()
local i = math.random(1, #Config.PedPool) local i = math.random(1, #Config.PedPool)
loadModel(Config.PedPool[i]) loadModel(Config.PedPool[i])
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 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("Ped Created for Ticket Trade") end if Config.Debug then print("^5Debug^7: ^6Ped ^2Created for location^7: '^6Ticket Trade^7'") end
end end
end) end)

View File

@@ -1,4 +1,4 @@
print("Jim-Payments v2.7 - Payments Script by Jimathy") print("^2Jim^7-^2Payments ^4v^62.7 ^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. -- If you need support I now have a discord available, it helps me keep track of issues and give better support.
@@ -8,7 +8,6 @@ Config = {
Debug = false, Debug = false,
Manage = true, -- "true" if using qb-management Manage = true, -- "true" if using qb-management
-- "false" if using qb-bossmenu -- "false" if using qb-bossmenu
TicketSystem = true, -- Enable this if you want to use the ticket system false
List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry
PaymentRadius = 30, -- This is how far the playerlist will check for nearby players (based on the person charging) PaymentRadius = 30, -- This is how far the playerlist will check for nearby players (based on the person charging)
@@ -45,6 +44,9 @@ Config = {
CashInLocation = vector4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank 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 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 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 CommissionDouble = false, -- Set this to true if you want the person charging to get double Commission

View File

@@ -22,15 +22,15 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
if biller then -- If this is found, it ISN'T a phone payment, so add money to society here if biller then -- If this is found, it ISN'T a phone payment, so add money to society here
if gang then if gang then
if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount) if Config.Manage then exports["qb-management"]:AddGangMoney(tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("QB-Management(Gang): Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.gang.name).."'") end if Config.Debug then print("^5Debug^7: ^6QB-Management^7(^Gang^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7'") end
else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(biller.PlayerData.gang.name), data.amount) else TriggerEvent("qb-gangmenu:server:addAccountMoney", tostring(biller.PlayerData.gang.name), data.amount)
if Config.Debug then print("QB-GangMenu: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.gang.name).."'") end if Config.Debug then print("^5Debug^7: ^6QB-GangMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.gang.name).."^7'") end
end end
elseif not gang then elseif not gang then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount) if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("QB-Management(Job): Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^6QB-Management^7(^4Job^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount) else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("QB-BossMenu: Adding $"..data.amount.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^6QB-BossMenu^7: ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end end
end end
elseif not biller then --Find the biller from their citizenid elseif not biller then --Find the biller from their citizenid
@@ -47,6 +47,7 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
-- If ticket system enabled, do this -- If ticket system enabled, do this
if duty and Config.TicketSystem then if duty and Config.TicketSystem then
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
if Config.TicketSystemAll then
for _, v in pairs(QBCore.Functions.GetPlayers()) do for _, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v) local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil or Player ~= billed then if Player ~= nil or Player ~= billed then
@@ -62,6 +63,11 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1) TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end end
end end
else
biller.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
TriggerClientEvent('QBCore:Notify', biller.PlayerData.source, 'Receipt received', 'success')
TriggerClientEvent('inventory:client:ItemBox', biller.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
end
end end
end end
-- Commission section, does each config option separately -- Commission section, does each config option separately
@@ -173,11 +179,11 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
local commission = (tonumber(price) * Config.FineJobs[biller.PlayerData.job.name].Commission) local commission = (tonumber(price) * Config.FineJobs[biller.PlayerData.job.name].Commission)
biller.Functions.AddMoney("bank", math.floor(commission)) biller.Functions.AddMoney("bank", math.floor(commission))
if Config.Manage then if Config.Manage then
if Config.Manage then exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), price) exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), price)
if Config.Debug then print("QB-Management(Job): Adding $"..price.." to account '"..tostring(biller.PlayerData.job.name).."'") end if Config.Debug then print("^5Debug^7: ^6QB-Management^7(^4Job^7): ^2Adding ^7$^6"..price.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), price) else
if Config.Debug then print("QB-BossMenu: Adding $"..price.." to account '"..tostring(biller.PlayerData.job.name).."'") end TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), price)
end if Config.Debug then print("^5Debug^7: ^6QB-BossMenu^7: ^2Adding ^7$^6"..price.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end end
TriggerClientEvent('QBCore:Notify', src, billed.PlayerData.charinfo.firstname.." was charged for $"..tonumber(price), "success") TriggerClientEvent('QBCore:Notify', src, billed.PlayerData.charinfo.firstname.." was charged for $"..tonumber(price), "success")
TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..tonumber(price)) TriggerClientEvent('QBCore:Notify', billed.PlayerData.source, 'You were charged for $'..tonumber(price))
@@ -193,6 +199,15 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
if data.accept == true then if data.accept == true then
billed.Functions.RemoveMoney("bank", data.amount) billed.Functions.RemoveMoney("bank", data.amount)
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success") TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." accepted the $"..data.amount.." charge", "success")
local commission = (tonumber(data.amount) * Config.FineJobs[biller.PlayerData.job.name].Commission)
if biller.Functions.AddMoney("bank", math.floor(commission)) then if Config.Debug then print("^5Debug^7: ^6PolCharge^7 - ^4Commission ^2 of ^7$^6"..commission.." ^2sent to Player^7(^6"..biller.PlayerData.source.."^7)") end end
if Config.Manage then
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("^5Debug^7: ^6QB-Management^7(^4Job^7): ^2Adding ^7$^6"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
else
TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), data.amount)
if Config.Debug then print("^5Debug^7: ^6QB-BossMenu^7: ^2Adding ^6$^7"..data.amount.." ^2to account ^7'^6"..tostring(biller.PlayerData.job.name).."^7'") end
end
else else
TriggerClientEvent("QBCore:Notify", src, "You declined the payment") TriggerClientEvent("QBCore:Notify", src, "You declined the payment")
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error") TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error")