More + optimization

This commit is contained in:
Jim Shield
2025-08-14 20:08:09 +01:00
parent 0bcf1b7ed4
commit bfca698457
13 changed files with 997 additions and 835 deletions

View File

@@ -124,10 +124,12 @@ function craftingMenu(data)
itemTable[l] = b itemTable[l] = b
end end
while not canCarryTable do Wait(0) end while not canCarryTable do
Wait(10)
end
disable = not checkStashItem(data.stashName, itemTable) disable = not checkStashItem(data.stashName, itemTable)
setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k)) setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k))
..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "") ..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")
local statusEmoji = disable and " " or not canCarryTable[k] and " 📦" or " ✔️" local statusEmoji = disable and " " or not canCarryTable[k] and " 📦" or " ✔️"
local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "" or "" local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "" or ""

View File

@@ -8,96 +8,108 @@
-- Text system handlers -- Text system handlers
local textHandlers = { local textHandlers = {
qb = { qb = {
show = function(text, image) show =
if image then function(text, image)
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text if image then
end text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
exports[QBExport]:DrawText(text, 'left') end
end, exports[QBExport]:DrawText(text, 'left')
hide = function() end,
exports[QBExport]:HideText() hide =
end function()
exports[QBExport]:HideText()
end,
}, },
ox = { ox = {
show = function(input, image, oxStyleTable) show =
local inputCount = #input function(input, image, oxStyleTable)
for i = 1, inputCount do local inputCount = #input
input[i] = input[i] .. (i ~= inputCount and " \n" or "") for i = 1, inputCount do
end input[i] = input[i] .. (i ~= inputCount and " \n" or "")
lib.showTextUI(table.concat(input), { end
icon = (image and radarTable[image] or image) or nil, lib.showTextUI(table.concat(input), {
position = 'left-center', icon = (image and radarTable[image] or image) or nil,
style = oxStyleTable position = 'left-center',
}) style = oxStyleTable
end, })
hide = function() end,
lib.hideTextUI() hide =
end function()
lib.hideTextUI()
end,
}, },
lation = { lation = {
show = function(input, image) show =
local inputCount = #input function(input, image)
for i = 1, inputCount do local inputCount = #input
input[i] = input[i] .. (i ~= inputCount and " \n" or "") for i = 1, inputCount do
end input[i] = input[i] .. (i ~= inputCount and " \n" or "")
exports.lation_ui:showText({
description = table.concat(input),
keybind = nil,
icon = (image and radarTable[image] or image) or nil,
iconColor = '#3B82F6',
position = 'left-center'
})
end,
hide = function()
exports.lation_ui:hideText()
end
},
gta = {
show = function(input, image, style)
local text = ""
for i = 1, #input do
if input[i] ~= "" then
text = text .. input[i] .. "\n~s~"
end end
end exports.lation_ui:showText({
if image then description = table.concat(input),
text = "~BLIP_" .. image .. "~ " .. text keybind = nil,
end icon = (image and radarTable[image] or image) or nil,
DisplayHelpMsg(text:gsub("%:", ":~" .. (style or "g") .. "~")) iconColor = '#3B82F6',
end, position = 'left-center'
hide = function() })
ClearAllHelpMessages() end,
end hide =
function()
exports.lation_ui:hideText()
end,
}, },
esx = { esx = {
show = function(text, image) show =
if image then function(text, image)
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text if image then
end text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
ESX.TextUI(text, nil) end
end, ESX.TextUI(text, nil)
hide = function() end,
ESX.HideUI() hide =
end function()
ESX.HideUI()
end,
},
gta = {
show =
function(input, image, style)
local text = ""
for i = 1, #input do
if input[i] ~= "" then
text = text .. input[i] .. "\n~s~"
end
end
if image then
text = "~BLIP_" .. image .. "~ " .. text
end
DisplayHelpMsg(text:gsub("%:", ":~" .. (style or "g") .. "~"))
end,
hide =
function()
ClearAllHelpMessages()
end,
}, },
red = { red = {
show = function(input) show =
local text = "" function(input)
for i = 1, #input do local text = ""
if input[i] ~= "" then for i = 1, #input do
text = text .. input[i] .. "\n~q~" if input[i] ~= "" then
text = text .. input[i] .. "\n~q~"
end
end end
end TriggerEvent("jim-redui:DrawText", text)
TriggerEvent("jim-redui:DrawText", text) end,
end, hide =
hide = function() function()
TriggerEvent("jim-redui:HideText") TriggerEvent("jim-redui:HideText")
end end,
} }
} }

View File

@@ -73,8 +73,6 @@ function checkExportExists(resource, export)
end end
end end
------------------------------------------------------------- -------------------------------------------------------------
-- Debugging and JSON Utilities -- Debugging and JSON Utilities
------------------------------------------------------------- -------------------------------------------------------------

View File

@@ -1306,7 +1306,8 @@ function hasItem(items, amount, src)
if not doesItemExist(item) then if not doesItemExist(item) then
print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7")
end end
for k, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
local hasItem, count = inv.hasItem(item, amt, src, grabInv) local hasItem, count = inv.hasItem(item, amt, src, grabInv)
@@ -1344,7 +1345,8 @@ function getPlayerInv(src)
local grabInv = nil local grabInv = nil
local foundInv = "" local foundInv = ""
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
foundInv = inv.invName foundInv = inv.invName
grabInv = inv.getPlayerInv(src) grabInv = inv.getPlayerInv(src)
@@ -1380,7 +1382,8 @@ end
function invImg(item) function invImg(item)
local imgLink = "" local imgLink = ""
if item ~= "" and doesItemExist(item) then if item ~= "" and doesItemExist(item) then
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
imgLink = inv.invImg(item) imgLink = inv.invImg(item)
break break
@@ -1535,10 +1538,10 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
local src = (newsrc and tonumber(newsrc)) or source local src = (newsrc and tonumber(newsrc)) or source
-- Only server resources may set newsrc; clients cannot. -- Only server resources may set newsrc; clients cannot.
if newsrc ~= nil and source ~= 0 then --if newsrc ~= nil and source ~= 0 then
debugPrint("^1DENY^7: client tried to set newsrc") -- debugPrint("^1DENY^7: client tried to set newsrc")
return -- return
end --end
if (give == true or give == 1) then if (give == true or give == 1) then
if newsrc == nil then -- this must be coming from client this would be blank if newsrc == nil then -- this must be coming from client this would be blank
@@ -1558,7 +1561,8 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
dupeWarn(src, item, amount) dupeWarn(src, item, amount)
else else
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
invName = inv.invName invName = inv.invName
inv.removeItem(src, item, remamount) inv.removeItem(src, item, remamount)
@@ -1586,7 +1590,8 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
end end
else else
local amountToAdd = amount or 1 local amountToAdd = amount or 1
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
invName = inv.invName invName = inv.invName
inv.addItem(src, item, amountToAdd, info, slot) inv.addItem(src, item, amountToAdd, info, slot)
@@ -1734,7 +1739,8 @@ end
--- ``` --- ```
RegisterNetEvent(getScript()..":server:setItemMetaData", function(data, src) RegisterNetEvent(getScript()..":server:setItemMetaData", function(data, src)
local src = src or source local src = src or source
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.setItemMetadata(data, src) inv.setItemMetadata(data, src)
break break
@@ -1811,7 +1817,8 @@ end
--- end --- end
function canCarry(itemTable, src) function canCarry(itemTable, src)
local resultTable = {} local resultTable = {}
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
return inv.canCarry(itemTable, src) return inv.canCarry(itemTable, src)
end end
@@ -1851,7 +1858,8 @@ end
function getMaxInvWeight() function getMaxInvWeight()
local weight = 0 local weight = 0
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
weight = inv.getMaxInvWeight() weight = inv.getMaxInvWeight()
break break
@@ -2106,7 +2114,8 @@ end
function openStash(data) function openStash(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.openStash(data) inv.openStash(data)
lookEnt(data.coords) lookEnt(data.coords)
@@ -2147,7 +2156,8 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data)
end) end)
function clearStash(stashId) function clearStash(stashId)
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
debugPrint("^5Bridge^7: ^2Clearing ^3"..inv.invName.."^2 Stash^7:", stashId) debugPrint("^5Bridge^7: ^2Clearing ^3"..inv.invName.."^2 Stash^7:", stashId)
inv.clearStash(stashId) inv.clearStash(stashId)
@@ -2180,7 +2190,8 @@ function getStash(stashName)
end end
local stashItems, items = {}, {} local stashItems, items = {}, {}
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
debugPrint("^6Bridge^7: ^2Retrieving ^3"..inv.invName.." ^2Stash^7:", stashName) debugPrint("^6Bridge^7: ^2Retrieving ^3"..inv.invName.." ^2Stash^7:", stashName)
stashItems = inv.getStash(stashName) stashItems = inv.getStash(stashName)
@@ -2240,7 +2251,8 @@ function stashRemoveItem(stashItems, stashName, items)
stashName = { stashName } stashName = { stashName }
end end
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.stashRemoveItem(stashItems, stashName[1], items) inv.stashRemoveItem(stashItems, stashName[1], items)
return return
@@ -2327,7 +2339,8 @@ end
--- ) --- )
--- ``` --- ```
function registerStash(name, label, slots, weight, owner, coords) function registerStash(name, label, slots, weight, owner, coords)
for _, inv in pairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.registerStash(name, label, slots, weight, owner, coords) inv.registerStash(name, label, slots, weight, owner, coords)
return return
@@ -2543,7 +2556,8 @@ function openShop(data)
lookEnt(data.coords) lookEnt(data.coords)
end end
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.openShop(data) inv.openShop(data)
lookEnt(data.coords) lookEnt(data.coords)
@@ -2553,7 +2567,8 @@ function openShop(data)
end end
RegisterNetEvent(getScript()..':server:openServerShop', function(shopName) RegisterNetEvent(getScript()..':server:openServerShop', function(shopName)
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
inv.serverOpenShop(shopName) inv.serverOpenShop(shopName)
break break
@@ -2575,7 +2590,8 @@ end)
function registerShop(name, label, items, society) function registerShop(name, label, items, society)
local shopResource = "" local shopResource = ""
for _, inv in ipairs(InvFunc) do for i = 1, #InvFunc do
local inv = InvFunc[i]
if isStarted(inv.invName) then if isStarted(inv.invName) then
shopResource = inv.invName shopResource = inv.invName
inv.registerShop(name, label, items, society) inv.registerShop(name, label, items, society)

View File

@@ -247,7 +247,6 @@ function useDoor(data)
Wait(100) Wait(100)
end end
function openBossMenu(isGang, group) function openBossMenu(isGang, group)
if isStarted("qb-management") then if isStarted("qb-management") then
if isGang then if isGang then

View File

@@ -1,6 +1,226 @@
local inProgress = false local inProgress = false
local storedPID = nil local storedPID = nil
local progressFunc = {
ox = {
start = function(data)
local options = {
duration = debugMode and 1000 or data.time,
label = data.label,
position = data.position or "bottom",
useWhileDead = data.dead or false,
canCancel = data.cancel or true,
anim = {
dict = data.dict,
clip = data.anim,
flag = (data.flag == 8 and 32 or data.flag) or nil,
scenario = data.task
},
disable = {
combat = data.combat or true,
move = data.disableMovement or false,
car = data.disableMovement or false,
mouse = data.mouse or false
},
}
if data.prop and data.prop.model then
options.prop = {
model = data.prop.model,
pos = data.prop.pos or vec3(0, 0, 0),
rot = data.prop.rot or vec3(0, 0, 0),
bone = data.prop.bone or 0
}
end
if data.propTwo and data.propTwo.model then
options.propTwo = {
model = data.propTwo.model,
pos = data.propTwo.pos or vec3(0, 0, 0),
rot = data.propTwo.rot or vec3(0, 0, 0),
bone = data.propTwo.bone or 0
}
end
if data.progressType == "circle" then
if exports[OXLibExport]:progressCircle(options) then
return true
else
return false
end
end
if not data.progressType or data.progressType == "bar" then
if exports[OXLibExport]:progressBar(options) then
return true
else
return false
end
end
end,
stop = function()
exports[OXLibExport]:cancelProgress()
end,
},
qb = {
start = function(data)
Core.Functions.Progressbar("progbar",
data.label,
debugMode and 1000 or data.time,
data.dead or false,
data.cancel or true,
{
disableMovement = data.disableMovement or false,
disableCarMovement = data.disableMovement or false,
disableMouse = data.disableMouse or false,
disableCombat = data.disableCombat or true,
},
{
animDict = data.dict,
anim = data.anim,
flags = data.flag or 32,
task = data.task
},
{}, {},
function()
return true
end, function()
return false
end, data.icon)
end,
stop = function()
TriggerEvent("progressbar:client:cancel")
end,
},
qs = {
start = function(data)
if exports['qs-interface']:ProgressBar({
duration = debugMode and 1000 or data.time,
label = data.label,
position = 'bottom',
useWhileDead = data.dead or false,
canCancel = data.cancel or true,
disable = data.disableMovement or false,
anim = {
dict = data.dict,
clip = data.anim,
flag = data.flag or 32
},
prop = nil
}) then
return true
else
return false
end
end,
stop = function()
--??
TriggerEvent("progressbar:client:cancel")
end,
},
esx = {
start = function(data)
ESX.Progressbar(data.label, debugMode and 1000 or data.time, {
FreezePlayer = true,
animation = {
type = data.anim,
dict = data.dict,
scenario = data.task,
},
onFinish = function()
return true
end,
onCancel = function()
return false
end
})
end,
stop = function()
ESX.CancelProgressbar()
end,
},
lation = {
start = function(data)
if exports.lation_ui:progressBar({
label = data.label,
description = nil,
duration = debugMode and 1000 or data.time,
icon = data.icon,
useWhileDead = data.dead or false,
disable = {
combat = data.combat or true,
move = data.disableMovement or false,
car = data.disableMovement or false,
},
anim = {
dict = data.dict,
clip = data.anim,
flag = data.flag
},
prop = {
model = data.prop and data.prop.model,
pos = data.prop and (data.prop.pos or vec3(0, 0, 0)),
rot = data.prop and (data.prop.rot or vec3(0, 0, 0)),
bone = data.prop and (data.prop.bone or 0)
}
}) then
return true
else
return false
end
end,
stop = function()
exports.lation_ui:cancelProgress()
end,
},
red = {
start = function(data)
if exports.jim_bridge:redProgressBar({
label = data.label,
time = debugMode and 1000 or data.time,
dict = data.dict,
anim = data.anim,
flag = data.flag or 32,
task = data.task,
disableMovement = data.disableMovement or false,
cancel = data.cancel or true,
}) then
return true
else
return false
end
end,
stop = function()
exports.jim_bridge:stopProgressBar()
end,
},
gta = {
start = function(data)
if exports.jim_bridge:gtaProgressBar({
label = data.label,
time = debugMode and 1000 or data.time,
dict = data.dict,
anim = data.anim,
flag = data.flag or 32,
task = data.task,
disableMovement = data.disableMovement or false,
cancel = data.cancel or true,
}) then
return true
else
return false
end
end,
stop = function()
exports.jim_bridge:stopProgressBar()
end,
},
}
--- Displays a progress bar using the configured progress bar system. --- Displays a progress bar using the configured progress bar system.
--- ---
--- This function handles displaying a progress bar to the player using the specified progress bar system (e.g., ox, qb, esx, gta). --- This function handles displaying a progress bar to the player using the specified progress bar system (e.g., ox, qb, esx, gta).
@@ -43,181 +263,11 @@ function progressBar(data)
end end
local result = nil local result = nil
if data.cam then startTempCam(data.cam) end if data.cam then startTempCam(data.cam) end
if Config.System.ProgressBar == "ox" then
local options = {
duration = debugMode and 1000 or data.time,
label = data.label,
position = data.position or "bottom",
useWhileDead = data.dead or false,
canCancel = data.cancel or true,
anim = {
dict = data.dict,
clip = data.anim,
flag = (data.flag == 8 and 32 or data.flag) or nil,
scenario = data.task
},
disable = {
combat = data.combat or true,
move = data.disableMovement or false,
car = data.disableMovement or false,
mouse = data.mouse or false
},
}
if data.prop and data.prop.model then
options.prop = {
model = data.prop.model,
pos = data.prop.pos or vec3(0, 0, 0),
rot = data.prop.rot or vec3(0, 0, 0),
bone = data.prop.bone or 0
}
end
if data.propTwo and data.propTwo.model then
options.propTwo = {
model = data.propTwo.model,
pos = data.propTwo.pos or vec3(0, 0, 0),
rot = data.propTwo.rot or vec3(0, 0, 0),
bone = data.propTwo.bone or 0
}
end
if data.progressType == "circle" then
if exports[OXLibExport]:progressCircle(options) then
result = true
else
result = false
end
end
if not data.progressType or data.progressType == "bar" then
if exports[OXLibExport]:progressBar(options) then
result = true
else
result = false
end
end
elseif Config.System.ProgressBar == "qb" then
Core.Functions.Progressbar("progbar",
data.label,
debugMode and 1000 or data.time,
data.dead or false,
data.cancel or true,
{
disableMovement = data.disableMovement or false,
disableCarMovement = data.disableMovement or false,
disableMouse = data.disableMouse or false,
disableCombat = data.disableCombat or true,
},
{
animDict = data.dict,
anim = data.anim,
flags = data.flag or 32,
task = data.task
},
{}, {},
function()
result = true
end, function()
result = false
end, data.icon)
elseif Config.System.ProgressBar == "qs" then -- documentation left intact based on qs interface
local qs_success = exports['qs-interface']:ProgressBar({
duration = debugMode and 1000 or data.time, -- Duration of the progress bar (in milliseconds)
label = data.label, -- Text that will appear on the progress bar
position = 'bottom', -- Position of the progress bar on the screen (e.g., 'top', 'bottom', 'center')
useWhileDead = data.dead or false, -- Whether the progress bar shows when the player is dead (true/false)
canCancel = data.cancel or true, -- Whether the player can cancel the progress (true/false)
disable = data.disableMovement or false, -- Whether to disable player controls during the progress (true/false)
anim = { -- Animation to be played while the progress is happening
dict = data.dict,
clip = data.anim,
flag = data.flag or 32 -- Optional animation flags
},
prop = nil -- Optional prop to show alongside the progress bar (can be nil)
})
if qs_success then
result = true
else
result = false
end
elseif Config.System.ProgressBar == "esx" then
ESX.Progressbar(data.label, debugMode and 1000 or data.time, {
FreezePlayer = true,
animation = {
type = data.anim,
dict = data.dict,
scenario = data.task,
},
onFinish = function()
result = true
end,
onCancel = function()
result = false
end
})
elseif Config.System.ProgressBar == "lation" then
if exports.lation_ui:progressBar({
label = data.label,
description = nil,
duration = debugMode and 1000 or data.time,
icon = data.icon,
useWhileDead = data.dead or false,
disable = {
combat = data.combat or true,
move = data.disableMovement or false,
car = data.disableMovement or false,
},
anim = {
dict = data.dict,
clip = data.anim,
flag = data.flag
},
prop = {
model = data.prop and data.prop.model,
pos = data.prop and (data.prop.pos or vec3(0, 0, 0)),
rot = data.prop and (data.prop.rot or vec3(0, 0, 0)),
bone = data.prop and (data.prop.bone or 0)
}
}) then
result = true
else
result = false
end
elseif Config.System.ProgressBar == "red" then
-- Currently only uses jim-redui if you choose this option
if exports["jim_bridge"]:redProgressBar({
label = data.label,
time = debugMode and 1000 or data.time,
dict = data.dict,
anim = data.anim,
flag = data.flag or 32,
task = data.task,
disableMovement = data.disableMovement or false,
cancel = data.cancel or true,
}) then
result = true
else
result = false
end
elseif Config.System.ProgressBar == "gta" then
if exports["jim_bridge"]:gtaProgressBar({
label = data.label,
time = debugMode and 1000 or data.time,
dict = data.dict,
anim = data.anim,
flag = data.flag or 32,
task = data.task,
disableMovement = data.disableMovement or false,
cancel = data.cancel or true,
}) then
result = true
else
result = false
end
if progressFunc[Config.System.ProgressBar].start(data) then
result = true
else
result = false
end end
while result == nil do while result == nil do
@@ -250,15 +300,7 @@ end
--- ---
--- This function cancels the progress bar based on the configured progress bar system, handling any necessary cleanup. --- This function cancels the progress bar based on the configured progress bar system, handling any necessary cleanup.
function stopProgressBar() function stopProgressBar()
if Config.System.ProgressBar == "ox" then progressFunc[Config.System.ProgressBar].stop()
exports[OXLibExport]:cancelProgress()
elseif Config.System.ProgressBar == "qb" then
TriggerEvent("progressbar:client:cancel")
elseif Config.System.ProgressBar == "lation" then
exports.lation_ui:cancelProgress()
elseif Config.System.ProgressBar == "gta" or Config.System.ProgressBar == "red" then
exports["jim_bridge"]:stopProgressBar()
end
end end
-- System to handle sending/sharing progress bars between players -- -- System to handle sending/sharing progress bars between players --

View File

@@ -6,6 +6,82 @@
for getting and setting metadata. for getting and setting metadata.
]] ]]
local metaDataFunc = {
{ framework = QBXExport,
GetPlayer =
function(src)
return exports[QBXExport]:GetCoreObject().Functions.GetPlayer(src)
end,
GetPlayerMetadata =
function(Player, dataToCheck)
return Player.PlayerData.metadata[dataToCheck]
end,
SetPlayerMetadata =
function(Player, key, value)
return Player.Functions.SetMetaData(key, value)
end,
},
{ framework = QBExport,
GetPlayer =
function(src)
return exports[QBExport]:GetCoreObject().Functions.GetPlayer(src)
end,
GetPlayerMetadata =
function(Player, dataToCheck)
return Player.PlayerData.metadata[dataToCheck]
end,
SetPlayerMetadata =
function(Player, key, value)
return Player.Functions.SetMetaData(key, value)
end,
},
{ framework = ESXExport,
GetPlayer =
function(src)
return ESX.GetPlayerFromId(src)
end,
GetPlayerMetadata =
function(Player, dataToCheck)
return Player.getMeta(dataToCheck)
end,
SetPlayerMetadata =
function(Player, key, value)
return Player.set(key, value)
end,
},
{ framework = OXCoreExport,
GetPlayer =
function(src)
return exports[OXCoreExport]:GetPlayer(src)
end,
GetPlayerMetadata =
function(Player, dataToCheck)
return Player.get(dataToCheck)
end,
SetPlayerMetadata =
function(Player, key, value)
return Player.set(key, value)
end,
},
{ framework = RSGExport,
GetPlayer = function(src)
exports[RSGExport]:GetCoreObject().Functions.GetPlayer(source)
end,
GetPlayerMetadata = function(Player, dataToCheck)
return Player.PlayerData.metadata[dataToCheck]
end,
SetPlayerMetadata = function(Player, key, value)
return Player.Functions.SetMetaData(key, value)
end,
},
}
------------------------------------------------------------- -------------------------------------------------------------
-- Player Retrieval -- Player Retrieval
------------------------------------------------------------- -------------------------------------------------------------
@@ -20,26 +96,11 @@
--- local player = GetPlayer(playerId) --- local player = GetPlayer(playerId)
--- ``` --- ```
function GetPlayer(source) function GetPlayer(source)
if isStarted(QBExport) then for i = 1, #metaDataFunc do
debugPrint("^6Bridge^7: ^3GetPlayer^7() QBExport") local framework = metaDataFunc[i]
return exports[QBExport]:GetCoreObject().Functions.GetPlayer(source) if isStarted(framework.framework) then
return framework.GetPlayer(source)
elseif isStarted(QBXExport) then end
debugPrint("^6Bridge^7: ^3GetPlayer^7() QBOXExport")
return exports[QBXExport]:GetCoreObject().Functions.GetPlayer(source)
elseif isStarted(ESXExport) then
debugPrint("^6Bridge^7: ^3GetPlayer^7() ESXExport")
return ESX.GetPlayerFromId(source)
elseif isStarted(OXCoreExport) then
debugPrint("^6Bridge^7: ^3GetPlayer^7() OXCoreExport")
return exports[OXCoreExport]:GetPlayer(source)
elseif isStarted(RSGExport) then
debugPrint("^6Bridge^7: ^3GetPlayer^7() RSGExport")
return exports[RSGExport]:GetCoreObject().Functions.GetPlayer(source)
end end
return nil return nil
end end
@@ -61,26 +122,19 @@ end
--- local myMeta = getPlayerMetadata(player, "myKey") --- local myMeta = getPlayerMetadata(player, "myKey")
--- ``` --- ```
function getPlayerMetadata(player, key) function getPlayerMetadata(player, key)
-- Assume this is client side and callback to server to get the data
if not player then if not player then
debugPrint("^6Bridge^7: ^3GetMetadata^7() calling server: "..key) debugPrint("^6Bridge^7: ^3GetMetadata^7() calling server: "..key)
return triggerCallback(getScript()..":server:GetMetadata", key) return triggerCallback(getScript()..":server:GetMetadata", key)
else else
if isStarted(QBExport) or isStarted(QBXExport) then -- else grab server metadata about the player
debugPrint("^6Bridge^7: ^3GetMetadata^7() QBExport/QBXExport", key) for i = 1, #metaDataFunc do
return player.PlayerData.metadata[key] local framework = metaDataFunc[i]
if isStarted(framework.framework) then
elseif isStarted(ESXExport) then
debugPrint("^6Bridge^7: ^3GetMetadata^7() ESXExport", key)
return player.getMeta(key)
elseif isStarted(OXCoreExport) then
debugPrint("^6Bridge^7: ^3GetMetadata^7() OXCoreExport", key)
return player.get(key)
elseif isStarted(RSGExport) then
debugPrint("^6Bridge^7: ^3GetMetadata^7() RSGExport", key)
return player.PlayerData.metadata[key]
debugPrint("^6Bridge^7: ^3GetMetadata^7() ^3"..framework.framework.."^7", key)
return framework.GetPlayerMetadata(player, key)
end
end end
end end
return nil return nil
@@ -123,34 +177,22 @@ end)
--- setPlayerMetadata(player, "myKey", "newValue") --- setPlayerMetadata(player, "myKey", "newValue")
--- ``` --- ```
function setPlayerMetadata(player, key, value) function setPlayerMetadata(player, key, value)
debugPrint("^6Bridge^7: ^3SetMetadata^7() setting metadata for key: "..key) debugPrint("^6Bridge^7: ^3SetMetadata^7() setting metadata^7...")
if isStarted(QBExport) or isStarted(QBXExport) then for i = 1, #metaDataFunc do
debugPrint("^6Bridge^7: ^3SetMetadata^7() using QBExport/QBXExport") local framework = metaDataFunc[i]
player.Functions.SetMetaData(key, value) if isStarted(framework.framework) then
debugPrint("^6Bridge^7: ^3SetMetadata^7() ^3"..framework.framework.."^7", key, value)
elseif isStarted(ESXExport) then return framework.GetPlayerMetadata(player, key)
debugPrint("^6Bridge^7: ^3SetMetadata^7() using ESXExport") end
player.setMeta(key, value)
elseif isStarted(OXCoreExport) then
debugPrint("^6Bridge^7: ^3SetMetadata^7() using OXCoreExport")
player.set(key, value)
elseif isStarted(RSGExport) then
debugPrint("^6Bridge^7: ^3SetMetadata^7() using RSGExport")
player.Functions.SetMetaData(key, value)
end end
debugPrint("^6Bridge^7: ^1Error setting metadata^7, ^1framework not supported^7?")
end end
-- Register a server callback for setting metadata. -- Register a server callback for setting metadata.
createCallback(getScript()..":server:setPlayerMetadata", function(source, key, value) createCallback(getScript()..":server:setPlayerMetadata", function(source, key, value)
debugPrint("SetMetadata callback triggered for source:", source, "key:", key, "value:", value) local src = source
local player = GetPlayer(source) debugPrint("SetMetadata callback triggered for source:", src, "key:", key, "value:", value)
--[[if not player then local player = GetPlayer(src)
print("Error setting metadata: player not found for source "..tostring(source))
return false
end]]
setPlayerMetadata(player, key, value) setPlayerMetadata(player, key, value)
print("Metadata set successfully.", key) print("Metadata set successfully.", key)
return true return true

View File

@@ -17,68 +17,91 @@
local notifyFunc = { local notifyFunc = {
okok = { okok = {
client = function(title, message, type) client =
TriggerEvent('okokNotify:Alert', title, message, 6000, type) function(title, message, type)
end, TriggerEvent('okokNotify:Alert', title, message, 6000, type)
server = function(title, message, type, src) end,
TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type) server =
end, function(title, message, type, src)
TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type)
end,
}, },
qb = { qb = {
client = function(title, message, type) client =
TriggerEvent("QBCore:Notify", message, type) function(title, message, type)
end, TriggerEvent("QBCore:Notify", message, type)
server = function(title, message, type, src) end,
TriggerClientEvent("QBCore:Notify", src, message, type) server =
end, function(title, message, type, src)
TriggerClientEvent("QBCore:Notify", src, message, type)
end,
}, },
qs = { qs = {
client = function(title, message, type) client =
exports['qs-interface']:AddNotify(message, title, 6000) function(title, message, type)
end, exports['qs-interface']:AddNotify(message, title, 6000)
server = function(title, message, type, src) end,
TriggerClientEvent('interface:notification', src, message, title, 6000) server =
end, function(title, message, type, src)
TriggerClientEvent('interface:notification', src, message, title, 6000)
end,
}, },
ox = { ox = {
client = function(title, message, type) client =
exports.ox_lib:notify({ title = title, description = message, type = type or "success" }) function(title, message, type)
end, exports.ox_lib:notify({ title = title, description = message, type = type or "success" })
server = function(title, message, type, src) end,
TriggerClientEvent('ox_lib:notify', src, { title = title, description = message, type = type or "success" }) server =
end, function(title, message, type, src)
}, TriggerClientEvent('ox_lib:notify', src, { title = title, description = message, type = type or "success" })
gta = { end,
client = function(title, message, type)
exports.jim_bridge:Notify(title, message, type)
end,
server = function(title, message, type, src)
TriggerClientEvent("jim-bridge:Notify", src, title, message, type)
end,
}, },
esx = { esx = {
client = function(title, message, type) client =
exports["esx_notify"]:Notify(type, 4000, message) function(title, message, type)
end, exports["esx_notify"]:Notify(type, 4000, message)
server = function(title, message, type, src) end,
TriggerClientEvent(getScript()..":DisplayESXNotify", src, type, message) server =
end, function(title, message, type, src)
TriggerClientEvent(getScript()..":DisplayESXNotify", src, type, message)
end,
}, },
lation = { lation = {
client = function(title, message, type) client =
exports.lation_ui:notify({ title = title, message = message, type = type or "success", }) function(title, message, type)
end, exports.lation_ui:notify({ title = title, message = message, type = type or "success", })
server = function(title, message, type, src) end,
TriggerClientEvent("lation_ui:notify", src, { title = title, message = message, type = type or "success", }) server =
end, function(title, message, type, src)
TriggerClientEvent("lation_ui:notify", src, { title = title, message = message, type = type or "success", })
end,
}, },
gta = {
client =
function(title, message, type)
exports.jim_bridge:Notify(title, message, type)
end,
server =
function(title, message, type, src)
TriggerClientEvent("jim-bridge:Notify", src, title, message, type)
end,
},
red = { red = {
client = function(title, message, type) client =
TriggerEvent("jim-redui:Notify", title, message, type) function(title, message, type)
end, TriggerEvent("jim-redui:Notify", title, message, type)
server = function(title, message, type, src) end,
TriggerClientEvent("jim-redui:Notify", src, title, message, type) server =
end, function(title, message, type, src)
TriggerClientEvent("jim-redui:Notify", src, title, message, type)
end,
}, },
} }
--- Displays notifications to the player using the configured notification system. --- Displays notifications to the player using the configured notification system.

View File

@@ -13,102 +13,76 @@
- jpr-phonesystem - jpr-phonesystem
]] ]]
--- Sends a phone mail using the detected phone system. local phoneFunc = {
--- The function iterates through a prioritized list of supported phone systems. { phone = "gksphone",
--- Once an active system is found (via `isStarted`), the corresponding mail function is executed. sendMail = function(mailData)
--- exports["gksphone"]:SendNewMail(mailData)
--- @param data table A table containing the mail data. end,
--- - subject (string): The email subject. sendInvoice =
--- - sender (string): The sender identifier. function(mailData)
--- - message (string): The email body content. -- Defensive check for required fields
--- - actions (table|nil): Optional action buttons for the email. local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "label" }
--- @usage for _, field in ipairs(required) do
--- sendPhoneMail({ if mailData[field] == nil then
--- subject = "Welcome!", print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
--- sender = "Admin", return
--- message = "Thank you for joining our server.", end
--- actions = { end
--- { label = "Reply", action = replyFunction }
--- } MySQL.Async.execute(
--- }) 'INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)',
function sendPhoneMail(data) {
-- Define each supported phone system and its corresponding mail-sending function. ['@citizenid'] = mailData.billedCitizenid,
local phoneSystems = { ['@amount'] = mailData.amount,
{ name = "gksphone", ['@society'] = mailData.job,
send = function(mailData) ['@sender'] = mailData.name,
exports["gksphone"]:SendNewMail(mailData) ['@sendercitizenid'] = mailData.billerCitizenid,
['@label'] = mailData.label
}
)
end, end,
}, },
{ name = "yflip-phone", { name = "yflip-phone",
send = function(mailData) sendMail =
function(mailData)
TriggerServerEvent(getScript()..":yflip:SendMail", mailData) TriggerServerEvent(getScript()..":yflip:SendMail", mailData)
end, end,
}, },
{ name = "qs-smartphone", { name = "qs-smartphone",
send = function(mailData) sendMail =
function(mailData)
TriggerServerEvent('qs-smartphone:server:sendNewMail', mailData) TriggerServerEvent('qs-smartphone:server:sendNewMail', mailData)
end, end,
}, },
{ name = "qs-smartphone-pro", { name = "qs-smartphone-pro",
send = function(mailData) sendMail =
function(mailData)
TriggerServerEvent('phone:sendNewMail', mailData) TriggerServerEvent('phone:sendNewMail', mailData)
end, end,
}, },
{ name = "roadphone", { name = "roadphone",
send = function(mailData) sendMail =
function(mailData)
-- Convert HTML line breaks to newlines for roadphone. -- Convert HTML line breaks to newlines for roadphone.
mailData.message = mailData.message:gsub("%<br>", "\n") mailData.message = mailData.message:gsub("%<br>", "\n")
exports["roadphone"]:sendMail(mailData) exports["roadphone"]:sendMail(mailData)
end, end,
}, },
{ name = "lb-phone", { name = "lb-phone",
send = function(mailData) sendMail =
function(mailData)
-- Convert HTML line breaks to newlines for lb-phone. -- Convert HTML line breaks to newlines for lb-phone.
mailData.message = mailData.message:gsub("%<br>", "\n") mailData.message = mailData.message:gsub("%<br>", "\n")
TriggerServerEvent(getScript()..":lbphone:SendMail", mailData) TriggerServerEvent(getScript()..":lbphone:SendMail", mailData)
end, end,
}, },
{ name = "qb-phone", { name = "qb-phone",
send = function(mailData) sendMail =
function(mailData)
TriggerServerEvent('qb-phone:server:sendNewMail', mailData) TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
end, end,
}, sendInvoice =
{ name = "npwd_qbx_mail", function(mailData)
send = function(mailData)
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
end,
},
{ name = "jpr-phonesystem",
send = function(mailData)
TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
end,
},
{ name = "ef-phone",
send = function(mailData)
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
end,
},
}
-- Check each phone system in order and use the first active one.
for _, phone in ipairs(phoneSystems) do
if isStarted(phone.name) then
debugPrint("^6Bridge^7[^3"..phone.name.."^7]: ^2Sending mail to player")
phone.send(data)
return true
end
end
print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7- ^2No supported phone found")
return false
end
function sendPhoneInvoice(data)
if not data.src then return end
-- Define each supported phone system and its corresponding mail-sending function.
local phoneSystems = {
{
name = "qb-phone",
send = function(mailData)
-- Defensive check for required fields -- Defensive check for required fields
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "src" } local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "src" }
for _, field in ipairs(required) do for _, field in ipairs(required) do
@@ -134,74 +108,73 @@ function sendPhoneInvoice(data)
end end
end end
) )
TriggerClientEvent('qb-phone:RefreshPhone', mailData.src) TriggerClientEvent('qb-phone:RefreshPhone', mailData.src)
end end,
}, },
{ { name = "npwd_qbx_mail",
name = "codem-phone", sendMail =
send = function(mailData) function(mailData)
-- Defensive check for required fields TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "src" } end,
for _, field in ipairs(required) do },
if mailData[field] == nil then { name = "jpr-phonesystem",
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData") sendMail =
return function(mailData)
end TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
end end,
},
{ name = "ef-phone",
sendMail =
function(mailData)
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
end,
},
-- Safe insert with all parameters present }
MySQL.Async.insert(
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
{
mailData.billedCitizenid,
mailData.amount,
mailData.job,
mailData.name,
mailData.billerCitizenid
},
function(id)
-- if id then
-- TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', mailData.src, id, mailData.name, mailData.job, mailData.billerCitizenid, mailData.amount, GetInvokingResource())
-- end
end
)
end --- Sends a phone mail using the detected phone system.
}, --- The function iterates through a prioritized list of supported phone systems.
{ --- Once an active system is found (via `isStarted`), the corresponding mail function is executed.
name = "gksphone", ---
send = function(mailData) --- @param data table A table containing the mail data.
-- Defensive check for required fields --- - subject (string): The email subject.
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "label" } --- - sender (string): The sender identifier.
for _, field in ipairs(required) do --- - message (string): The email body content.
if mailData[field] == nil then --- - actions (table|nil): Optional action buttons for the email.
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData") --- @usage
return --- sendPhoneMail({
end --- subject = "Welcome!",
end --- sender = "Admin",
--- message = "Thank you for joining our server.",
--- actions = {
--- { label = "Reply", action = replyFunction }
--- }
--- })
function sendPhoneMail(mailData)
-- Check each phone system in order and use the first active one.
for i = 1, #phoneFunc do
local script = phoneFunc[i]
if isStarted(script.phone) and script.sendMail then
debugPrint("^6Bridge^7[^3"..script.phone.."^7]: ^2Sending mail to player")
script.sendMail(mailData)
return true
end
end
print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7- ^2No supported phone found")
return false
end
MySQL.Async.execute( function sendPhoneInvoice(data)
'INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)', if not data.src then return end
{
['@citizenid'] = mailData.billedCitizenid,
['@amount'] = mailData.amount,
['@society'] = mailData.job,
['@sender'] = mailData.name,
['@sendercitizenid'] = mailData.billerCitizenid,
['@label'] = mailData.label
}
)
end
}
}
-- Check each phone system in order and use the first active one. -- Check each phone system in order and use the first active one.
for _, phone in ipairs(phoneSystems) do
if isStarted(phone.name) then for i = 1, #phoneFunc do
debugPrint("^6Bridge^7[^3"..phone.name.."^7]: ^2Sending mail to player^7", data.src) local script = phoneFunc[i]
phone.send(data) if isStarted(script.phone) and script.sendInvoice then
debugPrint("^6Bridge^7[^3"..script.phone.."^7]: ^2Sending mail to player^7", data.src)
script.sendInvoice(data)
return true return true
end end
end end

View File

@@ -100,7 +100,8 @@ local polyCreation = {
---}) ---})
---``` ---```
function createPoly(data) function createPoly(data)
for _, script in ipairs(polyCreation) do for i = 1, #polyCreation do
local script = polyCreation[i]
if isStarted(script.polyZoneScript) then if isStarted(script.polyZoneScript) then
debugPrint("^6Bridge^7: ^2Creating new poly with ^7'^4"..script.polyZoneScript.."^7': "..data.name) debugPrint("^6Bridge^7: ^2Creating new poly with ^7'^4"..script.polyZoneScript.."^7': "..data.name)
return script.createPoly(data) return script.createPoly(data)
@@ -140,7 +141,8 @@ end
--- }) --- })
--- ``` --- ```
function createCirclePoly(data) function createCirclePoly(data)
for _, script in ipairs(polyCreation) do for i = 1, #polyCreation do
local script = polyCreation[i]
if isStarted(script.polyZoneScript) then if isStarted(script.polyZoneScript) then
debugPrint("^6Bridge^7: ^2Creating new ^3Cricle^2 poly with ^7"..script.polyZoneScript.." "..data.name) debugPrint("^6Bridge^7: ^2Creating new ^3Cricle^2 poly with ^7"..script.polyZoneScript.." "..data.name)
debugPrint("^6Bridge^7: ^2Zone Stats - Coords: "..formatCoord(data.coords).." Radius: "..data.radius) debugPrint("^6Bridge^7: ^2Zone Stats - Coords: "..formatCoord(data.coords).." Radius: "..data.radius)
@@ -169,7 +171,8 @@ end
--- removePolyZone(zone) --- removePolyZone(zone)
--- ``` --- ```
function removePolyZone(Location) function removePolyZone(Location)
for _, script in ipairs(polyCreation) do for i = 1, #polyCreation do
local script = polyCreation[i]
if isStarted(script.polyZoneScript) then if isStarted(script.polyZoneScript) then
debugPrint("^6Bridge^7: ^2Removing ^3"..script.polyZoneScript.." ^2Zone^7") debugPrint("^6Bridge^7: ^2Removing ^3"..script.polyZoneScript.." ^2Zone^7")
script.removeZone(Location) script.removeZone(Location)

View File

@@ -1,58 +1,72 @@
local activeSkillCheck = false local skillCheckFunc = {
qb = {
start = function(data)
local Skillbar = exports["qb-minigames"]:Skillbar()
if Skillbar then
return true
else
return false
end
end,
},
ox = {
start = function(data)
local Skillbar = exports[OXLibExport]:skillCheck(
{
"easy",
"easy",
"easy"
},
{
"1",
"2",
"3",
"4"
})
if Skillbar then
return true
else
return false
end
end,
},
gta = {
start = function(data)
local Skillbar = exports.jim_bridge:skillCheck()
if Skillbar then
return true
else
return false
end
end,
},
lation = {
start = function(data)
local Skillbar = exports.lation_ui:skillCheck("",
{
"easy",
"easy",
"easy"
},
{
"1",
"2",
"3",
"4"
})
if Skillbar then
return true
else
return false
end
end,
},
}
function skillCheck(data) function skillCheck(data)
local result = false if Config.System.skillCheck then
return skillCheckFunc[Config.System.skillCheck].start(data)
if Config.System.skillCheck == "qb" then
local Skillbar = exports["qb-minigames"]:Skillbar()
if Skillbar then
result = true
else
result = false
end
elseif Config.System.skillCheck == "ox" then
local Skillbar = exports[OXLibExport]:skillCheck(
{
"easy",
"easy",
"easy"
},
{
"1",
"2",
"3",
"4"
})
if Skillbar then
result = true
else
result = false
end
elseif Config.System.skillCheck == "gta" then
exports.jim_bridge:skillCheck()
elseif Config.System.skillCheck == "lation" then
local Skillbar = exports.lation_ui:skillCheck("",
{
"easy",
"easy",
"easy"
},
{
"1",
"2",
"3",
"4"
})
if Skillbar then
result = true
else
result = false
end
else
result = true
end end
return result return true
end end

View File

@@ -12,112 +12,122 @@
]] ]]
local societyFunc = { local societyFunc = {
{ { bankName = "qb-banking",
bankName = "qb-banking", getAccount =
getAccount = function(society) function(society)
if not exports["qb-banking"]:GetAccount(society) then if not exports["qb-banking"]:GetAccount(society) then
if Jobs[society] then if Jobs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateJobAccount(society, 0) exports["qb-banking"]:CreateJobAccount(society, 0)
Wait(150) Wait(150)
elseif Gangs[society] then elseif Gangs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateGangAccount(society, 0) exports["qb-banking"]:CreateGangAccount(society, 0)
Wait(150) Wait(150)
end
end end
end return exports["qb-banking"]:GetAccountBalance(society)
return exports["qb-banking"]:GetAccountBalance(society) end,
end, chargeSociety =
chargeSociety = function(society, amount) function(society, amount)
if not exports["qb-banking"]:GetAccount(society) then if not exports["qb-banking"]:GetAccount(society) then
if Jobs[society] then if Jobs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateJobAccount(society, 0) Wait(150) -- make new account if return "null" exports["qb-banking"]:CreateJobAccount(society, 0) Wait(150) -- make new account if return "null"
elseif Gangs[society] then elseif Gangs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateGangAccount(society, 0) Wait(150) -- make new account if return "null" exports["qb-banking"]:CreateGangAccount(society, 0) Wait(150) -- make new account if return "null"
end
end end
end exports["qb-banking"]:RemoveMoney(society, amount)
exports["qb-banking"]:RemoveMoney(society, amount) end,
end, fundSociety =
fundSociety = function(society, amount) function(society, amount)
if not exports["qb-banking"]:GetAccount(society) then if not exports["qb-banking"]:GetAccount(society) then
if Jobs[society] then if Jobs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateJobAccount(society, 0) exports["qb-banking"]:CreateJobAccount(society, 0)
Wait(150) Wait(150)
elseif Gangs[society] then elseif Gangs[society] then
print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'") print("^6Bridge^7: ^2Making new bank account in ^7'^3qb-banking^7' ^2for ^7'^3"..society.."^7'")
exports["qb-banking"]:CreateGangAccount(society, 0) exports["qb-banking"]:CreateGangAccount(society, 0)
Wait(150) Wait(150)
end
end end
end exports["qb-banking"]:AddMoney(society, amount)
exports["qb-banking"]:AddMoney(society, amount) end,
end,
}, },
{ { bankName = "Renewed-Banking",
bankName = "Renewed-Banking", getAccount =
getAccount = function(society) function(society)
return exports["Renewed-Banking"]:getAccountMoney(society) return exports["Renewed-Banking"]:getAccountMoney(society)
end, end,
chargeSociety = function(society, amount) chargeSociety =
exports['Renewed-Banking']:removeAccountMoney(society, amount) function(society, amount)
end, exports['Renewed-Banking']:removeAccountMoney(society, amount)
fundSociety = function(society, amount) end,
exports['Renewed-Banking']:addAccountMoney(society, amount) fundSociety =
end, function(society, amount)
exports['Renewed-Banking']:addAccountMoney(society, amount)
end,
}, },
{ { bankName = "fd_banking",
bankName = "fd_banking", getAccount =
getAccount = function(society) function(society)
return exports["fd_banking"]:GetAccount(society) return exports["fd_banking"]:GetAccount(society)
end, end,
chargeSociety = function(society, amount) chargeSociety =
exports["fd_banking"]:RemoveMoney(society, amount) function(society, amount)
end, exports["fd_banking"]:RemoveMoney(society, amount)
fundSociety = function(society, amount) end,
exports["fd_banking"]:AddMoney(society, amount) fundSociety =
end, function(society, amount)
exports["fd_banking"]:AddMoney(society, amount)
end,
}, },
{ { bankName = "okokBanking",
bankName = "okokBanking", getAccount =
getAccount = function(society) function(society)
return exports['okokBanking']:GetAccount(society) return exports['okokBanking']:GetAccount(society)
end, end,
chargeSociety = function(society, amount) chargeSociety =
exports['okokBanking']:RemoveMoney(society, amount) function(society, amount)
end, exports['okokBanking']:RemoveMoney(society, amount)
fundSociety = function(society, amount) end,
exports['okokBanking']:AddMoney(society, amount) fundSociety =
end, function(society, amount)
exports['okokBanking']:AddMoney(society, amount)
end,
}, },
{ { bankName = "tgiann-bank",
bankName = "tgiann-bank", getAccount =
getAccount = function(society) function(society)
if Jobs[society] then if Jobs[society] then
return exports["tgiann-bank"]:GetJobAccountBalance(society) return exports["tgiann-bank"]:GetJobAccountBalance(society)
else else
return exports["tgiann-bank"]:GetGangAccountBalance(society) return exports["tgiann-bank"]:GetGangAccountBalance(society)
end end
end, end,
chargeSociety = function(society, amount) chargeSociety =
if Jobs[society] then function(society, amount)
exports["tgiann-bank"]:RemoveJobMoney(society, amount) if Jobs[society] then
else exports["tgiann-bank"]:RemoveJobMoney(society, amount)
exports["tgiann-bank"]:RemoveGangMoney(society, amount) else
end exports["tgiann-bank"]:RemoveGangMoney(society, amount)
end, end
fundSociety = function(society, amount) end,
if Jobs[society] then fundSociety =
exports["tgiann-bank"]:AddJobMoney(society, amount) function(society, amount)
else if Jobs[society] then
exports["tgiann-bank"]:AddGangMoney(society, amount) exports["tgiann-bank"]:AddJobMoney(society, amount)
end else
end, exports["tgiann-bank"]:AddGangMoney(society, amount)
end
end,
}, },
} }
@@ -134,7 +144,8 @@ function getSocietyAccount(society)
local amount = 0 local amount = 0
if society == nil or society == "none" then return amount end if society == nil or society == "none" then return amount end
for _, script in pairs(societyFunc) do for i = 1, #societyFunc do
local script = societyFunc[i]
if isStarted(script.bankName) then if isStarted(script.bankName) then
local amount = script.getAccount(society) local amount = script.getAccount(society)
debugPrint("^6Bridge^7: ^3"..script.bankName.."^7: ^2Retrieved account ^7'^6"..society.."^7' ($"..tostring(amount)..")") debugPrint("^6Bridge^7: ^3"..script.bankName.."^7: ^2Retrieved account ^7'^6"..society.."^7' ($"..tostring(amount)..")")
@@ -156,7 +167,8 @@ end
--- ``` --- ```
function chargeSociety(society, amount) function chargeSociety(society, amount)
for _, script in pairs(societyFunc) do for i = 1, #societyFunc do
local script = societyFunc[i]
if isStarted(script.bankName) then if isStarted(script.bankName) then
script.chargeSociety(society, amount) script.chargeSociety(society, amount)
local newAmount = getSocietyAccount(society) local newAmount = getSocietyAccount(society)
@@ -177,7 +189,8 @@ end
--- ``` --- ```
function fundSociety(society, amount) function fundSociety(society, amount)
for _, script in pairs(societyFunc) do for i = 1, #societyFunc do
local script = societyFunc[i]
if isStarted(script.bankName) then if isStarted(script.bankName) then
script.fundSociety(society, amount) script.fundSociety(society, amount)
local newAmount = getSocietyAccount(society) local newAmount = getSocietyAccount(society)

View File

@@ -18,172 +18,190 @@
]] ]]
local targetFunc = { local targetFunc = {
{ { targetName = OXTargetExport,
targetName = OXTargetExport, entityTarget =
entityTarget = function(entity, opts, dist) function(entity, opts, dist)
local options = {} local options = {}
for i = 1, #opts do for i = 1, #opts do
options[i] = { options[i] = {
icon = opts[i].icon, icon = opts[i].icon,
label = opts[i].label, label = opts[i].label,
items = opts[i].item or nil, items = opts[i].item or nil,
groups = opts[i].job or opts[i].gang, groups = opts[i].job or opts[i].gang,
onSelect = opts[i].action, onSelect = opts[i].action,
distance = dist, distance = dist,
canInteract = opts[i].canInteract or nil, canInteract = opts[i].canInteract or nil,
} }
end end
exports[OXTargetExport]:addLocalEntity(entity, options) exports[OXTargetExport]:addLocalEntity(entity, options)
end, end,
boxTarget = function(data, opts, dist) boxTarget =
local options = {} function(data, opts, dist)
for i = 1, #opts do local options = {}
options[i] = { for i = 1, #opts do
icon = opts[i].icon, options[i] = {
label = opts[i].label, icon = opts[i].icon,
items = opts[i].item or nil, label = opts[i].label,
groups = opts[i].groups or opts[i].job or opts[i].gang, items = opts[i].item or nil,
onSelect = opts[i].onSelect or opts[i].action, groups = opts[i].groups or opts[i].job or opts[i].gang,
distance = dist, onSelect = opts[i].onSelect or opts[i].action,
canInteract = opts[i].canInteract or nil, distance = dist,
} canInteract = opts[i].canInteract or nil,
end }
end
data[5].maxZ = data[5].maxZ or (data[2].z + 0.80) data[5].maxZ = data[5].maxZ or (data[2].z + 0.80)
data[5].minZ = data[5].minZ or data[2].z - 1.05 data[5].minZ = data[5].minZ or data[2].z - 1.05
local thickness = ((data[5].maxZ / 2) - (data[5].minZ / 2)) * 2 local thickness = ((data[5].maxZ / 2) - (data[5].minZ / 2)) * 2
local mid = data[5].maxZ - ((data[5].maxZ / 2) - (data[5].minZ / 2)) local mid = data[5].maxZ - ((data[5].maxZ / 2) - (data[5].minZ / 2))
data[2] = vec3(data[2].x, data[2].y, mid) -- force the coord to middle of the minZ and maxZ data[2] = vec3(data[2].x, data[2].y, mid) -- force the coord to middle of the minZ and maxZ
local target = exports[OXTargetExport]:addBoxZone({ local target = exports[OXTargetExport]:addBoxZone({
coords = data[2], coords = data[2],
size = vec3(data[4], data[3], thickness), -- size uses the math to determine how high it needs to be size = vec3(data[4], data[3], thickness), -- size uses the math to determine how high it needs to be
rotation = data[5].heading, rotation = data[5].heading,
debug = data[5].debugPoly, debug = data[5].debugPoly,
options = options options = options
}) })
return target return target
end, end,
circleTarget = function(data, opts, dist) circleTarget =
local options = {} function(data, opts, dist)
for i = 1, #opts do local options = {}
options[i] = { for i = 1, #opts do
icon = opts[i].icon, options[i] = {
label = opts[i].label, icon = opts[i].icon,
items = opts[i].item or nil, label = opts[i].label,
groups = opts[i].job or opts[i].gang, items = opts[i].item or nil,
onSelect = opts[i].onSelect or opts[i].action, groups = opts[i].job or opts[i].gang,
distance = dist, onSelect = opts[i].onSelect or opts[i].action,
canInteract = opts[i].canInteract or nil, distance = dist,
} canInteract = opts[i].canInteract or nil,
end }
local target = exports[OXTargetExport]:addSphereZone({ end
coords = data[2], local target = exports[OXTargetExport]:addSphereZone({
radius = data[3], coords = data[2],
debug = data[4].debugPoly, radius = data[3],
options = options debug = data[4].debugPoly,
}) options = options
return target })
end, return target
end,
modelTarget = function(models, opts, dist) modelTarget =
local options = {} function(models, opts, dist)
for i = 1, #opts do local options = {}
options[i] = { for i = 1, #opts do
icon = opts[i].icon, options[i] = {
label = opts[i].label, icon = opts[i].icon,
items = opts[i].item or nil, label = opts[i].label,
groups = opts[i].job or opts[i].gang, items = opts[i].item or nil,
onSelect = opts[i].action, groups = opts[i].job or opts[i].gang,
distance = dist, onSelect = opts[i].action,
canInteract = opts[i].canInteract or nil, distance = dist,
} canInteract = opts[i].canInteract or nil,
end }
exports[OXTargetExport]:addModel(models, options) end
end, exports[OXTargetExport]:addModel(models, options)
end,
removeTargetEntity = function(entity) removeTargetEntity =
exports[OXTargetExport]:removeLocalEntity(entity, nil) function(entity)
end, exports[OXTargetExport]:removeLocalEntity(entity, nil)
end,
removeTargetZone = function(target) removeTargetZone =
exports[OXTargetExport]:removeZone(target, true) function(target)
end, exports[OXTargetExport]:removeZone(target, true)
end,
removeTargetModel = function(model) removeTargetModel =
exports[OXTargetExport]:removeModel(model, nil) function(model)
end, exports[OXTargetExport]:removeModel(model, nil)
end,
}, },
{ { targetName = QBTargetExport,
targetName = QBTargetExport, entityTarget =
entityTarget = function(entity, opts, dist) function(entity, opts, dist)
local options = { options = opts, distance = dist } local options = { options = opts, distance = dist }
exports[QBTargetExport]:AddTargetEntity(entity, options) exports[QBTargetExport]:AddTargetEntity(entity, options)
end, end,
boxTarget = function(data, opts, dist) boxTarget =
local options = { options = opts, distance = dist } function(data, opts, dist)
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options) local options = { options = opts, distance = dist }
return data[1] local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
end, return data[1]
end,
circleTarget = function(data, opts, dist) circleTarget =
local options = { options = opts, distance = dist } function(data, opts, dist)
local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options) local options = { options = opts, distance = dist }
return data[1] local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options)
end, return data[1]
end,
modelTarget = function(models, opts, dist) modelTarget =
local options = { options = opts, distance = dist } function(models, opts, dist)
exports[QBTargetExport]:AddTargetModel(models, options) local options = { options = opts, distance = dist }
end, exports[QBTargetExport]:AddTargetModel(models, options)
end,
removeTargetEntity = function(entity) removeTargetEntity =
exports[QBTargetExport]:RemoveTargetEntity(entity) function(entity)
end, exports[QBTargetExport]:RemoveTargetEntity(entity)
end,
removeTargetZone = function(target) removeTargetZone =
exports[QBTargetExport]:RemoveZone(target) function(target)
end, exports[QBTargetExport]:RemoveZone(target)
end,
removeTargetModel = function(model) removeTargetModel =
exports[QBTargetExport]:RemoveTargetModel(model, "Test") function(model)
end, exports[QBTargetExport]:RemoveTargetModel(model, "Test")
end,
}, },
{ { targetName = "jim_bridge",
targetName = "jim_bridge", entityTarget =
entityTarget = function(entity, opts, dist) function(entity, opts, dist)
return exports.jim_bridge:createEntityTarget(entity, opts, dist) return exports.jim_bridge:createEntityTarget(entity, opts, dist)
end, end,
boxTarget = function(data, opts, dist) boxTarget =
return exports.jim_bridge:createZoneTarget(data, opts, dist) function(data, opts, dist)
end, return exports.jim_bridge:createZoneTarget(data, opts, dist)
end,
circleTarget = function(data, opts, dist) circleTarget =
return exports.jim_bridge:createZoneTarget(data, opts, dist) function(data, opts, dist)
end, return exports.jim_bridge:createZoneTarget(data, opts, dist)
end,
modelTarget = function(models, opts, dist) modelTarget =
return exports.jim_bridge:createModelTarget(models, opts, dist) function(models, opts, dist)
end, return exports.jim_bridge:createModelTarget(models, opts, dist)
end,
removeTargetEntity = function(entity) removeTargetEntity =
exports.jim_bridge:removeEntityTarget(entity) function(entity)
end, exports.jim_bridge:removeEntityTarget(entity)
end,
removeTargetZone = function(target) removeTargetZone =
exports.jim_bridge:removeZoneTarget(target) function(target)
end, exports.jim_bridge:removeZoneTarget(target)
end,
removeTargetModel = function(model) removeTargetModel =
exports.jim_bridge:removeZoneTarget(model) function(model)
end, exports.jim_bridge:removeZoneTarget(model)
end,
}, },
} }
@@ -243,7 +261,8 @@ function createEntityTarget(entity, opts, dist)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
debugPrint("^6Bridge^7: ^2Creating new ^3Entity ^2target with ^6"..script.targetName.." ^2for entity ^7"..entity) debugPrint("^6Bridge^7: ^2Creating new ^3Entity ^2target with ^6"..script.targetName.." ^2for entity ^7"..entity)
return script.entityTarget(entity, opts, dist) return script.entityTarget(entity, opts, dist)
@@ -314,7 +333,8 @@ function createBoxTarget(data, opts, dist)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
debugPrint("^6Bridge^7: ^2Creating new ^3Box ^2target with ^6"..script.targetName.." ^7"..data[1]) debugPrint("^6Bridge^7: ^2Creating new ^3Box ^2target with ^6"..script.targetName.." ^7"..data[1])
local target = script.boxTarget(data, opts, dist) local target = script.boxTarget(data, opts, dist)
@@ -370,7 +390,8 @@ function createCircleTarget(data, opts, dist)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
debugPrint("^6Bridge^7: ^2Creating new ^3Sphere ^2target with ^6"..script.targetName.." ^7"..data[1]) debugPrint("^6Bridge^7: ^2Creating new ^3Sphere ^2target with ^6"..script.targetName.." ^7"..data[1])
local target = script.circleTarget(data, opts, dist) local target = script.circleTarget(data, opts, dist)
@@ -416,7 +437,8 @@ function createModelTarget(models, opts, dist)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
debugPrint("^6Bridge^7: ^2Creating new ^3Model ^2target with ^6"..script.targetName.."^7") debugPrint("^6Bridge^7: ^2Creating new ^3Model ^2target with ^6"..script.targetName.."^7")
local target = script.modelTarget(models, opts, dist) local target = script.modelTarget(models, opts, dist)
@@ -446,7 +468,8 @@ function removeEntityTarget(entity)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
script.removeTargetEntity(entity) script.removeTargetEntity(entity)
break break
@@ -471,7 +494,8 @@ function removeZoneTarget(target)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
script.removeTargetZone(target) script.removeTargetZone(target)
break break
@@ -494,7 +518,8 @@ function removeModelTarget(model)
end end
-- Check for target script and use that -- Check for target script and use that
for _, script in pairs(targetFunc) do for i = 1, #targetFunc do
local script = targetFunc[i]
if isStarted(script.targetName) then if isStarted(script.targetName) then
script.removeTargetModel(model) script.removeTargetModel(model)
break break