7 Commits

Author SHA1 Message Date
Jim Shield
9eb2e987d4 Version Bump
`3.0.01` - `3.0.02`
2025-05-14 20:25:05 +01:00
Jim Shield
e73520a10c Tidy up the double check for commPercent
Left in the old code for commission calculation

I don't think it was making a difference but it wasn't needed
2025-05-14 20:24:47 +01:00
Jim Shield
f869c682c1 fix missing variable for polcharge
Fixes missing variable when using /polcharge and the confirmation option
2025-05-14 20:23:41 +01:00
Jim Shield
ca625c50e2 fix duplicate text entry for charging users
Apparently missed this completely, removed the duplicate text entry when not using the list option

this should fix any issues with this
2025-05-14 20:23:03 +01:00
Jim Shield
49f4d404e3 place start functions behind onResourceStart()
ESX helper
2025-05-12 22:49:28 +01:00
Jim Shield
2b92f749b5 Refactor a couple files for readability 2025-05-12 10:49:00 +01:00
Jim Shield
5e80192cef Update fxmanifest.lua to new format
Removes core loading in `fxmanifest.lua` in favour of more "verbose" file loader in jim_bridge v`2.0.08+`
2025-05-10 20:08:03 +01:00
8 changed files with 163 additions and 127 deletions

View File

@@ -43,9 +43,28 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[1] then triggerNotify(nil, locale("error" ,"no_one"), "error") return end if not nearbyList[1] then
triggerNotify(nil, locale("error" ,"no_one"), "error")
return
end
newinputs[#newinputs+1] = {
type = "select",
text = locale("menu", "cus_id"),
name = "citizen",
label = locale("menu", "cus_id"),
default = 1,
options = nearbyList
}
else -- If Config.List is false, create input text box for ID's 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 = locale("menu" ,"person_id"), text = locale("menu" ,"person_id") } newinputs[#newinputs+1] = {
type = 'text',
isRequired = true,
required = true,
name = 'citizen',
label = locale("menu", "cus_id"),
text = locale("menu", "cus_id")
}
end end
--Grab Player Job name or Gang Name if needed --Grab Player Job name or Gang Name if needed
@@ -53,11 +72,6 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
--Check if image was given when opening the regsiter --Check if image was given when opening the regsiter
local img = data.img ~= nil and (Config.System.Menu == "qb" and "<center><img src="..(data.img).." width=200px></center>") or Jobs[getInfo.job].label local img = data.img ~= nil and (Config.System.Menu == "qb" and "<center><img src="..(data.img).." width=200px></center>") or Jobs[getInfo.job].label
if Config.General.List then
newinputs[#newinputs+1] = { type = "select", text = locale("menu" ,"cus_id"), name = "citizen", label = locale("menu" ,"cus_id"), default = 1, options = nearbyList }
else
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = locale("menu" ,"cus_id") }
end
newinputs[#newinputs+1] = { newinputs[#newinputs+1] = {
type = 'select', type = 'select',
name = 'billtype', name = 'billtype',
@@ -73,7 +87,11 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
local dialog = createInput(img, newinputs) local dialog = createInput(img, newinputs)
if dialog then if dialog then
if dialog[1] then if dialog[1] then -- if ox menu, auto adjust values
if dialog[1] == "" then
TriggerEvent(getScript()..":client:Charge", data, outside)
return
end
dialog.citizen = dialog[1] dialog.citizen = dialog[1]
dialog.billtype = dialog[2] dialog.billtype = dialog[2]
dialog.price = dialog[3] dialog.price = dialog[3]
@@ -85,7 +103,7 @@ end)
RegisterNetEvent(getScript()..":client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside) RegisterNetEvent(getScript()..":client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside)
local setimage = "" local setimage = ""
print(billerjob)
if not img then if not img then
setimage = billerjob setimage = billerjob
else else
@@ -134,7 +152,7 @@ RegisterNetEvent(getScript()..":client:PayPopup", function(amount, biller, billt
}) })
end, end,
} }
debugPrint(setimage)
openMenu(Menu, { openMenu(Menu, {
header = setimage, header = setimage,
onExit = function() onExit = function()

View File

@@ -2,38 +2,69 @@ RegisterNetEvent(getScript()..":client:PolCharge", function()
local Playerinfo = getPlayer() local Playerinfo = getPlayer()
--Check if player is allowed to use /cashregister command --Check if player is allowed to use /cashregister command
local allowed = false local allowed = false
for k in pairs(Config.PolCharge.FineJobs) do if k == Playerinfo.job then allowed = true end end for k in pairs(Config.PolCharge.FineJobs) do
if not allowed then triggerNotify(nil, locale("error", "no_job"), "error") return end if k == Playerinfo.job then
allowed = true
break
end
end
if not allowed then
triggerNotify(nil, locale("error", "no_job"), "error")
return
end
local newinputs = {} -- Begin qb-input creation here. local newinputs = {} -- Begin qb-input creation here.
local nearbyList = {} local nearbyList = {}
if Config.PolCharge.FineJobList then -- If nearby player list is wanted: if Config.PolCharge.FineJobList then -- If nearby player list is wanted:
--Retrieve a list of nearby players from server -- Retrieve a list of nearby players from server
local onlineList = triggerCallback(getScript()..":MakePlayerList") local onlineList = triggerCallback(getScript()..":MakePlayerList")
--Convert list of players nearby into one qb-input understands + add distance info -- Convert list of players nearby into one an input script understands + add distance info
for _, v in pairs(Core.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.General.PaymentRadius)) do for _, v in pairs(Core.Functions.GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), Config.General.PaymentRadius)) do
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId())) local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) then if onlineList[i].value == GetPlayerServerId(v) then
if v ~= PlayerId() or debugMode 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)' } 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
end end
end end
--If list is empty(no one nearby) show error and stop --If list is empty(no one nearby) show error and stop
if not nearbyList[1] then triggerNotify(nil, locale("error" ,"no_one"), "error") return end if not nearbyList[1] then
triggerNotify(nil, locale("error" ,"no_one"), "error")
return
end end
if Config.PolCharge.FineJobList then newinputs[#newinputs+1] = {
newinputs[#newinputs+1] = { type = "select", text = locale("menu" ,"cus_id"), name = "citizen", label = locale("menu" ,"cus_id"), default = 1, options = nearbyList } type = "select",
text = locale("menu" ,"cus_id"),
name = "citizen",
label = locale("menu" ,"cus_id"),
default = 1,
options = nearbyList
}
else else
newinputs[#newinputs+1] = { type = 'text', isRequired = true, name = 'citizen', text = locale("menu" ,"cus_id") } newinputs[#newinputs+1] = {
type = 'text',
isRequired = true,
name = 'citizen',
text = locale("menu" ,"cus_id")
}
end end
newinputs[#newinputs+1] = { type = 'number', isRequired = true, name = 'price', text = locale("menu" ,"amount_charge") } newinputs[#newinputs+1] = {
type = 'number',
isRequired = true,
name = 'price',
text = locale("menu" ,"amount_charge")
}
local dialog = createInput(Jobs[Playerinfo.job].label, newinputs) local dialog = createInput(Jobs[Playerinfo.job].label, newinputs)
if dialog then if dialog then
jsonPrint(dialog)
if dialog[1] then if dialog[1] then
dialog.citizen = dialog[1] dialog.citizen = dialog[1]
dialog.price = dialog[2] dialog.price = dialog[2]
@@ -42,9 +73,13 @@ RegisterNetEvent(getScript()..":client:PolCharge", function()
end end
end) end)
RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob) RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob, commPercent)
local Menu = {} local Menu = {}
Menu[#Menu+1] = { isMenuHeader = true, header = "", txt = locale("menu" ,"bank_charge")..amount } Menu[#Menu+1] = {
isMenuHeader = true,
header = "",
txt = locale("menu" ,"bank_charge")..amount
}
Menu[#Menu+1] = { Menu[#Menu+1] = {
icon = "fas fa-circle-check", icon = "fas fa-circle-check",
header = locale("menu" ,"yes"), header = locale("menu" ,"yes"),
@@ -54,6 +89,7 @@ RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, bille
accept = true, accept = true,
amount = amount, amount = amount,
biller = biller, biller = biller,
commPercent = commPercent,
}) })
end, end,
} }

View File

@@ -1,7 +1,7 @@
name "Jim-Payments" name "Jim-Payments"
author "Jimathy" author "Jimathy"
version "3.0.01" version "3.0.02"
description "Payment Script By Jimathy" description "Payment Script"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"
lua54 'yes' lua54 'yes'
@@ -12,25 +12,12 @@ shared_scripts {
'locales/*.lua', 'locales/*.lua',
'config.lua', 'config.lua',
-- Required core scripts --Jim Bridge - https://github.com/jimathy/jim-bridge
'@ox_lib/init.lua',
'@ox_core/lib/init.lua',
'@es_extended/imports.lua',
'@qbx_core/modules/playerdata.lua',
--Jim Bridge
'@jim_bridge/starter.lua', '@jim_bridge/starter.lua',
'shared/*.lua', 'shared/*.lua',
} }
client_scripts { client_scripts {
'@PolyZone/client.lua',
'@PolyZone/BoxZone.lua',
'@PolyZone/EntityZone.lua',
'@PolyZone/CircleZone.lua',
'@PolyZone/ComboZone.lua',
'client/*.lua', 'client/*.lua',
} }

View File

@@ -1,10 +1,49 @@
registerCommand("cashgive", { onResourceStart(function()
registerCommand("cashgive", {
locale("command" , "pay_user"), {}, false, locale("command" , "pay_user"), {}, false,
function(source) function(source)
TriggerClientEvent(getScript()..":client:ATM:give", source) TriggerClientEvent(getScript()..":client:ATM:give", source)
end end
}) })
createCallback(getScript()..":GetInfo", function(source)
local Player = getPlayer(source)
local society, gsociety = 0, 0
society = getSocietyAccount(Player.job)
if Player.gang ~= "none" then
gsociety = getSocietyAccount(Player.gang)
end
-- Savings account is only QBCore for now
if isStarted(QBExport) and not isStarted(QBXExport) then
-- Grab Savings account info
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.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
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)
end, true)
RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety) RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, baccount, account, society, gsociety)
local src = source local src = source
@@ -207,44 +246,6 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
end end
end) end)
createCallback(getScript()..":GetInfo", function(source)
local Player = getPlayer(source)
local society, gsociety = 0, 0
society = getSocietyAccount(Player.job)
if Player.gang ~= "none" then
gsociety = getSocietyAccount(Player.gang)
end
-- Savings account is only QBCore for now
if isStarted(QBExport) and not isStarted(QBXExport) then
-- Grab Savings account info
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.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
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)
RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price) RegisterServerEvent(getScript()..":server:ATM:give", function(citizen, price)
local Player = getPlayer(source) local Player = getPlayer(source)
local Reciever = getPlayer(tonumber(citizen)) local Reciever = getPlayer(tonumber(citizen))

View File

@@ -9,16 +9,15 @@ onResourceStart(function()
if Items and not Items["payticket"] then if Items and not Items["payticket"] then
debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7") debugPrint("^1Error^7: ^2Unable to find ^7'^3payticket^7' ^2item it in the Shared^7")
end end
end, true)
registerCommand("cashregister", { registerCommand("cashregister", {
locale("command", "cash_reg"), {}, false, locale("command", "cash_reg"), {}, false,
function(source) function(source)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true) TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end end
}) })
createCallback(getScript()..":MakePlayerList", function(source) createCallback(getScript()..":MakePlayerList", function(source)
local onlineList = {} local onlineList = {}
for _, v in pairs(GetPlayers()) do for _, v in pairs(GetPlayers()) do
if v ~= nil or type(v) ~= "number" then if v ~= nil or type(v) ~= "number" then
@@ -28,7 +27,15 @@ createCallback(getScript()..":MakePlayerList", function(source)
end end
end end
return onlineList return onlineList
end) end)
if Config.General.Usebzzz then
createUseableItem('terminal', function(source, item)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end)
end
end, true)
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang) RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
local src = source local src = source
@@ -94,11 +101,3 @@ RegisterServerEvent(getScript()..":server:PayPopup", function(data)
triggerNotify(nil, billed.firstname..locale("error", "decline_pay")..data.amount..locale("success", "payment"), "error", data.biller) triggerNotify(nil, billed.firstname..locale("error", "decline_pay")..data.amount..locale("success", "payment"), "error", data.biller)
end end
end) end)
CreateThread(function()
if Config.General.Usebzzz then
createUseableItem('terminal', function(source, item)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end)
end
end)

View File

@@ -1,9 +1,11 @@
registerCommand("polcharge", { onResourceStart(function()
registerCommand("polcharge", {
locale("command", "charge"), {}, false, locale("command", "charge"), {}, false,
function(source) function(source)
TriggerClientEvent(getScript()..":client:PolCharge", source) TriggerClientEvent(getScript()..":client:PolCharge", source)
end end
}) })
end, true)
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price) RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local src = source local src = source
@@ -12,12 +14,7 @@ RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local price = math.floor(tonumber(price)) local price = math.floor(tonumber(price))
local commPercent = Config.PolCharge.FineJobs[biller.job] and Config.PolCharge.FineJobs[biller.job].Commission or 0.25 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)")
end
local commission = math.floor(price * commPercent) local commission = math.floor(price * commPercent)
if price > 0 then if price > 0 then

View File

@@ -3,11 +3,9 @@ RegisterServerEvent(getScript()..":Tickets:Give", function(data, biller, gang)
local activePlayers = GetPlayers() local activePlayers = GetPlayers()
local commPercent = 0 local commPercent = 0
jsonPrint(data) jsonPrint(data)
if Config.Receipts.Jobs[data.society] then
commPercent = Config.Receipts.Jobs[data.society].Commission local commPercent = Config.PolCharge.FineJobs[data.society] and Config.PolCharge.FineJobs[data.society].Commission or 0.25
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) 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 if biller ~= nil then -- If this is found, it ISN'T a phone payment, so add money to society here

View File

@@ -1 +1 @@
3.0.01 3.0.02