mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
PolCharge fixes + debug
This commit is contained in:
38
atms.lua
38
atms.lua
@@ -21,15 +21,17 @@ local function cv(amount)
|
||||
return formatted
|
||||
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 unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) 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("^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 gangroles = {}
|
||||
CreateThread(function()
|
||||
if Config.useATM then
|
||||
if Config.ATMBlips then
|
||||
for k, v in pairs(Config.WallATMLocations) do
|
||||
for _, v in pairs(Config.WallATMLocations) do
|
||||
blip = AddBlipForCoord(v)
|
||||
SetBlipSprite(blip, 108)
|
||||
SetBlipDisplay(blip, 4)
|
||||
@@ -40,7 +42,7 @@ CreateThread(function()
|
||||
AddTextComponentString("ATM")
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
for k, v in pairs(Config.ATMLocations) do
|
||||
for _, v in pairs(Config.ATMLocations) do
|
||||
blip = AddBlipForCoord(v)
|
||||
SetBlipSprite(blip, 108)
|
||||
SetBlipDisplay(blip, 4)
|
||||
@@ -55,8 +57,8 @@ CreateThread(function()
|
||||
end
|
||||
if Config.useBanks then
|
||||
if Config.BankBlips then
|
||||
for k,v in pairs(Config.BankLocations) do
|
||||
for l, b in pairs(v) do
|
||||
for _, v in pairs(Config.BankLocations) do
|
||||
for _, b in pairs(v) do
|
||||
blip = AddBlipForCoord(b)
|
||||
SetBlipSprite(blip, 108)
|
||||
SetBlipDisplay(blip, 4)
|
||||
@@ -72,9 +74,9 @@ CreateThread(function()
|
||||
end
|
||||
end
|
||||
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
|
||||
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 bossroles[tostring(k)] ~= nil then -- checks if the line exists
|
||||
if bossroles[tostring(k)] > tonumber(l) then bossroles[tostring(k)] = tonumber(l) end -- the
|
||||
@@ -84,9 +86,9 @@ CreateThread(function()
|
||||
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
|
||||
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 QBCore.Shared.Gangs[tostring(k)].grades[l].isboss == true then
|
||||
if gangroles[tostring(k)] ~= nil then
|
||||
@@ -135,7 +137,7 @@ CreateThread(function()
|
||||
local i = math.random(1, #Config.PedPool)
|
||||
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 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
|
||||
@@ -143,13 +145,15 @@ CreateThread(function()
|
||||
end)
|
||||
|
||||
local function PlayATMAnimation(animation)
|
||||
if animation == 'enter' then RequestAnimDict('amb@prop_human_atm@male@enter')
|
||||
while not HasAnimDictLoaded('amb@prop_human_atm@male@enter') do Wait(1) end
|
||||
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
|
||||
if animation == 'enter' then
|
||||
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')
|
||||
end
|
||||
if animation == 'exit' then RequestAnimDict('amb@prop_human_atm@male@exit')
|
||||
while not HasAnimDictLoaded('amb@prop_human_atm@male@exit') do Wait(1) end
|
||||
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
|
||||
if animation == 'exit' then
|
||||
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')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName(
|
||||
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 unloadModel(model) if Config.Debug then print("Debug: Removing Model: '"..model.."'") end SetModelAsNoLongerNeeded(model) 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("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
|
||||
|
||||
CreateThread(function()
|
||||
local jobroles = {} local gangroles = {}
|
||||
@@ -38,7 +38,7 @@ CreateThread(function()
|
||||
local i = math.random(1, #Config.PedPool)
|
||||
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 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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -6,9 +6,8 @@ print("Jim-Payments v2.7 - Payments Script by Jimathy")
|
||||
|
||||
Config = {
|
||||
Debug = false,
|
||||
Manage = true, -- "true" if using qb-management
|
||||
Manage = true, -- "true" if using qb-management
|
||||
-- "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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
57
server.lua
57
server.lua
@@ -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 gang then
|
||||
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)
|
||||
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
|
||||
elseif not gang then
|
||||
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)
|
||||
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
|
||||
elseif not biller then --Find the biller from their citizenid
|
||||
@@ -47,20 +47,26 @@ RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang)
|
||||
-- If ticket system enabled, do this
|
||||
if duty and Config.TicketSystem then
|
||||
if data.amount >= Config.Jobs[data.society].MinAmountforTicket then
|
||||
for _, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||
local Player = QBCore.Functions.GetPlayer(v)
|
||||
if Player ~= nil or Player ~= billed then
|
||||
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
|
||||
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
||||
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
||||
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 Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
|
||||
Player.Functions.AddItem('payticket', 1, false, {["quality"] = nil})
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Receipt received', 'success')
|
||||
TriggerClientEvent('inventory:client:ItemBox', Player.PlayerData.source, QBCore.Shared.Items['payticket'], "add", 1)
|
||||
end
|
||||
end
|
||||
if gang then
|
||||
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
|
||||
if gang then
|
||||
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
|
||||
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
|
||||
@@ -173,11 +179,11 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
|
||||
local commission = (tonumber(price) * Config.FineJobs[biller.PlayerData.job.name].Commission)
|
||||
biller.Functions.AddMoney("bank", math.floor(commission))
|
||||
if Config.Manage then
|
||||
if Config.Manage then 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
|
||||
else TriggerEvent("qb-bossmenu:server:addAccountMoney", tostring(biller.PlayerData.job.name), price)
|
||||
if Config.Debug then print("QB-BossMenu: Adding $"..price.." to account '"..tostring(biller.PlayerData.job.name).."'") end
|
||||
end
|
||||
exports["qb-management"]:AddMoney(tostring(biller.PlayerData.job.name), price)
|
||||
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)
|
||||
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
|
||||
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))
|
||||
@@ -193,6 +199,15 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
|
||||
if data.accept == true then
|
||||
billed.Functions.RemoveMoney("bank", data.amount)
|
||||
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
|
||||
TriggerClientEvent("QBCore:Notify", src, "You declined the payment")
|
||||
TriggerClientEvent("QBCore:Notify", data.biller, billed.PlayerData.charinfo.firstname.." declined the $"..data.amount.." charge", "error")
|
||||
|
||||
Reference in New Issue
Block a user