mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-18 14:56:02 +01:00
v3.0 Beta Push
This commit is contained in:
336
client/atms.lua
336
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 = "<center><img src=https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png width=200px></center><br>"..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.."<br>"..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.."<br>"..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.."<br>"..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 = "<center><img src="..Config.General.menuLogo.." width=200px></center>"
|
||||
elseif Config.System.Menu == "ox" then header = ''
|
||||
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 = "<center><img src="..Config.General.menuLogo.." width=200px></center>"
|
||||
elseif Config.System.Menu == "ox" then setimage = ''
|
||||
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)
|
||||
|
||||
340
client/banks.lua
Normal file
340
client/banks.lua
Normal file
@@ -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 = "<center><img src="..Config.General.menuLogo.." width=200px></center>"
|
||||
elseif Config.System.Menu == "ox" then header = ''
|
||||
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 = "<center><img src="..Config.General.menuLogo.." width=200px></center>"
|
||||
elseif Config.System.Menu == "ox" then setimage = ''
|
||||
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
|
||||
145
client/charge.lua
Normal file
145
client/charge.lua
Normal file
@@ -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 = "<center><img src="..(data.img and data.img or "").." width=200px></center>"
|
||||
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 = "<center><img src="..(img and img or "").." width=200px></center>"
|
||||
elseif Config.System.Menu == "ox" then
|
||||
setimage = '..')'
|
||||
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)
|
||||
@@ -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)
|
||||
|
||||
]]
|
||||
1
client/polcharge.lua
Normal file
1
client/polcharge.lua
Normal file
@@ -0,0 +1 @@
|
||||
-- wip
|
||||
20
client/tickets.lua
Normal file
20
client/tickets.lua
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user