mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-17 06:16:02 +01:00
/polcharge for police billing + Optimize + Fixes
This commit is contained in:
76
atms.lua
76
atms.lua
@@ -21,10 +21,12 @@ 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 bossroles = {}
|
||||
local gangroles = {}
|
||||
CreateThread(function()
|
||||
if Config.Gabz then BankLoc = Config.GabzBankLocations ATMLoc = Config.GabzATMLocations end
|
||||
if Config.useATM then
|
||||
if Config.ATMBlips then
|
||||
for k, v in pairs(Config.WallATMLocations) do
|
||||
@@ -38,7 +40,7 @@ CreateThread(function()
|
||||
AddTextComponentString("ATM")
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
for k, v in pairs(ATMLoc) do
|
||||
for k, v in pairs(Config.ATMLocations) do
|
||||
blip = AddBlipForCoord(v)
|
||||
SetBlipSprite(blip, 108)
|
||||
SetBlipDisplay(blip, 4)
|
||||
@@ -53,7 +55,7 @@ CreateThread(function()
|
||||
end
|
||||
if Config.useBanks then
|
||||
if Config.BankBlips then
|
||||
for k,v in pairs(BankLoc) do
|
||||
for k,v in pairs(Config.BankLocations) do
|
||||
for l, b in pairs(v) do
|
||||
blip = AddBlipForCoord(b)
|
||||
SetBlipSprite(blip, 108)
|
||||
@@ -75,14 +77,14 @@ CreateThread(function()
|
||||
for l, b 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
|
||||
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, v in pairs(QBCore.Shared.Gangs) do
|
||||
for k, v 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
|
||||
if tostring(k) ~= "none" then
|
||||
@@ -92,7 +94,7 @@ CreateThread(function()
|
||||
else gangroles[tostring(k)] = tonumber(l)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -101,38 +103,38 @@ CreateThread(function()
|
||||
exports['qb-target']:AddTargetModel(Config.ATMModels, { options = { { event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-alt", label = "Use ATM", id = "atm" },}, distance = 1.5, })
|
||||
for k,v in pairs(Config.WallATMLocations) do
|
||||
Targets["jimwallatm"..k] =
|
||||
exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimwallatm"..k, debugPoly=Config.Debug, useZ=true, },
|
||||
exports['qb-target']:AddCircleZone("jimwallatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(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 = "Use ATM", id = "atm" },
|
||||
--{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
|
||||
}, distance = 1.5 })
|
||||
end
|
||||
for k,v in pairs(ATMLoc) do
|
||||
for k,v in pairs(Config.ATMLocations) do
|
||||
Targets["jimatm"..k] =
|
||||
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(v.z)+0.2), 0.5, { name="jimatm"..k, debugPoly=Config.Debug, useZ=true, },
|
||||
exports['qb-target']:AddCircleZone("jimatm"..k, vector3(tonumber(v.x), tonumber(v.y), tonumber(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 = "Use ATM", id = "atm" },
|
||||
--{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
|
||||
}, distance = 1.5 })
|
||||
end
|
||||
end
|
||||
if Config.useBanks then
|
||||
for k,v in pairs(BankLoc) do
|
||||
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(tonumber(b.x), tonumber(b.y), tonumber(b.z)+0.2), 2.0, { name="jimbank"..k..l, debugPoly=Config.Debug, useZ=true, },
|
||||
exports['qb-target']:AddCircleZone("jimbank"..k..l, vector3(tonumber(b.x), tonumber(b.y), tonumber(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 = "Use Bank", id = "bank" },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Transfer Money", id = "transfer" },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-money-check-dollar", label = "Access Savings", id = "savings" },
|
||||
|
||||
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = "Access Society Account", id = "society", job = bossroles },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Society Money Transfer", id = "societytransfer", job = bossroles },
|
||||
|
||||
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-building", label = "Gang Society Account", id = "gang", gang = gangroles },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Gang Money Transfer", id = "gangtransfer", gang = gangroles }, },
|
||||
{ event = "jim-payments:Client:ATM:use", icon = "fas fa-arrow-right-arrow-left", label = "Gang Money Transfer", id = "gangtransfer", gang = gangroles }, },
|
||||
distance = 2.5 })
|
||||
if Config.Peds then
|
||||
local i = math.random(1, #Config.PedPool)
|
||||
RequestModel(Config.PedPool[i]) while not HasModelLoaded(Config.PedPool[i]) do Wait(0) 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)), b[4], false, false) end
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -163,14 +165,14 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
QBCore.Functions.TriggerCallback('jim-payments:ATM:Find', function(cb) p:resolve(cb) end) local info = Citizen.Await(p)
|
||||
local society local gsociety local cancelled = false
|
||||
if Config.Manage then
|
||||
society = GrabAccount("GetAccount", PlayerJob.name)
|
||||
society = GrabAccount("GetAccount", PlayerJob.name)
|
||||
Wait(200)
|
||||
gsociety = GrabAccount("GetGangAccount", PlayerGang.name)
|
||||
else
|
||||
local p = promise.new()
|
||||
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) society = Citizen.Await(p)
|
||||
QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) p:resolve(cb) end, PlayerJob.name) society = Citizen.Await(p)
|
||||
local p2 = promise.new()
|
||||
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) gsociety = Citizen.Await(p2)
|
||||
QBCore.Functions.TriggerCallback('qb-gangmenu:server:GetAccount', function(cb) p2:resolve(cb) end, PlayerGang.name) gsociety = Citizen.Await(p2)
|
||||
end
|
||||
local atmbartime = 2500
|
||||
local setoptions = {}
|
||||
@@ -211,8 +213,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "transfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Account -<br>"..info.account.."<br>"..info.cid.."<br><br>- Balances -<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
|
||||
@@ -225,21 +227,21 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "savings" then
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Account Info -<br>Savings ID: "..info.aid.."<br>"..info.cid.."<br><br>- Balances -<br>💰Savings - $"..cv(info.savbal).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
|
||||
setheader = "💰 Savings 💰"
|
||||
setinputs = { { type = 'radio', name = 'billtype', text = setview, options = setoptions },
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💵 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Savings", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "society" then
|
||||
setoptions = { { value = "withdraw", text = "Withdrawl" }, { value = "deposit", text = "Deposit" } }
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
|
||||
@@ -251,8 +253,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "societytransfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerJob.label.."<br><br>- Balances -<br>🏢"..PlayerJob.label.." - $"..cv(society).."<br><br>- Options -"
|
||||
@@ -265,8 +267,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "gang" then
|
||||
setheader = "🏢 Society Banking 🏢"
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br>🏦Bank - $"..cv(info.bank).."<br><br>- Options -"
|
||||
@@ -278,8 +280,8 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
|
||||
end, data.icon)
|
||||
|
||||
elseif data.id == "gangtransfer" then
|
||||
setoptions = { { value = "transfer", text = "Transfer" } }
|
||||
setview = "Welcome back, "..info.name.."<br><br>- Society Account -<br>"..PlayerGang.label.."<br><br>- Balances -<br>🏢"..PlayerGang.label.." - $"..cv(gsociety).."<br><br>- Options -"
|
||||
@@ -289,13 +291,13 @@ RegisterNetEvent('jim-payments:Client:ATM:use', function(data)
|
||||
{ type = 'number', isRequired = true, name = 'amount', text = '💸 Amount to transfer' }, }
|
||||
PlayATMAnimation('enter')
|
||||
QBCore.Functions.Progressbar("accessing_atm", "Accessing Transfers", atmbartime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = false, }, {}, {}, {}, function() -- Done
|
||||
|
||||
|
||||
end, function()
|
||||
TriggerEvent("QBCore:Notify", "Cancelled!", "error")
|
||||
cancelled = true
|
||||
end, data.icon)
|
||||
end, data.icon)
|
||||
end
|
||||
|
||||
|
||||
Wait(atmbartime+500)
|
||||
if not cancelled then
|
||||
cancelled = false
|
||||
@@ -327,7 +329,7 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
|
||||
if nearbyList[#nearbyList] == nil then TriggerEvent("QBCore:Notify", "No one near by to charge", "error") return end
|
||||
local dialog = exports['qb-input']:ShowInput({ header = "Give someone cash", submitText = "Give",
|
||||
inputs = {
|
||||
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
||||
{ text = " ", name = "citizen", type = "select", options = nearbyList },
|
||||
{ type = 'number', isRequired = true, name = 'price', text = '💵 Amount to Pay' }, }
|
||||
})
|
||||
if dialog then
|
||||
@@ -338,6 +340,6 @@ RegisterNetEvent('jim-payments:client:ATM:give', function()
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end
|
||||
for k, v in pairs(Targets) do exports['qb-target']:RemoveZone(k) end
|
||||
for k, v in pairs(Peds) do DeletePed(Peds[k]) 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)
|
||||
Reference in New Issue
Block a user