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
--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
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
--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
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] = {
type = 'select',
name = 'billtype',
@@ -73,7 +87,11 @@ RegisterNetEvent(getScript()..":client:Charge", function(data, outside)
local dialog = createInput(img, newinputs)
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.billtype = dialog[2]
dialog.price = dialog[3]
@@ -85,7 +103,7 @@ end)
RegisterNetEvent(getScript()..":client:PayPopup", function(amount, biller, billtype, img, billerjob, gang, outside)
local setimage = ""
print(billerjob)
if not img then
setimage = billerjob
else
@@ -134,7 +152,7 @@ RegisterNetEvent(getScript()..":client:PayPopup", function(amount, biller, billt
})
end,
}
debugPrint(setimage)
openMenu(Menu, {
header = setimage,
onExit = function()

View File

@@ -2,38 +2,69 @@ RegisterNetEvent(getScript()..":client:PolCharge", function()
local Playerinfo = getPlayer()
--Check if player is allowed to use /cashregister command
local allowed = false
for k in pairs(Config.PolCharge.FineJobs) do if k == Playerinfo.job then allowed = true end end
if not allowed then triggerNotify(nil, locale("error", "no_job"), "error") return end
for k in pairs(Config.PolCharge.FineJobs) do
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 nearbyList = {}
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")
--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
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(PlayerPedId()))
for i = 1, #onlineList do
if onlineList[i].value == GetPlayerServerId(v) 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
--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
end
if not nearbyList[1] then
triggerNotify(nil, locale("error" ,"no_one"), "error")
return
end
if Config.PolCharge.FineJobList then
newinputs[#newinputs+1] = { type = "select", text = locale("menu" ,"cus_id"), name = "citizen", label = locale("menu" ,"cus_id"), default = 1, options = nearbyList }
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") }
newinputs[#newinputs+1] = {
type = 'text',
isRequired = true,
name = 'citizen',
text = locale("menu" ,"cus_id")
}
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)
if dialog then
jsonPrint(dialog)
if dialog[1] then
dialog.citizen = dialog[1]
dialog.price = dialog[2]
@@ -42,9 +73,13 @@ RegisterNetEvent(getScript()..":client:PolCharge", function()
end
end)
RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob)
RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, billerjob, commPercent)
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] = {
icon = "fas fa-circle-check",
header = locale("menu" ,"yes"),
@@ -54,6 +89,7 @@ RegisterNetEvent(getScript()..":client:PolPopup", function(amount, biller, bille
accept = true,
amount = amount,
biller = biller,
commPercent = commPercent,
})
end,
}

View File

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

View File

@@ -1,10 +1,49 @@
registerCommand("cashgive", {
locale("command" , "pay_user"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:ATM:give", source)
end
})
onResourceStart(function()
registerCommand("cashgive", {
locale("command" , "pay_user"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:ATM:give", source)
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)
local src = source
@@ -207,44 +246,6 @@ RegisterServerEvent(getScript()..":server:ATM:use", function(amount, billtype, b
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)
local Player = getPlayer(source)
local Reciever = getPlayer(tonumber(citizen))

View File

@@ -9,26 +9,33 @@ onResourceStart(function()
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)
registerCommand("cashregister", {
locale("command", "cash_reg"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end
})
createCallback(getScript()..":MakePlayerList", function(source)
local onlineList = {}
for _, v in pairs(GetPlayers()) do
if v ~= nil or type(v) ~= "number" then
local Player = getPlayer(v)
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.name }
Wait(10)
registerCommand("cashregister", {
locale("command", "cash_reg"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end
})
createCallback(getScript()..":MakePlayerList", function(source)
local onlineList = {}
for _, v in pairs(GetPlayers()) do
if v ~= nil or type(v) ~= "number" then
local Player = getPlayer(v)
onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.name }
Wait(10)
end
end
return onlineList
end)
if Config.General.Usebzzz then
createUseableItem('terminal', function(source, item)
TriggerClientEvent(getScript()..":client:Charge", source, {}, true)
end)
end
return onlineList
end)
end, true)
RegisterServerEvent(getScript()..":server:Charge", function(citizen, price, billtype, img, outside, gang)
local src = source
@@ -93,12 +100,4 @@ RegisterServerEvent(getScript()..":server:PayPopup", function(data)
triggerNotify(nil, locale("success", "declined"), "error", src)
triggerNotify(nil, billed.firstname..locale("error", "decline_pay")..data.amount..locale("success", "payment"), "error", data.biller)
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", {
locale("command", "charge"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:PolCharge", source)
end
})
onResourceStart(function()
registerCommand("polcharge", {
locale("command", "charge"), {}, false,
function(source)
TriggerClientEvent(getScript()..":client:PolCharge", source)
end
})
end, true)
RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local src = source
@@ -12,12 +14,7 @@ RegisterServerEvent(getScript()..":server:PolCharge", function(citizen, price)
local price = math.floor(tonumber(price))
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)
if price > 0 then

View File

@@ -3,11 +3,9 @@ RegisterServerEvent(getScript()..":Tickets:Give", function(data, biller, gang)
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 commPercent = Config.PolCharge.FineJobs[data.society] and Config.PolCharge.FineJobs[data.society].Commission or 0.25
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

View File

@@ -1 +1 @@
3.0.01
3.0.02