Update 3.0 beta

This commit is contained in:
Jim Shield
2025-02-21 13:54:49 +00:00
parent 38f360fc26
commit 2ebfeff554
12 changed files with 624 additions and 513 deletions

View File

@@ -52,7 +52,7 @@ Stream the prop and add the emote that is provided to rpemotes or dpemotes
- To make use of the ticket reward system for workers you need to add the ticket item to your shared items lua
- Naviage to `[qb] > qb-core / shared / items.lua` and add this line
```lua
["payticket"] = {["name"] = "payticket", ["label"] = "Receipt", ["weight"] = 150, ["type"] = "item", ["image"] = "ticket.png", ["unique"] = false, ["useable"] = false, ["shouldClose"] = false, ["combinable"] = nil, ["description"] = "Cash these in at the bank!"},
payticket = { name = "payticket", label = "Receipt", weight = 10, type = "item", image = "ticket.png", unique = false, useable = false, shouldClose = false, description = "Cash these in at the bank!" },
```
- Add the ticket image to your inventory script:
@@ -199,10 +199,6 @@ FineJobList = true, -- "true" to use nearby player list feature in the cash regi
- `ATMBlips` Enable this if you are a pyscho and need every ATM to be on the map too
- `Gabz` Enable to change to Gabz Bank locations, this corrects the ATM/Bank Cashier + Ticket Cash in
---
## Support for other scripts
### Renewed-Banking
- Support for renewed banking added
- Toggle `RenewedBanking` in the config.lua to enable this
### Renewed's qb-phone
- Simply leave the Config.PhoneType as `"qb"`

View File

@@ -7,13 +7,13 @@ if Config.ATMs.enable then
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)
local name, entCoords = getScript()..":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"],
createCircleTarget({name, vec3(entCoords.x, entCoords.y, entCoords.z+1.03), 0.5, { name=name, debugPoly = debugMode, useZ=true, },},
{ { action = function() lookEnt(v) TriggerEvent(getScript()..":Client:ATM") end,
icon = "fas fa-money-check-alt", label = locale("target", "atm"),
}, }, 1.5)
end
if Config.ATMs.showBlips then
@@ -34,64 +34,65 @@ if Config.ATMs.enable then
end)
end
RegisterNetEvent('jim-payments:Client:ATM', function() local setheader = nil
RegisterNetEvent(getScript()..":Client:ATM", function() local setheader = nil
--this grabs all the info from names to savings account numbers in the databases
local info = triggerCallback("jim-payments:GetInfo")
local info = triggerCallback(getScript()..":GetInfo")
playAnim("amb@prop_human_atm@male@enter", "enter", 2000, 1)
if progressBar({ label = Loc[Config.Lan].menu["acc_atm"], time = 3000 }) then
if progressBar({ label = locale("menu", "acc_atm"), time = 3000 }) then
local Menu = {}
Menu[#Menu+1] = {
isMenuHeader = true,
header = Loc[Config.Lan].menu["welcome"]..info.name,
header = locale("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)
header = locale("menu", "header_balance"),
txt = locale("menu", "bank_balance")..cv(info.bank)..br..locale("menu", "cash_balance")..cv(info.cash)
}
Menu[#Menu+1] = {
header = Loc[Config.Lan].menu["withdraw"],
header = locale("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 = '!['..''.. ']('..Config.General.menuLogo..')'
local header = locale("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 = '!['..''.. ']('..Config.General.menuLogo..')'
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")
triggerNotify(nil, locale("error", "cancel"), "error")
end
end)
function atmWithdrawl(info)
local setimage = Loc[Config.Lan].menu["header_atm"]
local setimage = locale("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 = '!['..''.. ']('..Config.General.menuLogo..')'
end
local dialog = createInput(Loc[Config.Lan].menu["header_atm"], {
local dialog = createInput(locale("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)
text = Config.System.Menu == "ox" and locale("menu", "bank_balance")..cv(info.bank)..locale("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"],
locale("menu", "header_balance")..br..
locale("menu", "bank_balance")..cv(info.bank)..br..
locale("menu", "cash_balance")..cv(info.cash)..br..br..
locale("menu", "header_option"),
options = {
{ value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] },
{ value = "withdraw", text = locale("menu", "withdraw") },
} },
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"],
text = locale("menu", "header_trans_amount"),
min = 0,
max = info.bank,
},
@@ -104,7 +105,7 @@ function atmWithdrawl(info)
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)
TriggerServerEvent(getScript()..":server:ATM:use", dialog.amount, dialog.billtype, dialog.account, "atm", info.society, info.gsociety)
end
end

View File

@@ -1,321 +1,343 @@
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
local name = getScript()..":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
if isStarted("jim-talktonpc") 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
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, }, }, {
{ name, vec3(v[i].x, v[i].y, v[i].z+0.2), 2.0, { name = name, debugPoly = debugMode, useZ = true, }, }, {
{ action = function()
if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then
if Config.General.Peds and isStarted("jim-talktonpc") then
exports["jim-talktonpc"]:createCam(Peds[name], true, "generic", true)
end
TriggerEvent("jim-payments:Client:Bank", { ped = Config.General.Peds and Peds[name] })
TriggerEvent(getScript()..":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,
icon = "fas fa-piggy-bank", label = locale("target", "bank") },
{ action = function() TriggerEvent(getScript()..":Tickets:Menu", { gang = false }) end,
icon = "fas fa-receipt", label = locale("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,
{ action = function() TriggerEvent(getScript()..":Tickets:Menu", { gang = true }) end,
icon = "fas fa-receipt", label = locale("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"] })
makeBlip({coords = v[i], sprite = 814, col = 2, scale = 0.7, disp = 6, name = locale("blip", "blip_bank") })
end
end
end
end
RegisterNetEvent('jim-payments:Client:Bank', function(data) local setheader = nil
RegisterNetEvent(getScript()..":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
local bankinfo = triggerCallback(getScript()..":GetInfo")
local info = getPlayer()
info.ped = data.ped or nil
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
if progressBar({ label = locale("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,
header = locale("menu", "welcome")..info.name,
txt = locale("menu", "header_acc").." "..info.account..br..info.citizenId,
}
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)
header = locale("menu", "header_acc")..locale("menu", "header_balance"),
txt = locale("menu", "bank_balance")..cv(info.bank)..br..locale("menu", "cash_balance")..cv(info.cash)
}
Menu[#Menu+1] = {
header = Loc[Config.Lan].menu["deposit"].."/"..Loc[Config.Lan].menu["withdraw"],
header = locale("menu", "deposit").."/"..locale("menu", "withdraw"),
icon = "fas fa-piggy-bank",
onSelect = function() info.id = "bank" bankTransaction(info) end,
onSelect = function()
info.id = "bank"
bankTransaction(info, bankinfo)
end,
}
if isStarted(QBExport) then -- only supports qbcore account transfers
Menu[#Menu+1] = {
header = locale("target", "transfer"),
icon = "fas fa-arrow-right-arrow-left",
onSelect = function()
info.id = "transfer"
bankTransaction(info, bankinfo)
end,
}
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"],
header = locale("target", "saving"),
icon = "fas fa-money-check-dollar",
onSelect = function() info.id = "savings" bankTransaction(info) end,
onSelect = function()
info.id = "savings"
bankTransaction(info, bankinfo)
end,
}
if PlayerJob.isboss then
if info.jobBoss then
Menu[#Menu+1] = {
header = Loc[Config.Lan].target["soc_saving"],
txt = PlayerJob.label,
header = locale("target", "soc_saving"),
txt = Jobs[info.job].label or "Error",
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,
onSelect = function()
info.id = "society"
bankTransaction(info, bankinfo)
end,
}
if isStarted(QBExport) then
Menu[#Menu+1] = {
header = locale("target", "soc_trans"),
txt = Jobs[info.job].label or "Error",
icon = "fas fa-arrow-right-arrow-left",
onSelect = function()
info.id = "societytransfer"
bankTransaction(info, bankinfo)
end,
}
end
end
if PlayerGang.isboss then
if info.gangBoss then
Menu[#Menu+1] = {
header = Loc[Config.Lan].target["gang_acct"],
txt = PlayerGang.label,
header = locale("target", "gang_acct"),
txt = Gangs[info.gang].label or "Error",
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,
onSelect = function()
info.id = "gang"
bankTransaction(info, bankinfo)
end,
}
if isStarted(QBExport) then
Menu[#Menu+1] = {
header = locale("target", "gang_trans"),
txt = Gangs[info.gang].label or "Error",
icon = "fas fa-arrow-right-arrow-left",
onSelect = function()
info.id = "gangtransfer"
bankTransaction(info, bankinfo)
end,
}
end
end
local header = Loc[Config.Lan].menu["header_atm"]
local header = locale("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 = '!['..''.. ']('..Config.General.menuLogo..')'
end
openMenu(Menu, { header = header, canClose = true, onExit = function()
if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then
if Config.General.Peds and isStarted("jim-talktonpc") 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")
triggerNotify(nil, locale("error", "cancel"), "error")
end
end)
function bankTransaction(info)
local setimage = Loc[Config.Lan].menu["header_atm"]
function bankTransaction(info, bankinfo)
local setimage = locale("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 = '!['..''.. ']('..Config.General.menuLogo..')'
end
playAnim("amb@prop_human_atm@male@idle_a", "idle_a", nil, 1)
exports["jim-talktonpc"]:injectEmotion("thanks", info.ped)
if isStarted("jim-talktonpc") then exports["jim-talktonpc"]:injectEmotion("thanks", info.ped) end
local setinputs, setheader = {}, ""
if info.id == "bank" then
setheader = Loc[Config.Lan].menu["header_bank"]
setheader = locale("menu", "header_bank")
setinputs = {
{ type = 'radio',
{ 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)
text = Config.System.Menu == "ox" and locale("menu", "bank_balance")..cv(info.bank)..locale("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"],
locale("menu", "header_balance")..br..
locale("menu", "bank_balance")..cv(info.bank)..br..
locale("menu", "cash_balance")..cv(info.cash)..br..br..
locale("menu", "header_option"),
options = {
{ value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] },
{ value = "deposit", text = Loc[Config.Lan].menu["deposit"] }
{ value = "withdraw", text = locale("menu", "withdraw") },
{ value = "deposit", text = locale("menu", "deposit") }
},
},
{ type = 'number',
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
elseif info.id == "transfer" then
setheader = Loc[Config.Lan].menu["header_trans"]
setheader = locale("menu", "header_trans")
setinputs = {
{ type = 'radio',
name = 'billtype',
text = Config.System.Menu == "ox" and Loc[Config.Lan].menu["bank_balance"]..cv(info.bank)
text = Config.System.Menu == "ox" and locale("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"],
locale("menu", "header_balance")..br..
locale("menu", "bank_balance")..cv(info.bank)..br..
locale("menu", "header_option"),
options = {
{ value = "transfer", text = Loc[Config.Lan].menu["transfer"] }
{ value = "transfer", text = locale("menu", "transfer") }
},
},
{ type = 'text',
isRequired = true,
name = 'account',
text = Loc[Config.Lan].menu["header_account_no"]
text = locale("menu", "header_account_no")
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"],
text = locale("menu", "header_trans_amount"),
min = 0,
max = info.bank,
},
}
elseif info.id == "savings" then
setheader = Loc[Config.Lan].menu["header_saving"]
setheader = locale("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)
text = Config.System.Menu == "ox" and locale("menu", "saving_balance")..cv(bankinfo.savbal)..locale("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"],
locale("menu", "header_balance")..br..
locale("menu", "saving_balance")..cv(bankinfo.savbal)..br..
locale("menu", "bank_balance")..cv(info.bank)..br..br..
locale("menu", "header_option"),
options = {
{ value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] },
{ value = "deposit", text = Loc[Config.Lan].menu["deposit"] }
{ value = "withdraw", text = locale("menu", "withdraw") },
{ value = "deposit", text = locale("menu", "deposit") }
}
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
elseif info.id == "society" then
setheader = PlayerJob.label.." - "..Loc[Config.Lan].menu["header_soc_bank"]
setheader = Jobs[info.job].label.." - "..locale("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)
text = Config.System.Menu == "ox" and Jobs[info.job].label.." - $"..cv(bankinfo.society)..locale("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"],
locale("menu", "header_balance")..br..
Jobs[info.job].label.." - $"..cv(bankinfo.society)..br..
locale("menu", "bank_balance")..cv(info.bank)..br..br..
locale("menu", "header_option"),
options = {
{ value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] },
{ value = "deposit", text = Loc[Config.Lan].menu["deposit"] }
{ value = "withdraw", text = locale("menu", "withdraw") },
{ value = "deposit", text = locale("menu", "deposit") }
}
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
elseif info.id == "societytransfer" then
setheader = PlayerJob.label.." - "..Loc[Config.Lan].menu["header_trans"]
setheader =Jobs[info.job].label.." - "..locale("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)
text = Config.System.Menu == "ox" and Jobs[info.job].label.." - $"..cv(bankinfo.society)..locale("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"] } }
locale("menu", "header_balance")..br..
Jobs[info.job].label.." - $"..cv(bankinfo.society)..br..
locale("menu", "bank_balance")..cv(info.bank)..br..br..
locale("menu", "header_option"),
options = { { value = "transfer", text = locale("menu", "transfer") } }
},
{ type = 'text',
isRequired = true,
name = 'account',
text = Loc[Config.Lan].menu["header_account_no"]
text = locale("menu", "header_account_no")
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
elseif info.id == "gang" then
setheader = PlayerGang.label.." - "..Loc[Config.Lan].menu["header_soc_bank"]
setheader = Gangs[info.gang].label.." - "..locale("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)
text = Config.System.Menu == "ox" and Gangs[info.gang].label.." - $"..cv(bankinfo.gsociety)..locale("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"],
locale("menu", "header_balance")..br..
Gangs[info.gang].label.." - $"..cv(bankinfo.gsociety)..br..
locale("menu", "bank_balance")..cv(info.bank)..br..br..
locale("menu", "header_option"),
options = {
{ value = "withdraw", text = Loc[Config.Lan].menu["withdraw"] },
{ value = "deposit", text = Loc[Config.Lan].menu["deposit"] }
{ value = "withdraw", text = locale("menu", "withdraw") },
{ value = "deposit", text = locale("menu", "deposit") }
}
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
elseif info.id == "gangtransfer" then
setheader = PlayerGang.label.." - "..Loc[Config.Lan].menu["header_soc_bank"]
setheader = Gangs[info.gang].label.." - "..locale("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)
text = Config.System.Menu == "ox" and Gangs[info.gang].label.." - $"..cv(bankinfo.gsociety)..locale("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"],
locale("menu", "header_balance")..br..
Gangs[info.gang].label.." - $"..cv(bankinfo.gsociety)..br..
locale("menu", "bank_balance")..cv(info.bank)..br..br..
locale("menu", "header_option"),
options = {
{ value = "transfer", text = Loc[Config.Lan].menu["transfer"] }
{ value = "transfer", text = locale("menu", "transfer") }
}
},
{ type = 'text',
isRequired = true,
name = 'account',
text = Loc[Config.Lan].menu["header_account_no"]
text = locale("menu", "header_account_no")
},
{ type = 'number',
isRequired = true,
name = 'amount',
text = Loc[Config.Lan].menu["header_trans_amount"]
text = locale("menu", "header_trans_amount")
},
}
end
@@ -327,14 +349,14 @@ function bankTransaction(info)
dialog.amount = dialog[2] or 1
end
if not dialog.amount then
TriggerEvent("jim-payments:Client:Bank", { ped = info.ped })
TriggerEvent(getScript()..":Client:Bank", { ped = info.ped })
return
end
if Config.General.Peds and GetResourceState("jim-talktonpc"):find("start") then
if Config.General.Peds and isStarted("jim-talktonpc") 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)
TriggerServerEvent(getScript()..":server:ATM:use", dialog.amount, dialog.billtype, dialog.account, info.id, bankinfo.society, bankinfo.gsociety)
end
end

View File

@@ -6,21 +6,17 @@ function spawnCustomRegisters()
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"], }
{ onSelect = function() TriggerEvent(getScript()..":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)
onPlayerLoaded(function() spawnCustomRegisters() end, true)
local billPrev = "cash"
RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
RegisterNetEvent(getScript()..":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
@@ -28,13 +24,13 @@ RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
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")
local onlineList = triggerCallback(getScript()..":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
if v ~= PlayerId() or debugMode 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
@@ -75,11 +71,11 @@ RegisterNetEvent('jim-payments:client:Charge', function(data, outside)
dialog.price = dialog[3]
end
billPrev = dialog.billtype
TriggerServerEvent('jim-payments:server:Charge', dialog.citizen, dialog.price, dialog.billtype, data.img, outside, gang)
TriggerServerEvent(getScript()..":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)
RegisterNetEvent(getScript()..":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>"
@@ -103,7 +99,7 @@ RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billty
header = Loc[Config.Lan].menu["yes"],
txt = "",
onSelect = function()
TriggerServerEvent("jim-payments:server:PayPopup", {
TriggerServerEvent(getScript()..":server:PayPopup", {
accept = true,
amount = amount,
biller = biller,
@@ -116,7 +112,7 @@ RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billty
icon = "fas fa-circle-xmark",
header = Loc[Config.Lan].menu["no"],
onSelect = function()
TriggerServerEvent("jim-payments:server:PayPopup", {
TriggerServerEvent(getScript()..":server:PayPopup", {
accept = false,
amount = amount,
biller = biller,
@@ -128,7 +124,7 @@ RegisterNetEvent("jim-payments:client:PayPopup", function(amount, biller, billty
openMenu(Menu, {
header = setimage,
onExit = function()
TriggerServerEvent("jim-payments:server:PayPopup", {
TriggerServerEvent(getScript()..":server:PayPopup", {
accept = false,
amount = amount,
biller = biller,

View File

@@ -1,4 +1,4 @@
RegisterNetEvent('jim-payments:client:PolCharge', function()
RegisterNetEvent(getScript()..":client:PolCharge", function()
--Check if player is allowed to use /cashregister command
local allowed = false
for k in pairs(Config.PolCharge.FineJobs) do if k == PlayerJob.name then allowed = true end end
@@ -8,13 +8,13 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
local nearbyList = {}
if Config.PolCharge.FineJobList then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server
local onlineList = triggerCallback("jim-payments:MakePlayerList")
local onlineList = triggerCallback(getScript()..":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
if v ~= PlayerId() or debugMode 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
@@ -37,11 +37,11 @@ RegisterNetEvent('jim-payments:client:PolCharge', function()
dialog.citizen = dialog[1]
dialog.price = dialog[2]
end
TriggerServerEvent('jim-payments:server:PolCharge', dialog.citizen, dialog.price)
TriggerServerEvent(getScript()..":server:PolCharge", dialog.citizen, dialog.price)
end
end)
RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, billerjob)
RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob)
local Menu = {}
Menu[#Menu+1] = { isMenuHeader = true, header = "", txt = Loc[Config.Lan].menu["bank_charge"]..amount }
Menu[#Menu+1] = {
@@ -49,7 +49,7 @@ RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, biller
header = Loc[Config.Lan].menu["yes"],
txt = "",
onSelect = function()
TriggerServerEvent("jim-payments:server:PolPopup", {
TriggerServerEvent(getScript()..":server:PolPopup", {
accept = true,
amount = amount,
biller = biller,
@@ -60,7 +60,7 @@ RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, biller
icon = "fas fa-circle-xmark",
header = Loc[Config.Lan].menu["no"],
onSelect = function()
TriggerServerEvent("jim-payments:server:PolPopup", {
TriggerServerEvent(getScript()..":server:PolPopup", {
accept = false,
amount = amount,
biller = biller,
@@ -71,7 +71,7 @@ RegisterNetEvent("jim-payments:client:PolPopup", function(amount, biller, biller
header = "🧾 "..billerjob..Loc[Config.Lan].menu["payment"],
headertxt = Loc[Config.Lan].menu["accept_payment"],
onExit = function()
TriggerServerEvent("jim-payments:server:PolPopup", {
TriggerServerEvent(getScript()..":server:PolPopup", {
accept = false,
amount = amount,
biller = biller,

View File

@@ -1,6 +1,9 @@
RegisterNetEvent('jim-payments:Tickets:Menu', function(data)
RegisterNetEvent(getScript()..":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
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)
@@ -13,7 +16,7 @@ RegisterNetEvent('jim-payments:Tickets:Menu', function(data)
}
Menu[#Menu+1] = {
icon = "fas fa-circle-check", header = Loc[Config.Lan].menu["yes"],
onSelect = function() TriggerServerEvent('jim-payments:Tickets:Sell') end,
onSelect = function() TriggerServerEvent(getScript()..":Tickets:Sell") end,
}
openMenu(Menu, { header = "🧾 "..label..Loc[Config.Lan].menu["receipt"], headertxt = Loc[Config.Lan].menu["trade_confirm"], canClose = true, })
end

View File

@@ -7,21 +7,22 @@ print("^2Jim^7-^2Payments ^7v^4"..GetResourceMetadata(GetCurrentResourceName(),
Config = {
Lan = "en",
System = {
Debug = true,
Debug = false,
EventDebug = false,
Menu = "qb", -- "qb", "ox", "gta"
Notify = "gta", -- "qb", "ox", "gta", "esx"
ProgressBar = "gta", -- "qb", "ox", "gta", "esx"
Notify = "qb", -- "qb", "ox", "gta", "esx"
ProgressBar = "qb", -- "qb", "ox", "gta", "esx"
},
Crafting = {
craftCam = true,
MultiCraft = true,
MultiCraftAmounts = { [1], [5], [10] },
showItemBox = true,
},
General = {
Banking = "qb-banking",
-- "qb-management" -- This is for the older version of QBCore
-- "qb-banking" -- This is for the latest QBCore updates
-- "renewed"
-- "fd" -- currently default supported
-- "okok" -- make sure to add societies to Config.Societies in okokBanking, This is for the latest QBCore updates
ApGov = false, -- Toggle support for AP-Goverment Tax
List = true, -- "true" to use nearby player list feature in the cash registers, "false" for manual id entry
@@ -57,11 +58,8 @@ Config = {
-- "qb" for qb-phone
-- "gks" for GKSPhone
useBanks = false, -- Enable this to use my banking stuff
BankBlips = false, -- Enable this if you disabled qb-banking and need bank locations
Gabz = true, -- "true" to enable Gabz Bank locations
Gabz = false, -- "true" to enable Gabz Bank locations
-- this corrects the ATM/Bank Cashier + Ticket Cash in locations
menuLogo = "https://static.wikia.nocookie.net/gtawiki/images/b/bd/Fleeca-GTAV-Logo.png",
@@ -69,7 +67,7 @@ Config = {
},
ATMs = {
enable = true,
enable = true, -- Enable this if wanting to use jim-payments atm systems
showBlips = true,
ATMModels = { `prop_atm_01`, `prop_atm_02`, `prop_atm_03`, `prop_fleeca_atm`, `gabz_sm_pb_atmframe` },
@@ -77,7 +75,7 @@ Config = {
},
Banks = {
enable = true,
enable = true, -- Enable this if wanting to use jim-payments banking systems
showBlips = true,
},
@@ -103,7 +101,7 @@ Config = {
vec4(252.23, 223.11, 106.29, 159.2), -- Default Third Window along in Pacific Bank
},
CashInAnywhere = true,
CashInAnywhere = true, -- enable this to add cash ticket option to any banking location
-- MinAmountforTicket should be your cheapest item
-- PayPerTicket should never be higher than MinAmountforTicket
@@ -156,3 +154,13 @@ Config = {
}
PlayerGang, PlayerJob, onDuty = {}, {}, nil
-- Test function for locales
function locale(section, string)
if not Config.Lan or Config.Lan == "" then return print("Error, no langauge set") end
local localTable = Loc[Config.Lan]
if not localTable then return "Locale Table Not Found" end
if not localTable[section] then return "["..section.."] Invalid" end
if not localTable[section][string] then return "["..string.."] Invalid" end
return localTable[section][string]
end

View File

@@ -14,15 +14,14 @@ shared_scripts {
-- Required core scripts
'@ox_lib/init.lua',
'@ox_core/imports/client.lua',
'@ox_core/lib/init.lua',
'@es_extended/imports.lua',
'@qbx_core/modules/playerdata.lua',
--Jim Bridge
'@jim_bridge/exports.lua',
'@jim_bridge/functions.lua',
'@jim_bridge/wrapper.lua',
'@jim_bridge/crafting.lua',
'@jim_bridge/starter.lua',
'shared/*.lua',
}
client_scripts {

View File

@@ -1,49 +1,60 @@
RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, baccount, account, society, gsociety)
Core.Commands.Add("cashgive",
Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent(getScript()..":client:ATM:give", source) end)
registerCommand("polcharge", {
Loc[Config.Lan].command["pay_user"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:ATM:give", source)
end
})
RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety)
local src = source
local Player = Core.Functions.GetPlayer(src)
local cashB = Player.Functions.GetMoney("cash")
local bankB = Player.Functions.GetMoney("bank")
local Player = getPlayer(src)
local amount = tonumber(amount)
local bankScript, newAmount = "", 0
--Simple transfers from bank to wallet --
if account == "bank" or account == "atm" then
if billtype == "withdraw" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
elseif bankB >= tonumber(amount) then
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
elseif Player.bank >= tonumber(amount) then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["from_bank"], "success") -- Don't really need this as phone gets notified when money is withdrawn
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
Player.Functions.AddMoney('cash', amount)
chargePlayer(amount, "bank", src) Wait(1500)
fundPlayer(amount, "cash", src)
end
elseif billtype == "deposit" then
if cashB < amount then triggerNotify(nil, Loc[Config.Lan].error["no_cash"], "error", src)
elseif cashB >= amount then
Player.Functions.RemoveMoney('cash', amount) Wait(1500)
Player.Functions.AddMoney('bank', amount)
if Player.cash < amount then
triggerNotify(nil, Loc[Config.Lan].error["no_cash"], "error", src)
elseif Player.cash >= amount then
chargePlayer(amount, "cash", src) Wait(1500)
fundPlayer(amount, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into_bank"], "success", src)
end
end
-- Transfers from bank to savings account --
elseif account == "savings" then
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
local getSavingsAccount = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
if getSavingsAccount[1] ~= nil then savbal = tonumber(getSavingsAccount[1].account_balance) aid = getSavingsAccount[1].citizenid end
if billtype == "withdraw" then
if savbal >= amount then
savbal -= amount
Player.Functions.AddMoney('bank', amount)
fundPlayer(amount, "cash", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["draw_save"], "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.PlayerData.citizenid}, function(success)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
if success then return true else return false end
end)
elseif savbal < amount then
triggerNotify(nil, Loc[Config.Lan].error["saving_low"], "error")
end
elseif billtype == "deposit" then
if amount < bankB then
if amount < Player.bank then
savbal += amount
Player.Functions.RemoveMoney('bank', amount)
chargePlayer(amount, "bank", src)
triggerNotify(nil, "$"..cv(amount)..Loc[Config.Lan].success["depos_save"], "success", src)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.PlayerData.citizenid}, function(success)
MySQL.Async.execute('UPDATE bank_accounts SET account_balance = ? WHERE citizenid = ?', { savbal, Player.citizenId}, function(success)
if success then return true else return false end
end)
else triggerNotify(nil, Loc[Config.Lan].error["bank_low"], "error", src)
@@ -52,27 +63,60 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
--Simple transfers from society account to bank --
elseif account == "society" then
if billtype == "withdraw" then
if tonumber(society) < amount then triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
if tonumber(society) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
elseif tonumber(society) >= amount then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Player.PlayerData.job.label..Loc[Config.Lan].success["account"], "success", src)
Player.Functions.AddMoney('bank', amount)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount) end
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports['Renewed-Banking']:removeAccountMoney(Player.job, amount)
newAmount = exports["Renewed-Banking"]:getAccountMoney(Player.job)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:RemoveMoney(Player.job, amount)
newAmount = exports["qb-banking"]:GetAccountBalance(Player.job)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
exports["fd_banking"]:RemoveMoney(Player.job, amount)
newAmount = exports["fd_banking"]:GetAccount(Player.job)
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:RemoveMoney(Player.job, amount)
newAmount = exports['okokBanking']:GetAccount(Player.job)
end
fundPlayer(amount, "bank", src)
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Removing ^7$"..amount.." ^2from account ^7'^6"..Player.job.."^7' ($"..newAmount..")")
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Jobs[Player.job].label..Loc[Config.Lan].success["account"], "success", src)
end
elseif billtype == "deposit" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif bankB >= amount then
if Config.Banking == "renewed" then exports['Renewed-Banking']:addAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:AddMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:AddMoney(tostring(Player.PlayerData.job.name), amount) end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Player.PlayerData.job.label..Loc[Config.Lan].success["account"], "success", src)
if Player.bank < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports['Renewed-Banking']:addAccountMoney(Player.job, amount)
newAmount = exports["Renewed-Banking"]:getAccountMoney(Player.job)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(Player.job, amount)
newAmount = exports["qb-banking"]:GetAccountBalance(Player.job)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
exports.fd_banking:AddMoney(Player.job, amount)
newAmount = exports["fd_banking"]:GetAccount(Player.job)
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(Player.job, amount)
newAmount = exports['okokBanking']:GetAccount(Player.job)
end
chargePlayer(amount, "bank", src) Wait(1500)
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Adding ^7$"..amount.." ^2to account ^7'^6"..Player.job.."^7' ($"..newAmount..")")
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Jobs[Player.job].label..Loc[Config.Lan].success["account"], "success", src)
end
end
-- Transfer from boss account to players --
--[[ disabled until i work out a system for other frameworks
elseif account == "societytransfer" then
local bannedCharacters = {'%','$',';'}
local newAmount = tostring(amount)
@@ -90,10 +134,15 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
local result = MySQL.Sync.fetchAll('SELECT * FROM players WHERE charinfo LIKE ?', {query})
if result[1] then
local Reciever = Core.Functions.GetPlayerByCitizenId(result[1].citizenid)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount) end
if Config.Banking == "renewed" then
exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-management" then
exports["qb-management"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "qb-banking" then
exports["qb-banking"]:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
elseif Config.Banking == "fd" then
exports.fd_banking:RemoveMoney(tostring(Player.PlayerData.job.name), amount)
end
if Reciever then
Reciever.Functions.AddMoney('bank', amount)
triggerNotify(nil, Loc[Config.Lan].success["sent"]..amount..Loc[Config.Lan].success["to"]..Reciever.PlayerData.charinfo.firstname.." "..Reciever.PlayerData.charinfo.lastname, "success", src)
@@ -105,29 +154,43 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
elseif not result[1] then triggerNotify(nil, Loc[Config.Lan].error["error_start"]..baccount..Loc[Config.Lan].error["error_end"], "error", src)
end
end
end]]
--Simple transfers from gang society account to bank --
elseif account == "gang" then
if billtype == "withdraw" then
if tonumber(gsociety) < amount then triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
if tonumber(gsociety) < amount then
triggerNotify(nil, Loc[Config.Lan].error["soc_low"], "error", src)
elseif tonumber(gsociety) >= amount then
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Player.PlayerData.gang.label..Loc[Config.Lan].success["account"], "success", src)
Player.Functions.AddMoney('bank', amount)
if Config.Banking == "renewed" then exports['Renewed-Banking']:removeAccountMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:RemoveGangMoney(tostring(Player.PlayerData.gang.name), amount) end
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:removeAccountMoney(Player.gang, amount)
elseif isStarted("qb-banking") then
exports["qb-banking"]:RemoveMoney(Player.gang, amount)
elseif isStarted("fd_banking") then
exports["fd_banking"]:RemoveGangMoney(Player.gang, amount)
elseif isStarted("okokBanking") then
exports["okokBanking"]:RemoveMoney(Player.gang, amount)
end
end
fundPlayer(amount, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["draw"]..cv(amount)..Loc[Config.Lan].success["fromthe"]..Gangs[Player.gang].label..Loc[Config.Lan].success["account"], "success", src)
elseif billtype == "deposit" then
if bankB < amount then triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif bankB >= amount then
if Config.Banking == "rewnewed" then exports['Renewed-Banking']:addAccountMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-management" then exports["qb-management"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "qb-banking" then exports["qb-banking"]:AddGangMoney(tostring(Player.PlayerData.gang.name), amount)
elseif Config.Banking == "fd" then exports.fd_banking:AddGangMoney(tostring(Player.PlayerData.gang.name), amount) end
if Player.bank < amount then
triggerNotify(nil, Loc[Config.Lan].error["nomoney_bank"], "error", src)
elseif Player.bank >= amount then
if isStarted("Renewed-Banking") then
exports['Renewed-Banking']:addAccountMoney(Player.gang, amount)
elseif isStarted("qb-banking") then
exports["qb-banking"]:AddGangMoney(Player.gang, amount)
elseif isStarted("fd_banking") then
exports["fd_banking"]:AddGangMoney(Player.gang, amount)
elseif isStarted("okokBanking") then
exports["okokBanking"]:AddMoney(Player.gang, amount)
end
Player.Functions.RemoveMoney('bank', amount) Wait(1500)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Player.PlayerData.gang.label..Loc[Config.Lan].success["account"], "success", src)
triggerNotify(nil, Loc[Config.Lan].success["deposited"]..cv(amount)..Loc[Config.Lan].success["into"]..Gangs[Player.gang].label..Loc[Config.Lan].success["account"], "success", src)
end
end
-- Transfer from gang account to players --
@@ -200,68 +263,69 @@ RegisterServerEvent('jim-payments:server:ATM:use', function(amount, billtype, ba
end
end)
createCallback('jim-payments:GetInfo', function(source, cb)
local Player = Core.Functions.GetPlayer(source)
local name = Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname
local cid = Player.PlayerData.citizenid.." ["..source.."]"
local cash = Player.Functions.GetMoney("cash")
local bank = Player.Functions.GetMoney("bank")
local account = Player.PlayerData.charinfo.account
local society = 0
local gsociety = 0
createCallback(getScript()..":GetInfo", function(source)
local Player = getPlayer(source)
local society, gsociety = 0, 0
if Config.General.Banking == "qb-banking" then
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts')
for _, v in pairs(result) do
if Player.PlayerData.job.name == v.account_name then society = v.account_balance end
if isStarted("Renewed-Banking") then
society = exports["Renewed-Banking"]:getAccountMoney(Player.job)
if Player.gang ~= "none" then
gsociety = exports["Renewed-Banking"]:getAccountMoney(Player.gang)
end
if Player.PlayerData.gang.name ~= "none" then
for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.account_name then gsociety = v.account_balance end
elseif isStarted("qb-banking") then
if not exports["qb-banking"]:GetAccount(Player.job) then
print("Making new bank account in qb-banking for "..Player.job)
exports["qb-banking"]:CreateJobAccount(Player.job, 0) Wait(150) -- make new account if return "null"
end
society = exports["qb-banking"]:GetAccountBalance(Player.job)
if Player.gang ~= "none" then
if not exports["qb-banking"]:GetAccount(Player.gang) then
print("Making new bank account in qb-banking for "..Player.gang)
exports["qb-banking"]:CreateGangAccount(Player.gang, 0) Wait(150) -- make new account if return "null"
society = exports["qb-banking"]:GetAccountBalance(Player.gang)
end
society = exports["qb-banking"]:GetAccountBalance(Player.gang)
end
-- If qb-management, grab info directly from database
elseif not Config.General.Banking == "renewed" then
local result = MySQL.Sync.fetchAll('SELECT * FROM management_funds')
for _, v in pairs(result) do
if Player.PlayerData.job.name == v.job_name then society = v.amount end
elseif isStarted("fd_banking") then
society = exports["fd_banking"]:GetAccount(Player.job)
if Player.gang ~= "none" then
gsociety = exports["fd_banking"]:GetGangAccount(Player.gang)
end
if Player.PlayerData.gang.name ~= "none" then
for _, v in pairs(result) do
if Player.PlayerData.gang.name == v.job_name then gsociety = v.amount end
end
elseif isStarted("okokBanking") then
society = exports["okokBanking"]:GetAccount(Player.job)
if Player.gang ~= "none" then
gsociety = exports["okokBanking"]:GetAccount(Player.gang)
end
else
end
-- Grab Savings account info
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
if result[1] then
accountID = result[1].citizenid
savingBalance = result[1].account_balance
else
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, account_name, account_balance) VALUES (?, ?, ?)', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, 0}, function() completed = true end) repeat Wait(0) until completed == true
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.PlayerData.citizenid, 'Savings_'..Player.PlayerData.citizenid, })
MySQL.Async.insert('INSERT INTO bank_accounts (citizenid, account_name, account_balance) VALUES (?, ?, ?)', { Player.citizenId, 'Savings_'..Player.citizenId, 0}, function() completed = true end) repeat Wait(0) until completed == true
local result = MySQL.Sync.fetchAll('SELECT * FROM bank_accounts WHERE citizenid = ? AND account_name = ?', { Player.citizenId, 'Savings_'..Player.citizenId, })
accountID = result[1].citizenid
savingBalance = result[1].account_balance
end
local retTable = {name = name,
cash = cash,
bank = bank,
account = account,
cid = cid,
savbal = savingBalance,
aid = accountID,
society = society,
gsociety = gsociety}
if GetResourceState(OXLibExport):find("start") then return retTable
else return cb(retTable) end
local retTable = {
name = Player.firstname..' '..Player.lastname,
cash = Player.cash,
bank = Player.bank,
account = Player.account,
cid = Player.citizenId.." ["..source.."]",
savbal = savingBalance,
aid = accountID,
society = society,
gsociety = gsociety
}
return retTable
end)
Core.Commands.Add("cashgive", Loc[Config.Lan].command["pay_user"], {}, false, function(source) TriggerClientEvent("jim-payments:client:ATM:give", source) end)
RegisterServerEvent("jim-payments:server:ATM:give", function(citizen, price)
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
local Player = Core.Functions.GetPlayer(source)
local Reciever = Core.Functions.GetPlayer(tonumber(citizen))
local amount = tonumber(price)

View File

@@ -1,214 +1,104 @@
AddEventHandler('onResourceStart', function(r) if GetCurrentResourceName() ~= r then return end
onResourceStart(function()
for k in pairs(Config.Receipts.Jobs) do
while not Jobs do Wait(10) end
if not Jobs[k] and not Gangs[k] then
print("Jim-Payments: Config.Receipts.Jobs searched for job/gang '"..k.."' and couldn't find it in the Shared")
debugPrint("^1Error^7: ^5Config^7.^5Receipts^7.^5Jobs ^2searched for job/gang ^7'^3"..k.."^7' ^2and couldn't find it in the Shared^7")
end
end
end)
registerCommand("cashregister", { Loc[Config.Lan].command["cash_reg"], {}, false, function(source) TriggerClientEvent("jim-payments:client:Charge", source, {}, true) end })
if Items and not Items["payticket"] then
debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7")
end
end, true)
createCallback('jim-payments:MakePlayerList', function(source, cb)
registerCommand("cashregister", {
Loc[Config.Lan].command["cash_reg"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end
})
createCallback(getScript()..":MakePlayerList", function(source)
local onlineList = {}
for _, v in pairs(Core.Functions.GetPlayers()) do
for _, v in pairs(GetPlayers()) do
local Player = getPlayer(v)
onlineList[#onlineList+1] = {
value = tonumber(v),
text = "["..v.."] - "..Player.name
}
end
if GetResourceState(OXLibExport):find("start") then return onlineList
else cb(onlineList) end
return onlineList
end)
RegisterServerEvent("jim-payments:server:Charge", function(citizen, price, billtype, img, outside, gang)
print(citizen, price, billtype, img, outside, gang)
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
local src = source
local biller = Core.Functions.GetPlayer(src)
local billed = Core.Functions.GetPlayer(tonumber(citizen))
local biller = getPlayer(src)
local billed = getPlayer(tonumber(citizen))
local amount = tonumber(price)
local balance = billed.Functions.GetMoney(billtype)
local balance = billed[billtype]
if amount and amount > 0 then
if balance < amount then
triggerNotify(nil, Loc[Config.Lan].error["customer_nocash"], "error", src)
triggerNotify(nil, Loc[Config.Lan].error["you_nocash"], "error", tonumber(citizen))
return
end
local label = biller.PlayerData.job.label
if gang == true then label = biller.PlayerData.gang.label end
local label = gang == true and Gangs[biller.gang].label or Jobs[biller.job].label
if Config.General.PhoneBank == false or gang == true or billtype == "cash" then
TriggerClientEvent("jim-payments:client:PayPopup", billed.PlayerData.source, amount, src, billtype, img, label, gang, outside)
TriggerClientEvent(getScript()..":client:PayPopup", billed.source, amount, src, billtype, img, label, gang, outside)
else
if Config.General.PhoneType == "qb" then
MySQL.Async.insert(
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
{billed.PlayerData.citizenid, amount, biller.PlayerData.job.name, biller.PlayerData.charinfo.firstname, biller.PlayerData.citizenid}, function(id)
{billed.citizenid, amount, biller.job, biller.firstname, biller.citizenid}, function(id)
if id then
TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.PlayerData.source, id, biller.PlayerData.charinfo.firstname, biller.PlayerData.job.name, biller.PlayerData.citizenid, amount, GetInvokingResource())
TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', billed.source, id, biller.firstname, biller.job, biller.citizenid, amount, GetInvokingResource())
end
end)
TriggerClientEvent('qb-phone:RefreshPhone', billed.PlayerData.source)
TriggerClientEvent('qb-phone:RefreshPhone', billed.source)
elseif Config.General.PhoneType == "gks" then
MySQL.Async.execute('INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', {
['@citizenid'] = billed.PlayerData.citizenid,
['@citizenid'] = billed.citizenid,
['@amount'] = amount,
['@society'] = biller.PlayerData.job.name,
['@sender'] = biller.PlayerData.charinfo.firstname,
['@sendercitizenid'] = biller.PlayerData.citizenid,
['@label'] = biller.PlayerData.job.label,
['@society'] = biller.job,
['@sender'] = biller.firstname,
['@sendercitizenid'] = biller.citizenid,
['@label'] = label,
})
TriggerClientEvent('gksphone:notifi', src, {title = 'Billing', message = Loc[Config.Lan].success["inv_succ"], img= '/html/static/img/icons/logo.png' })
TriggerClientEvent('gksphone:notifi', billed.PlayerData.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' })
TriggerClientEvent('gksphone:notifi', billed.source, {title = 'Billing', message = Loc[Config.Lan].success["inv_recieved"], img= '/html/static/img/icons/logo.png' })
end
triggerNotify(nil, Loc[Config.Lan].success["inv_succ"], 'success', src)
triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["inv_recieved"], nil, billed.source)
end
else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end
end)
RegisterServerEvent("jim-payments:server:PayPopup", function(data)
RegisterServerEvent(getScript()..":server:PayPopup", function(data)
local src = source
local billed = Core.Functions.GetPlayer(src)
local biller = Core.Functions.GetPlayer(tonumber(data.biller))
local billed = getPlayer(src)
local biller = getPlayer(tonumber(data.biller))
local newdata = {
senderCitizenId = biller.PlayerData.citizenid,
society = data.gang and biller.PlayerData.gang.name or biller.PlayerData.job.name,
senderCitizenId = biller.citizenid,
society = data.gang and biller.gang or biller.job,
amount = data.amount
}
if data.accept then
billed.Functions.RemoveMoney(tostring(data.billtype), data.amount)
if Config.General.ApGov then exports['ap-government']:chargeCityTax(billed.PlayerData.source, "Item", data.amount) end
TriggerEvent('jim-payments:Tickets:Give', newdata, biller, data.gang)
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller)
chargePlayer(data.amount, data.billtype, src)
if Config.General.ApGov then
exports['ap-government']:chargeCityTax(billed.source, "Item", data.amount)
end
TriggerEvent(getScript()..":Tickets:Give", newdata, biller, data.gang)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].success["accepted_pay"]..data.amount..Loc[Config.Lan].success["payment"], "success", data.biller)
elseif not data.accept then
triggerNotify(nil, Loc[Config.Lan].success["declined"], "error", src)
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller)
end
end)
RegisterServerEvent('jim-payments:Tickets:Give', function(data, biller, gang) local src = source
local billed = Core.Functions.GetPlayer(src) -- This should always be from the person who accepted the payment
local takecomm = math.floor(data.amount * Config.Receipts.Jobs[data.society].Commission)
if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here
local billerGang, billerJob, amountChange, newAmount = tostring(biller.PlayerData.gang.name), tostring(biller.PlayerData.job.name), (data.amount - takecomm), 0
if gang then
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(billerGang, amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(billerGang)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange)
newAmount = exports[Config.General.Banking]:AddGangMoney(billerGang, amountChange)
if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddGangMoney(billerGang, amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(billerGang)
elseif Config.General.Banking == "okok" then
exports['okokBanking']:AddMoney(billerGang, amountChange)
newAmount = exports['okokBanking']:GetAccount(billerGang)
end
elseif not gang then
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(billerJob, amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(billerJob)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddMoney(billerJob, amountChange)
newAmount = exports[Config.General.Banking]:GetAccount(billerJob, amountChange)
if Config.General.Banking == "qb-banking" then newAmount = newAmount["account_balance"] end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddMoney(billerJob, amountChange)
newAmount = exports["fd_banking"]:GetAccount(billerJob)
elseif Config.General.Banking == "okok" then
exports['okokBanking']:AddMoney(billerJob, amountChange)
newAmount = exports['okokBanking']:GetAccount(billerJob)
end
end
print("^5Debug^7: ^3"..Config.General.Banking.."^7(^3"..(gang and "Gang" or "Job").."^7): ^2Adding ^7$"..amountChange.." ^2to account ^7'^6"..(gang and billerGang or billerJob).."^7' ($"..newAmount..")")
if Config.System.Debug then
end
elseif not biller then --Find the biller from their citizenid
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player.PlayerData.citizenid == data.senderCitizenId then biller = Player end
end
triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.PlayerData.source)
end
-- If ticket system enabled, do this
if (biller.PlayerData.job.onduty or gang) and Config.Receipts.TicketSystem then
if data.amount >= Config.Receipts.Jobs[data.society].MinAmountforTicket then
if Config.Receipts.TicketSystemAll then
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player ~= nil or Player ~= billed then
if gang then
if Player.PlayerData.gang.name == data.society then
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source)
end
else
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, Player.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.PlayerData.source)
end
end
end
end
else
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, "payticket", 1, biller.PlayerData.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.PlayerData.source)
end
end
end
-- Commission section, does each config option separately
local comm = tonumber(Config.Receipts.Jobs[data.society].Commission)
if Config.Receipts.Commission and comm ~= 0 then
if Config.Receipts.CommissionLimit and data.amount < Config.Receipts.Jobs[data.society].MinAmountforTicket then return end
if Config.Receipts.CommissionDouble then
biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * (comm *2)))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source)
else biller.Functions.AddMoney("bank", math.floor(tonumber(data.amount) *comm))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.PlayerData.source)
end
if Config.Receipts.CommissionAll then
for _, v in pairs(Core.Functions.GetPlayers()) do
local Player = Core.Functions.GetPlayer(v)
if Player and Player ~= biller then
if Player.PlayerData.job.name == data.society and Player.PlayerData.job.onduty then
Player.Functions.AddMoney("bank", math.floor(tonumber(data.amount) * comm))
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.PlayerData.source)
end
end
end
end
end
end)
RegisterServerEvent('jim-payments:Tickets:Sell', function()
local Player = Core.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName("payticket") then triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', source) return
else
tickets = Player.Functions.GetItemByName("payticket").amount
Player.Functions.RemoveItem('payticket', tickets)
pay = (tickets * Config.Receipts.Jobs[Player.PlayerData.job.name].PayPerTicket)
Player.Functions.AddMoney('bank', pay, 'ticket-payment')
TriggerClientEvent('inventory:client:ItemBox', source, Core.Shared.Items['payticket'], "remove", tickets)
triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', source)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].error["decline_pay"]..data.amount..Loc[Config.Lan].success["payment"], "error", data.biller)
end
end)
CreateThread(function()
if Config.Usebzzz then
Core.Functions.CreateUseableItem('terminal', function(source, item)
TriggerClientEvent("jim-payments:client:Charge", source, {}, true)
if Config.General.Usebzzz then
createUseableItem('terminal', function(source, item)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end)
end
end)

View File

@@ -1,14 +1,19 @@
registerCommand("polcharge", { Loc[Config.Lan].command["charge"], {}, false, function(source) TriggerClientEvent("jim-payments:client:PolCharge", source) end })
registerCommand("polcharge", {
Loc[Config.Lan].command["charge"], {}, false,
function(source)
TriggerClientEvent(getScript()..":client:PolCharge", source)
end
})
RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local src = source
local biller = Core.Functions.GetPlayer(src)
local billed = Core.Functions.GetPlayer(tonumber(citizen))
local biller = getPlayer(src)
local billed = getPlayer(tonumber(citizen))
local price = math.floor(tonumber(price))
local commPercent = Config.PolCharge.FineJobs[biller.PlayerData.job.name] and Config.PolCharge.FineJobs[biller.PlayerData.job.name].Commission or 0.25
if Config.PolCharge.FineJobs[biller.PlayerData.job.name] then
commPercent = Config.PolCharge.FineJobs[biller.PlayerData.job.name].Commission
local commPercent = Config.PolCharge.FineJobs[biller.job] and Config.PolCharge.FineJobs[biller.job].Commission or 0.25
if Config.PolCharge.FineJobs[biller.job] then
commPercent = Config.PolCharge.FineJobs[biller.job].Commission
else
commPercent = 0.25
print("Can't find job in 'FineJobs', defaulting to 0.25 (25% commission)")
@@ -22,22 +27,22 @@ RegisterServerEvent("jim-payments:server:PolCharge", function(citizen, price)
billed = billed,
price = price,
commission = commission,
billerJob = tostring(biller.PlayerData.job.name),
billerJob = tostring(biller.job),
amountChange = (price - commission)
})
triggerNotify(nil, billed.PlayerData.charinfo.firstname..Loc[Config.Lan].success["charged"]..(price - commission), "success", src)
triggerNotify(nil, Loc[Config.Lan].success["you_charged"]..(price - commission), nil, billed.PlayerData.source)
triggerNotify(nil, billed.firstname..Loc[Config.Lan].success["charged"]..(price - commission), "success", src)
triggerNotify(nil, Loc[Config.Lan].success["you_charged"]..(price - commission), nil, billed.source)
else
TriggerClientEvent("jim-payments:client:PolPopup", billed.PlayerData.source, price, src, biller.PlayerData.job.label, commPercent)
TriggerClientEvent(getScript()..":client:PolPopup", billed.source, price, src, biller.job, commPercent)
end
else triggerNotify(nil, Loc[Config.Lan].error["charge_zero"], 'error', source) return end
end)
RegisterServerEvent("jim-payments:server:PolPopup", function(data)
RegisterServerEvent(getScript()..":server:PolPopup", function(data)
local src = source
local billed = Core.Functions.GetPlayer(src)
local biller = Core.Functions.GetPlayer(tonumber(data.biller))
local billed = getPlayer(src)
local biller = getPlayer(tonumber(data.biller))
local price = math.floor(data.amount)
local commission = math.floor(tonumber(data.amount) * data.commPercent)
if data.accept then
@@ -46,7 +51,7 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
billed = billed,
price = price,
commission = commission,
billerJob = tostring(biller.PlayerData.job.name),
billerJob = tostring(biller.job),
amountChange = (price - commission)
})
elseif not data.accept then
@@ -56,36 +61,43 @@ RegisterServerEvent("jim-payments:server:PolPopup", function(data)
end)
function polCharge(data)
local billedSource, billerSource, newAmount = data.billed.PlayerData.source, data.biller.PlayerData.source, 0
if data.billed.Functions.RemoveMoney("bank", data.price) then
if Config.System.Debug then print("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billedSource.."^7) ^2charged ^7$^6"..data.price.."^7") end
local billedSource, billerSource, newAmount = data.billed.source, data.biller.source, 0
local bankScript = nil
chargePlayer(data.price, "bank", billedSource)
debugPrint("^5Debug^7: ^3PolCharge^7 - ^2Player^7(^6"..billedSource.."^7) ^2charged ^7$^6"..data.price.."^7")
if Config.ApGov then
exports['ap-government']:chargeCityTax(billedSource, "Item", data.price)
end
if Config.ApGov then exports['ap-government']:chargeCityTax(billedSource, "Item", data.price) end
if data.biller.Functions.AddMoney("bank", data.commission) then
if Config.System.Debug then
print("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..data.commission.." ^2sent to Player^7(^6"..billerSource.."^7)")
fundPlayer(data.commission, "bank", billerSource)
debugPrint("^5Debug^7: ^3PolCharge^7 - ^2Commission of ^7$^6"..data.commission.." ^2sent to Player^7(^6"..billerSource.."^7)")
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports["Renewed-Banking"]:addAccountMoney(data.billerJob, data.amountChange)
newAmount = exports["Renewed-Banking"]:getAccountMoney(data.billerJob)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(data.billerJob, data.amountChange, "Cash Register Payment")
newAmount = exports["qb-banking"]:GetAccountBalance(data.billerJob)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
if gang then
exports["fd_banking"]:AddGangMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(data.billerJob)
else
exports["fd_banking"]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetAccount(data.billerJob)
end
end
if Config.General.Banking == "renewed" then
exports['Renewed-Banking']:addAccountMoney(data.billerJob, data.amountChange)
newAmount = exports['Renewed-Banking']:getAccountMoney(data.billerJob)
elseif Config.General.Banking == "qb-management" or Config.General.Banking == "qb-banking" then
exports[Config.General.Banking]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports[Config.General.Banking]:GetAccount(data.billerJob)
if Config.General.Banking == "qb-banking" then newAmount = newAmount.account_balance end
elseif Config.General.Banking == "fd" then
exports["fd_banking"]:AddMoney(data.billerJob, data.amountChange)
newAmount = exports["fd_banking"]:GetAccount(data.billerJob)
elseif Config.General.Banking == "okok" then
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(data.billerJob, data.amountChange)
newAmount = exports['okokBanking']:GetAccount(data.billerJob)
end
end
if Config.System.Debug then
print("^5Debug^7: ^3"..Config.General.Banking.."^7(^3Job^7): ^2Adding ^7$"..data.amountChange.." ^2to account ^7'^6"..data.billerJob.."^7' ($"..newAmount..")")
end
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3Job^7): ^2Adding ^7$"..data.amountChange.." ^2to account ^7'^6"..data.billerJob.."^7' ($"..newAmount..")")
end

120
server/ticketserver.lua Normal file
View File

@@ -0,0 +1,120 @@
RegisterServerEvent(getScript()..":Tickets:Give", function(data, biller, gang)
local src = source
local activePlayers = GetPlayers()
local commPercent = 0
jsonPrint(data)
if Config.Receipts.Jobs[data.society] then
commPercent = Config.Receipts.Jobs[data.society].Commission
else commPercent = 0.25
print("^1Error^7: ^2Can't find job in ^7'^3Config^7.^3Receipts^7.^3Jobs^7', ^2defaulting to 0.25 (25% commission)^7")
end
local takecomm = math.floor(data.amount * commPercent)
if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here
local amountChange, newAmount = (data.amount - takecomm), 0
local society = gang and tostring(biller.gang) or tostring(biller.job)
local bankScript = nil
if isStarted("Renewed-Banking") then
bankScript = "Renewed-Banking"
exports["Renewed-Banking"]:addAccountMoney(society, amountChange)
newAmount = exports["Renewed-Banking"]:getAccountMoney(society)
elseif isStarted("qb-banking") then
bankScript = "qb-banking"
exports["qb-banking"]:AddMoney(society, amountChange, "Cash Register Payment")
newAmount = exports["qb-banking"]:GetAccountBalance(society)
elseif isStarted("fd_banking") then
bankScript = "fd_banking"
if gang then
exports["fd_banking"]:AddGangMoney(society, amountChange)
newAmount = exports["fd_banking"]:GetGangAccount(society)
else
exports["fd_banking"]:AddMoney(society, amountChange)
newAmount = exports["fd_banking"]:GetAccount(society)
end
elseif isStarted("okokBanking") then
bankScript = "okokBanking"
exports['okokBanking']:AddMoney(society, amountChange)
newAmount = exports['okokBanking']:GetAccount(society)
end
debugPrint("^5Debug^7: ^3"..bankScript.."^7(^3"..(gang and "Gang" or "Job").."^7): ^2Adding ^7$"..amountChange.." ^2to account ^7'^6"..society.."^7' ($"..newAmount..")")
elseif not biller then --Find the biller from their citizenid
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if Player.citizenid == data.senderCitizenId then
biller = Player
end
end
triggerNotify(nil, data.sender..Loc[Config.Lan].success["invoice_start"]..data.amount..Loc[Config.Lan].success["invoice_end"], "success", biller.source)
end
-- If ticket system enabled, do this
if (biller.onDuty or gang) and Config.Receipts.TicketSystem then
if data.amount >= Config.Receipts.Jobs[data.society].MinAmountforTicket then
if Config.Receipts.TicketSystemAll then
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if v ~= src then
if gang then
if Player.gang == data.society then
addItem("payticket", 1, nil, Player.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.source)
end
else
print("player found")
if Player.job == data.society and Player.onDuty then
print("player on duty, giving tickets")
addItem("payticket", 1, nil, Player.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', Player.source)
end
end
end
end
else
addItem("payticket", 1, nil, biller.source)
triggerNotify(nil, Loc[Config.Lan].success["rec_rec"], 'success', biller.source)
end
end
end
-- Commission section, does each config option separately
local comm = tonumber(Config.Receipts.Jobs[data.society].Commission)
if Config.Receipts.Commission and comm ~= 0 then
if Config.Receipts.CommissionLimit and data.amount < Config.Receipts.Jobs[data.society].MinAmountforTicket then return end
if Config.Receipts.CommissionDouble then
fundPlayer(math.floor(tonumber(data.amount) * (comm *2)), "bank", biller.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * (comm *2))..Loc[Config.Lan].success["commission"], "success", biller.source)
else
fundPlayer(math.floor(tonumber(data.amount) *comm), "bank", biller.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", biller.source)
end
if Config.Receipts.CommissionAll then
for _, v in pairs(activePlayers) do
local Player = getPlayer(v)
if v ~= biller.source then
if Player.job == data.society and Player.onDuty then
fundPlayer(math.floor(tonumber(data.amount) * comm), "bank", Player.source)
triggerNotify(nil, Loc[Config.Lan].success["recieved"]..math.floor(tonumber(data.amount) * comm)..Loc[Config.Lan].success["commission"], "success", Player.source)
end
end
end
end
end
end)
RegisterServerEvent(getScript()..":Tickets:Sell", function() local src = source
local Player = getPlayer(src)
local hasItem, hasTable = hasItem("payticket", 1, src)
if not hasItem then
triggerNotify(nil, Loc[Config.Lan].error["no_ticket_to"], 'error', src)
return
else
local tickets = hasTable["payticket"].count
removeItem("payticket", tickets, src)
local pay = (tickets * Config.Receipts.Jobs[Player.job].PayPerTicket)
fundPlayer(pay, "bank", src)
triggerNotify(nil, Loc[Config.Lan].success["trade_ticket_start"]..tickets..Loc[Config.Lan].success["trade_ticket_end"]..cv(pay), 'success', src)
end
end)