Merge branch 'jimathy:main' into main

This commit is contained in:
oosayeroo
2025-08-22 10:43:04 +01:00
committed by GitHub
17 changed files with 2951 additions and 2176 deletions

View File

@@ -52,7 +52,7 @@ function CheckBridgeVersion()
print((line:find("http") and "^7" or "^5")..line) print((line:find("http") and "^7" or "^5")..line)
end end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() SetTimeout(3600000, function()
CheckBridgeVersion() CheckBridgeVersion()
end) end)
else else

View File

@@ -116,3 +116,29 @@ else
TriggerServerEvent(getScript()..":clearAuthEventRequest") TriggerServerEvent(getScript()..":clearAuthEventRequest")
end, true) end, true)
end end
function distExploitCheck(table, src)
if not table then
--print("^1Error^7: ^1This wasn^7'^1t reigstered correctly or this is an exploit attempt^1")
return false
end
local ped = src and GetPlayerPed(src) or PlayerPedId()
local srcCoords = GetEntityCoords(ped)
local allow = false
for i = 1, #table do
if #(table[i] - srcCoords) <= 10 then
return true
else
allow = false
end
end
if not allow then
debugPrint(src and ("^1Src ^3"..src.." ").."^1Tried to open a registered shop/stash from over the distance limit^7")
return false
end
end

View File

@@ -87,7 +87,7 @@ function CheckVersion()
end end
end end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() CheckVersion() end) SetTimeout(3600000, function() CheckVersion() end)
else else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)") print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)")
end end

View File

@@ -124,7 +124,9 @@ 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 "")

View File

@@ -8,19 +8,22 @@
-- Text system handlers -- Text system handlers
local textHandlers = { local textHandlers = {
qb = { qb = {
show = function(text, image) show =
function(text, image)
if image then if image then
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
end end
exports[QBExport]:DrawText(text, 'left') exports[QBExport]:DrawText(text, 'left')
end, end,
hide = function() hide =
function()
exports[QBExport]:HideText() exports[QBExport]:HideText()
end end,
}, },
ox = { ox = {
show = function(input, image, oxStyleTable) show =
function(input, image, oxStyleTable)
local inputCount = #input local inputCount = #input
for i = 1, inputCount do for i = 1, inputCount do
input[i] = input[i] .. (i ~= inputCount and " \n" or "") input[i] = input[i] .. (i ~= inputCount and " \n" or "")
@@ -31,13 +34,15 @@ local textHandlers = {
style = oxStyleTable style = oxStyleTable
}) })
end, end,
hide = function() hide =
function()
lib.hideTextUI() lib.hideTextUI()
end end,
}, },
lation = { lation = {
show = function(input, image) show =
function(input, image)
local inputCount = #input local inputCount = #input
for i = 1, inputCount do for i = 1, inputCount do
input[i] = input[i] .. (i ~= inputCount and " \n" or "") input[i] = input[i] .. (i ~= inputCount and " \n" or "")
@@ -50,13 +55,29 @@ local textHandlers = {
position = 'left-center' position = 'left-center'
}) })
end, end,
hide = function() hide =
function()
exports.lation_ui:hideText() exports.lation_ui:hideText()
end,
},
esx = {
show =
function(text, image)
if image then
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
end end
ESX.TextUI(text, nil)
end,
hide =
function()
ESX.HideUI()
end,
}, },
gta = { gta = {
show = function(input, image, style) show =
function(input, image, style)
local text = "" local text = ""
for i = 1, #input do for i = 1, #input do
if input[i] ~= "" then if input[i] ~= "" then
@@ -68,25 +89,15 @@ local textHandlers = {
end end
DisplayHelpMsg(text:gsub("%:", ":~" .. (style or "g") .. "~")) DisplayHelpMsg(text:gsub("%:", ":~" .. (style or "g") .. "~"))
end, end,
hide = function() hide =
function()
ClearAllHelpMessages() ClearAllHelpMessages()
end
},
esx = {
show = function(text, image)
if image then
text = '<img src="'..(radarTable[image] or "")..'" style="width:12px;height:12px">'..text
end
ESX.TextUI(text, nil)
end, end,
hide = function()
ESX.HideUI()
end
}, },
red = { red = {
show = function(input) show =
function(input)
local text = "" local text = ""
for i = 1, #input do for i = 1, #input do
if input[i] ~= "" then if input[i] ~= "" then
@@ -95,9 +106,10 @@ local textHandlers = {
end end
TriggerEvent("jim-redui:DrawText", text) TriggerEvent("jim-redui:DrawText", text)
end, end,
hide = function() hide =
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
------------------------------------------------------------- -------------------------------------------------------------
@@ -582,6 +580,67 @@ function GetRandomTiming(tbl)
return type(tbl) == "table" and math.random(tbl[1], tbl[2]) or tbl return type(tbl) == "table" and math.random(tbl[1], tbl[2]) or tbl
end end
-------------------------------------------------------------
-- Player Movement
-------------------------------------------------------------
--- Instantly turns an entity to face a target (entity or coordinates) without animation.
---
--- @param ent number|nil The Ped to turn (defaults to player's Ped if nil).
--- @param ent2 number|vector3|nil The target entity or coordinates to face.
---
--- @usage
--- ```lua
--- instantLookEnt(nil, vector3(200.0, 300.0, 40.0))
--- instantLookEnt(ped1, ped2)
--- ```
function instantLookEnt(ent, ent2)
local ped = ent or PlayerPedId()
local p1 = GetEntityCoords(ped, true)
local p2 = type(ent2) == "vector3" and ent2 or GetEntityCoords(ent2, true)
local dx = p2.x - p1.x
local dy = p2.y - p1.y
local heading = GetHeadingFromVector_2d(dx, dy)
debugPrint("^6Bridge^7: ^1Forced ^2Turning Player to^7: '^6"..formatCoord(p2).."^7'")
SetEntityHeading(ped, heading)
end
--- Makes the player look towards a specific target with an animated turn.
---
--- If the player is not already facing the target (entity or coordinates), a turning animation is triggered.
---
--- @param entity number|vector3|vector4|nil The target to look at.
---
--- @usage
--- ```lua
--- lookEnt(vector3(200.0, 300.0, 40.0))
--- lookEnt(pedEntity)
--- ```
function lookEnt(entity)
local ped = PlayerPedId()
if entity then
if type(entity) == "vector3" or type(entity) == "vector4" then
if not IsPedHeadingTowardsPosition(ped, entity.xyz, 30.0) then
TaskTurnPedToFaceCoord(ped, entity.xyz, 1500)
debugPrint("^6Bridge^7: ^2Turning Player to^7: '^6"..formatCoord(entity).."^7'")
Wait(1500)
end
else
if DoesEntityExist(entity) then
local entCoords = GetEntityCoords(entity)
if not IsPedHeadingTowardsPosition(ped, entCoords, 30.0) then
TaskTurnPedToFaceCoord(ped, entCoords, 1500)
debugPrint("^6Bridge^7: ^2Turning Player to^7: '^6"..entity.."^7' - '"..formatCoord(entCoords).."^7'")
Wait(1500)
end
end
end
end
end
------------------------------------------------------------- -------------------------------------------------------------
-- Material and Prop Functions -- Material and Prop Functions
------------------------------------------------------------- -------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,58 @@
and teleporting via doors. and teleporting via doors.
]] ]]
local bossMenuFunc = {
{ name = "qb-management",
openBossMenu = function(isGang, group)
if isGang then
TriggerEvent("qb-gangmenu:client:OpenMenu")
else
TriggerEvent("qb-bossmenu:client:OpenMenu")
end
end,
},
{ name = "qbx_management",
openBossMenu = function(isGang, group)
if isGang then
exports["qbx_management"]:OpenBossMenu("gang")
else
exports["qbx_management"]:OpenBossMenu("job")
end
end,
},
{ name = "esx_society",
openBossMenu = function(isGang, group)
TriggerEvent('esx_society:openBossMenu', group, function() end, { wash = false })
end,
},
{ name = "tss-bossmenu",
openBossMenu = function(isGang, group)
TriggerEvent("tss-bossmenu:client:OpenMenu")
end,
},
{ name = "okokBossMenu",
openBossMenu = function(isGang, group)
ExecuteCommand('openbossmenu')
end,
},
}
function openBossMenu(isGang, group)
for i = 1, #bossMenuFunc do
local bossmenu = bossMenuFunc[i]
if isStarted(bossmenu.name) then
bossmenu.openBossMenu(isGang, group)
return
end
end
end
------------------------------------------------------------- -------------------------------------------------------------
-- Global Duty Status -- Global Duty Status
------------------------------------------------------------- -------------------------------------------------------------
@@ -246,19 +298,3 @@ function useDoor(data)
DoScreenFadeIn(1000) DoScreenFadeIn(1000)
Wait(100) Wait(100)
end end
function openBossMenu(isGang, group)
if isStarted("qb-management") then
if isGang then
TriggerEvent("qb-gangmenu:client:OpenMenu")
else
TriggerEvent("qb-bossmenu:client:OpenMenu")
end
elseif isStarted("qbx_management") then
exports["qbx_management"]:OpenBossMenu(isGang and "gang" or "job")
elseif isStarted("esx_society") then
TriggerEvent('esx_society:openBossMenu', group, function() end, { wash = false })
end
end

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,182 +263,12 @@ 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 = { if progressFunc[Config.System.ProgressBar].start(data) then
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 result = true
else else
result = false result = false
end 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
end
while result == nil do while result == nil do
Wait(10) Wait(10)
@@ -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]: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")
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
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,66 +17,89 @@
local notifyFunc = { local notifyFunc = {
okok = { okok = {
client = function(title, message, type) client =
function(title, message, type)
TriggerEvent('okokNotify:Alert', title, message, 6000, type) TriggerEvent('okokNotify:Alert', title, message, 6000, type)
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type) TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type)
end, end,
}, },
qb = { qb = {
client = function(title, message, type) client =
function(title, message, type)
TriggerEvent("QBCore:Notify", message, type) TriggerEvent("QBCore:Notify", message, type)
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent("QBCore:Notify", src, message, type) TriggerClientEvent("QBCore:Notify", src, message, type)
end, end,
}, },
qs = { qs = {
client = function(title, message, type) client =
function(title, message, type)
exports['qs-interface']:AddNotify(message, title, 6000) exports['qs-interface']:AddNotify(message, title, 6000)
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent('interface:notification', src, message, title, 6000) TriggerClientEvent('interface:notification', src, message, title, 6000)
end, end,
}, },
ox = { ox = {
client = function(title, message, type) client =
function(title, message, type)
exports.ox_lib:notify({ title = title, description = message, type = type or "success" }) exports.ox_lib:notify({ title = title, description = message, type = type or "success" })
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent('ox_lib:notify', src, { title = title, description = message, type = type or "success" }) TriggerClientEvent('ox_lib:notify', src, { title = title, description = message, type = type or "success" })
end, 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,
},
esx = { esx = {
client = function(title, message, type) client =
function(title, message, type)
exports["esx_notify"]:Notify(type, 4000, message) exports["esx_notify"]:Notify(type, 4000, message)
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent(getScript()..":DisplayESXNotify", src, type, message) TriggerClientEvent(getScript()..":DisplayESXNotify", src, type, message)
end, end,
}, },
lation = { lation = {
client = function(title, message, type) client =
function(title, message, type)
exports.lation_ui:notify({ title = title, message = message, type = type or "success", }) exports.lation_ui:notify({ title = title, message = message, type = type or "success", })
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent("lation_ui:notify", src, { title = title, message = message, type = type or "success", }) TriggerClientEvent("lation_ui:notify", src, { title = title, message = message, type = type or "success", })
end, 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 =
function(title, message, type)
TriggerEvent("jim-redui:Notify", title, message, type) TriggerEvent("jim-redui:Notify", title, message, type)
end, end,
server = function(title, message, type, src) server =
function(title, message, type, src)
TriggerClientEvent("jim-redui:Notify", src, title, message, type) TriggerClientEvent("jim-redui:Notify", src, title, message, type)
end, end,
}, },

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)
---
--- @param data table A table containing the mail data.
--- - subject (string): The email subject.
--- - sender (string): The sender identifier.
--- - message (string): The email body content.
--- - actions (table|nil): Optional action buttons for the email.
--- @usage
--- sendPhoneMail({
--- subject = "Welcome!",
--- sender = "Admin",
--- message = "Thank you for joining our server.",
--- actions = {
--- { label = "Reply", action = replyFunction }
--- }
--- })
function sendPhoneMail(data)
-- Define each supported phone system and its corresponding mail-sending function.
local phoneSystems = {
{ name = "gksphone",
send = function(mailData)
exports["gksphone"]:SendNewMail(mailData) exports["gksphone"]:SendNewMail(mailData)
end, end,
sendInvoice =
function(mailData)
-- Defensive check for required fields
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "label" }
for _, field in ipairs(required) do
if mailData[field] == nil then
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
return
end
end
MySQL.Async.execute(
'INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)',
{
['@citizenid'] = mailData.billedCitizenid,
['@amount'] = mailData.amount,
['@society'] = mailData.job,
['@sender'] = mailData.name,
['@sendercitizenid'] = mailData.billerCitizenid,
['@label'] = mailData.label
}
)
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
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
return
end
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) { name = "jpr-phonesystem",
-- if id then sendMail =
-- TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', mailData.src, id, mailData.name, mailData.job, mailData.billerCitizenid, mailData.amount, GetInvokingResource()) function(mailData)
-- end TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
end end,
) },
{ name = "ef-phone",
sendMail =
end function(mailData)
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
end,
}, },
{
name = "gksphone",
send = function(mailData)
-- Defensive check for required fields
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "label" }
for _, field in ipairs(required) do
if mailData[field] == nil then
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
return
end
end
MySQL.Async.execute( }
'INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)',
{
['@citizenid'] = mailData.billedCitizenid, --- Sends a phone mail using the detected phone system.
['@amount'] = mailData.amount, --- The function iterates through a prioritized list of supported phone systems.
['@society'] = mailData.job, --- Once an active system is found (via `isStarted`), the corresponding mail function is executed.
['@sender'] = mailData.name, ---
['@sendercitizenid'] = mailData.billerCitizenid, --- @param data table A table containing the mail data.
['@label'] = mailData.label --- - subject (string): The email subject.
} --- - sender (string): The sender identifier.
) --- - message (string): The email body content.
--- - actions (table|nil): Optional action buttons for the email.
--- @usage
--- sendPhoneMail({
--- subject = "Welcome!",
--- 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
} 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
-- 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

@@ -11,70 +11,108 @@
• Getting active players near a coordinate. • Getting active players near a coordinate.
]] ]]
-------------------------------------------------------------
-- Player Movement
-------------------------------------------------------------
--- Instantly turns an entity to face a target (entity or coordinates) without animation.
---
--- @param ent number|nil The Ped to turn (defaults to player's Ped if nil).
--- @param ent2 number|vector3|nil The target entity or coordinates to face.
---
--- @usage
--- ```lua
--- instantLookEnt(nil, vector3(200.0, 300.0, 40.0))
--- instantLookEnt(ped1, ped2)
--- ```
function instantLookEnt(ent, ent2)
local ped = ent or PlayerPedId()
local p1 = GetEntityCoords(ped, true)
local p2 = type(ent2) == "vector3" and ent2 or GetEntityCoords(ent2, true)
local dx = p2.x - p1.x
local dy = p2.y - p1.y
local heading = GetHeadingFromVector_2d(dx, dy)
debugPrint("^6Bridge^7: ^1Forced ^2Turning Player to^7: '^6"..formatCoord(p2).."^7'")
SetEntityHeading(ped, heading)
end
--- Makes the player look towards a specific target with an animated turn.
---
--- If the player is not already facing the target (entity or coordinates), a turning animation is triggered.
---
--- @param entity number|vector3|vector4|nil The target to look at.
---
--- @usage
--- ```lua
--- lookEnt(vector3(200.0, 300.0, 40.0))
--- lookEnt(pedEntity)
--- ```
function lookEnt(entity)
local ped = PlayerPedId()
if entity then
if type(entity) == "vector3" or type(entity) == "vector4" then
if not IsPedHeadingTowardsPosition(ped, entity.xyz, 30.0) then
TaskTurnPedToFaceCoord(ped, entity.xyz, 1500)
debugPrint("^6Bridge^7: ^2Turning Player to^7: '^6"..formatCoord(entity).."^7'")
Wait(1500)
end
else
if DoesEntityExist(entity) then
local entCoords = GetEntityCoords(entity)
if not IsPedHeadingTowardsPosition(ped, entCoords, 30.0) then
TaskTurnPedToFaceCoord(ped, entCoords, 1500)
debugPrint("^6Bridge^7: ^2Turning Player to^7: '^6"..entity.."^7' - '"..formatCoord(entCoords).."^7'")
Wait(1500)
end
end
end
end
end
------------------------------------------------------------- -------------------------------------------------------------
-- Server Event Handlers for Needs -- Server Event Handlers for Needs
------------------------------------------------------------- -------------------------------------------------------------
local hungerThirstFunc = {
{ framework = QBXExport,
setThirst =
function(src, thirst)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('thirst', thirst)
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata.hunger, thirst)
end,
setHunger =
function(src, hunger)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('hunger', hunger)
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.thirst)
end,
},
{ framework = QBExport,
setThirst =
function(src, thirst)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('thirst', thirst)
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata.hunger, thirst)
end,
setHunger =
function(src, hunger)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('hunger', hunger)
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.thirst)
end,
},
{ framework = RSGExport,
setThirst =
function(src, thirst)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('thirst', thirst)
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata.hunger, thirst)
end,
setHunger =
function(src, hunger)
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('hunger', hunger)
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.thirst)
end,
},
{ framework = ESXExport,
setThirst =
function(src, thirst)
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
end,
setHunger =
function(src, hunger)
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
end,
},
}
--- Sets the player's thirst level.
---
--- @param src number The player's server ID.
--- @param thirst number The new thirst level.
---
--- @usage
--- ```lua
--- setThirst(playerId, 80)
--- ```
function setThirst(src, thirst)
for i = 1, #hungerThirstFunc do
local framework = hungerThirstFunc[i]
if isStarted(framework.framework) then
debugPrint("^4Debug^7: ^2Adding ^3"..framework.framework.." ^2thirst^7: ^3"..thirst.." ^2to player^7: ^3"..src.."^7")
framework.setThirst(src, thirst)
return
end
end
end
--- Sets the player's hunger level.
---
--- @param src number The player's server ID.
--- @param hunger number The new hunger level.
---
--- @usage
--- ```lua
--- setHunger(playerId, 60)
--- ```
function setHunger(src, hunger)
for i = 1, #hungerThirstFunc do
local framework = hungerThirstFunc[i]
if isStarted(framework.framework) then
debugPrint("^4Debug^7: ^2Adding ^3"..framework.framework.." ^2hunger^7: ^3"..hunger.." ^2to player^7: ^3"..src.."^7")
framework.setHunger(src, hunger)
return
end
end
end
--- Server event handler for urinal usage. --- Server event handler for urinal usage.
--- Decreases player's thirst by a random amount. --- Decreases player's thirst by a random amount.
RegisterNetEvent(getScript()..":server:Urinal", function() RegisterNetEvent(getScript()..":server:Urinal", function()
@@ -99,72 +137,94 @@ RegisterNetEvent(getScript()..":server:setNeed", function(needType, amount)
end end
end) end)
--- Sets the player's thirst level.
---
--- @param src number The player's server ID.
--- @param thirst number The new thirst level.
---
--- @usage
--- ```lua
--- setThirst(playerId, 80)
--- ```
function setThirst(src, thirst)
debugPrint("^4Debug^7: ^2Adding thirst^7: ^3"..thirst.." ^2to player^7: ^3"..src.."^7")
if isStarted(ESXExport) then
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('thirst', thirst)
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata.hunger, thirst)
end
end
--- Sets the player's hunger level.
---
--- @param src number The player's server ID.
--- @param hunger number The new hunger level.
---
--- @usage
--- ```lua
--- setHunger(playerId, 60)
--- ```
function setHunger(src, hunger)
debugPrint("^4Debug^7: ^2Adding hunger^7: ^3"..hunger.." ^2to player^7: ^3"..src.."^7")
if isStarted(ESXExport) then
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
local Player = Core.Functions.GetPlayer(src)
Player.Functions.SetMetaData('hunger', hunger)
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.thirst)
end
end
------------------------------------------------------------- -------------------------------------------------------------
-- Economy Event Handlers -- Economy Event Handlers
------------------------------------------------------------- -------------------------------------------------------------
--- BillPlayer local billPlayerFunc = {
function billPlayer(data) jim =
if not Config.System.Billing or Config.System.Billing == "jim" then function(data)
TriggerEvent("jim-payments:client:Charge", { TriggerEvent("jim-payments:client:Charge", {
job = data.job, job = data.job,
gang = data.gang, gang = data.gang,
coords = data.coords.xyz, coords = data.coords.xyz,
img = data.img img = data.img
}) })
elseif Config.System.Billing == "okok" then end,
-- TriggerServerEvent("okokBilling:CreateCustomInvoice", target, price, reason, invoiceSource, society, societyName) okok =
function(data)
TriggerEvent("okokBilling:ToggleCreateInvoice") TriggerEvent("okokBilling:ToggleCreateInvoice")
end,
}
--- BillPlayer
function billPlayer(data)
if Config.System.Billing and billPlayerFunc[Config.System.Billing] then
billPlayerFunc[Config.System.Billing](data)
else
debugPrint("^1Error^7: ^1No billing script detected")
end end
end end
-- Money Handlers
local moneyFunc = {
{ framework = OXInv,
chargePlayer =
function(src, amount, moneyType)
return exports[OXInv]:RemoveItem(src, "money", amount)
end,
fundPlayer =
function(src, amount, moneyType)
return exports[OXInv]:AddItem(src, "money", amount)
end,
},
{ framework = QBXExport,
chargePlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.RemoveMoney(moneyType or "cash", amount)
end,
fundPlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.AddMoney(moneyType or "cash", amount)
end,
},
{ framework = QBExport,
chargePlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.RemoveMoney(moneyType or "cash", amount)
end,
fundPlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.AddMoney(moneyType or "cash", amount)
end,
},
{ framework = RSGExport,
chargePlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.RemoveMoney(moneyType or "cash", amount)
end,
fundPlayer =
function(src, amount, moneyType)
return Core.Functions.GetPlayer(src).Functions.AddMoney(moneyType or "cash", amount)
end,
},
{ framework = ESXExport,
chargePlayer =
function(src, amount, moneyType)
return ESX.GetPlayerFromId(src).removeMoney(amount, "")
end,
fundPlayer =
function(src, amount, moneyType)
return ESX.GetPlayerFromId(src).addMoney(amount, "")
end,
},
}
--- Charges a player by removing money from their account. --- Charges a player by removing money from their account.
--- ---
--- @param cost number The amount to charge. --- @param cost number The amount to charge.
@@ -175,59 +235,33 @@ end
--- ```lua --- ```lua
--- chargePlayer(100, "cash", playerId) --- chargePlayer(100, "cash", playerId)
--- ``` --- ```
---
function chargePlayer(cost, moneyType, newsrc) function chargePlayer(cost, moneyType, newsrc)
local is_success = false local is_success = false
local src = newsrc or source local src = newsrc or source
local fundResource = ""
if cost < 0 then if cost <= 0 then
debugPrint("^1Error^7: ^7SRC: ^3"..src.." ^2Tried to charge a minus value^7", cost) debugPrint("^1Error^7: ^7SRC: ^3"..src.." ^2Tried to charge a zero or minus value^7", cost)
return return
end end
if moneyType == "cash" then
if isStarted(OXInv) then fundResource = OXInv
is_success = exports[OXInv]:RemoveItem(src, "money", cost)
elseif isStarted(QBExport) or isStarted(QBXExport) then
fundResource = QBExport
is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
elseif isStarted(RSGExport) then
fundResource = RSGExport
is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
elseif isStarted(ESXExport) then
fundResource = ESXExport
ESX.GetPlayerFromId(src).removeMoney(cost, "")
is_success = true
for i = 1, #moneyFunc do
local framework = moneyFunc[i]
if framework.framework == OXInv and moneyType == "bank" then goto skip end
if isStarted(framework.framework) then
debugPrint("^6Bridge^7: ^2Charging ^3"..framework.framework.." ^2Player^7: '^6"..cost.."^7'", moneyType)
is_success = framework.chargePlayer(src, cost, moneyType)
break
end end
elseif moneyType == "bank" then ::skip::
if isStarted(QBExport) or isStarted(QBXExport) then
fundResource = QBExport
is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
elseif isStarted(RSGExport) then
fundResource = RSGExport
is_success = Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
elseif isStarted(ESXExport) then
fundResource = ESXExport
ESX.GetPlayerFromId(src).removeMoney(cost, "")
is_success = true
end
end
if fundResource == "" then
print("Cannot charge player - check starter.lua")
else
debugPrint("^6Bridge^7: ^2Charging ^2Player^7: '^6"..cost.."^7'", moneyType, fundResource)
end end
return is_success return is_success
end end
RegisterNetEvent(getScript()..":server:ChargePlayer", function(cost, moneyType, newsrc) RegisterNetEvent(getScript()..":server:ChargePlayer", function(cost, moneyType, newsrc)
debugPrint(GetInvokingResource())
if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= "qb-core" then if GetInvokingResource() and GetInvokingResource() ~= getScript() and GetInvokingResource() ~= "qb-core" then
debugPrint("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7") print(GetInvokingResource())
print("^1Error^7: ^1Possible exploit^7, ^1vital function was called from an external resource^7")
return return
end end
chargePlayer(cost, moneyType, newsrc) chargePlayer(cost, moneyType, newsrc)
@@ -246,48 +280,23 @@ end)
function fundPlayer(fund, moneyType, newsrc) function fundPlayer(fund, moneyType, newsrc)
local is_success = false local is_success = false
local src = newsrc or source local src = newsrc or source
local fundResource = ""
if moneyType == "cash" then if fund <= 0 then
if isStarted(OXInv) then debugPrint("^1Error^7: ^7SRC: ^3"..src.." ^2Tried to fund a zero or minus value^7", fund)
fundResource = OXInv return
is_success = exports[OXInv]:AddItem(src, "money", fund)
elseif isStarted(QBExport) or isStarted(QBXExport) then
fundResource = QBExport
is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund)
elseif isStarted(RSGExport) then
fundResource = RSGExport
is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund)
elseif isStarted(ESXExport) then
fundResource = ESXExport
ESX.GetPlayerFromId(src).addMoney(fund, "")
is_success = true
end
elseif moneyType == "bank" then
if isStarted(QBExport) or isStarted(QBXExport) then
fundResource = QBExport
is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund)
elseif isStarted(RSGExport) then
fundResource = RSGExport
is_success = Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund)
elseif isStarted(ESXExport) then
fundResource = ESXExport
ESX.GetPlayerFromId(src).addMoney(fund, "")
is_success = true
end
end end
if fundResource == "" then for i = 1, #moneyFunc do
print("Cannot fund player - check starter.lua") local framework = moneyFunc[i]
else if framework.framework == OXInv and moneyType == "bank" then goto skip end
debugPrint("^6Bridge^7: ^2Funding Player: '^2"..fund.."^7'", moneyType, fundResource) if isStarted(framework.framework) then
debugPrint("^6Bridge^7: ^2Funding ^3"..framework.framework.." ^2Player^7: '^6"..fund.."^7'", moneyType)
is_success = framework.fundPlayer(src, fund, moneyType)
break
end end
::skip::
end
return is_success return is_success
end end
@@ -534,30 +543,13 @@ function hasJob(job, source, grade)
return hasJobFlag, duty return hasJobFlag, duty
end end
--- Retrieves basic player information (name, cash, bank, job, etc.) based on the active core/inventory system. ----------------------------------
--- ---
--- Can be called server-side (passing a player source) or client-side (for current player). local getPlayerFunc = {
--- { framework = ESXExport,
--- @param source number|nil Optional player server ID. serverSide =
--- @return table A table containing player details. function(src)
---
--- @usage
--- ```lua
--- -- Get information for a specific player
--- local playerInfo = getPlayer(playerId)
--- print(playerInfo.name, playerInfo.cash, playerInfo.bank)
---
--- -- Get information for the current player (client-side)
--- local myInfo = getPlayer()
--- print(myInfo.name, myInfo.cash, myInfo.bank)
--- ```
function getPlayer(source)
local Player = {} local Player = {}
--debugPrint("^6Bridge^7: ^2Getting ^3Player^2 info^7")
if source then
local src = tonumber(source)
if isStarted(ESXExport) then
local info = ESX.GetPlayerFromId(src) local info = ESX.GetPlayerFromId(src)
if not info then return {} end if not info then return {} end
Player = { Player = {
@@ -577,8 +569,45 @@ function getPlayer(source)
--account = info.charinfo.account, --account = info.charinfo.account,
citizenId = info.identifier, citizenId = info.identifier,
} }
return Player
end,
elseif isStarted(OXCoreExport) then clientSide =
function()
local Player = {}
local info = ESX.GetPlayerData()
if not info.firstName then return {} end
local cash, bank = 0, 0
for _, v in pairs(info.accounts) do
if v.name == "money" then cash = v.money end
if v.name == "bank" then bank = v.money end
end
Player = {
firstname = info.firstName,
lastname = info.lastName,
name = info.firstName.." "..info.lastName,
cash = cash,
bank = bank,
source = GetPlayerServerId(PlayerId()),
job = info.job.name,
--jobBoss = info.job.isboss,
--gang = info.gang.name,
--gangBoss = info.gang.isboss,
onDuty = info.job.onDuty,
--account = info.charinfo.account,
citizenId = info.identifier,
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
return Player
end,
},
{ framework = OXCoreExport,
serverSide =
function(src)
local Player = {}
local file = ('imports/%s.lua'):format('server') local file = ('imports/%s.lua'):format('server')
local import = LoadResourceFile('ox_core', file) local import = LoadResourceFile('ox_core', file)
local chunk = assert(load(import, ('@@ox_core/%s'):format(file))) local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
@@ -600,8 +629,38 @@ function getPlayer(source)
--account = info.charinfo.account, --account = info.charinfo.account,
citizenId = player.stateId, citizenId = player.stateId,
} }
return Player
end,
elseif isStarted(QBXExport) then clientSide =
function()
local Player = {}
if not OxPlayer.userId then return {} end
Player = {
firstname = OxPlayer.get("firstName"),
lastname = OxPlayer.get("lastName"),
name = OxPlayer.get("firstName").." "..OxPlayer.get("lastName"),
cash = exports[OXInv]:Search('count', "money"),
bank = 0,
source = GetPlayerServerId(PlayerId()),
job = OxPlayer.getGroups(),
--jobBoss = info.job.isboss,
gang = OxPlayer.getGroups(),
--gangBoss = info.gang.isboss,
--onDuty = info.job.onduty,
--account = info.charinfo.account,
citizenId = OxPlayer.userId,
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
return Player
end,
},
{ framework = QBXExport,
serverSide =
function(src)
local Player = {}
local info = exports[QBXExport]:GetPlayer(src) local info = exports[QBXExport]:GetPlayer(src)
if not info then return {} end if not info then return {} end
Player = { Player = {
@@ -624,112 +683,12 @@ function getPlayer(source)
isDown = info.PlayerData.metadata["inlaststand"], isDown = info.PlayerData.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
return Player
end,
elseif isStarted(QBExport) and not isStarted(QBXExport) then clientSide =
if Core.Functions.GetPlayer(src) then function()
local info = Core.Functions.GetPlayer(src).PlayerData local Player = {}
if not info then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
isDead = info.metadata["isdead"],
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
end
elseif isStarted(RSGExport) then
if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData
if not info then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
isDead = info.metadata["isdead"],
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
end
else
print("^4ERROR^7: ^2No Core detected for getPlayer() - Check starter.lua")
end
else
-- Client-side: Get current player info.
if isStarted(ESXExport) and ESX ~= nil then
local info = ESX.GetPlayerData()
if not info.firstName then return {} end
local cash, bank = 0, 0
for k, v in pairs(info.accounts) do
if v.name == "money" then cash = v.money end
if v.name == "bank" then bank = v.money end
end
Player = {
firstname = info.firstName,
lastname = info.lastName,
name = info.firstName.." "..info.lastName,
cash = cash,
bank = bank,
source = GetPlayerServerId(PlayerId()),
job = info.job.name,
--jobBoss = info.job.isboss,
--gang = info.gang.name,
--gangBoss = info.gang.isboss,
onDuty = info.job.onDuty,
--account = info.charinfo.account,
citizenId = info.identifier,
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
elseif isStarted(OXCoreExport) then
if not OxPlayer.userId then return {} end
Player = {
firstname = OxPlayer.get("firstName"),
lastname = OxPlayer.get("lastName"),
name = OxPlayer.get("firstName").." "..OxPlayer.get("lastName"),
cash = exports[OXInv]:Search('count', "money"),
bank = 0,
source = GetPlayerServerId(PlayerId()),
job = OxPlayer.getGroups(),
--jobBoss = info.job.isboss,
gang = OxPlayer.getGroups(),
--gangBoss = info.gang.isboss,
--onDuty = info.job.onduty,
--account = info.charinfo.account,
citizenId = OxPlayer.userId,
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayerData() local info = exports[QBXExport]:GetPlayerData()
if not info.charinfo then return {} end if not info.charinfo then return {} end
Player = { Player = {
@@ -752,8 +711,44 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
return Player
end,
},
elseif isStarted(QBExport) and not isStarted(QBXExport) then { framework = QBExport,
serverSide =
function(src)
local Player = {}
if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData
if not info then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
isDead = info.metadata["isdead"],
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
end
return Player
end,
clientSide =
function()
local Player = {}
local info = nil local info = nil
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end) Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
if not info.charinfo then return {} end if not info.charinfo then return {} end
@@ -778,8 +773,44 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
return Player
end,
},
elseif isStarted(RSGExport) then { framework = RSGExport,
serverSide =
function(src)
local Player = {}
if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData
if not info then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
source = info.source,
job = info.job.name,
jobBoss = info.job.isboss,
jobInfo = info.job,
gang = info.gang.name,
gangBoss = info.gang.isboss,
gangInfo = info.gang,
onDuty = info.job.onduty,
account = info.charinfo.account,
citizenId = info.citizenid,
isDead = info.metadata["isdead"],
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
end
return Player
end,
clientSide =
function()
local Player = {}
local info = nil local info = nil
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end) Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
if not info.charinfo then return {} end if not info.charinfo then return {} end
@@ -804,11 +835,53 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
return Player
end,
},
}
--- Retrieves basic player information (name, cash, bank, job, etc.) based on the active core/inventory system.
---
--- Can be called server-side (passing a player source) or client-side (for current player).
---
--- @param source number|nil Optional player server ID.
--- @return table A table containing player details.
---
--- @usage
--- ```lua
--- -- Get information for a specific player
--- local playerInfo = getPlayer(playerId)
--- print(playerInfo.name, playerInfo.cash, playerInfo.bank)
---
--- -- Get information for the current player (client-side)
--- local myInfo = getPlayer()
--- print(myInfo.name, myInfo.cash, myInfo.bank)
--- ```
function getPlayer(source)
local Player = {}
--debugPrint("^6Bridge^7: ^2Getting ^3Player^2 info^7")
if source then
for i = 1, #getPlayerFunc do
local framework = getPlayerFunc[i]
if isStarted(framework.framework) then
Player = framework.serverSide(source)
break
end
end
else else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3starter^1.^2lua^7")
for i = 1, #getPlayerFunc do
local framework = getPlayerFunc[i]
if isStarted(framework.framework) then
Player = framework.clientSide()
break
end end
end end
end
return Player return Player
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,17 +1,16 @@
local activeSkillCheck = false local skillCheckFunc = {
qb = {
function skillCheck(data) start = function(data)
local result = false
if Config.System.skillCheck == "qb" then
local Skillbar = exports["qb-minigames"]:Skillbar() local Skillbar = exports["qb-minigames"]:Skillbar()
if Skillbar then if Skillbar then
result = true return true
else else
result = false return false
end end
end,
elseif Config.System.skillCheck == "ox" then },
ox = {
start = function(data)
local Skillbar = exports[OXLibExport]:skillCheck( local Skillbar = exports[OXLibExport]:skillCheck(
{ {
"easy", "easy",
@@ -25,14 +24,24 @@ function skillCheck(data)
"4" "4"
}) })
if Skillbar then if Skillbar then
result = true return true
else else
result = false return false
end end
elseif Config.System.skillCheck == "gta" then end,
exports.jim_bridge:skillCheck() },
gta = {
elseif Config.System.skillCheck == "lation" then 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("", local Skillbar = exports.lation_ui:skillCheck("",
{ {
"easy", "easy",
@@ -45,14 +54,19 @@ function skillCheck(data)
"3", "3",
"4" "4"
}) })
if Skillbar then if Skillbar then
result = true return true
else else
result = false return false
end end
else end,
result = true },
}
function skillCheck(data)
if Config.System.skillCheck then
return skillCheckFunc[Config.System.skillCheck].start(data)
end end
return result return true
end end

View File

@@ -12,9 +12,9 @@
]] ]]
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'")
@@ -28,7 +28,8 @@ local societyFunc = {
end end
return exports["qb-banking"]:GetAccountBalance(society) return exports["qb-banking"]:GetAccountBalance(society)
end, end,
chargeSociety = function(society, amount) chargeSociety =
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'")
@@ -40,7 +41,8 @@ local societyFunc = {
end end
exports["qb-banking"]:RemoveMoney(society, amount) exports["qb-banking"]:RemoveMoney(society, amount)
end, end,
fundSociety = function(society, amount) fundSociety =
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'")
@@ -56,62 +58,70 @@ local societyFunc = {
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 =
function(society, amount)
exports['Renewed-Banking']:removeAccountMoney(society, amount) exports['Renewed-Banking']:removeAccountMoney(society, amount)
end, end,
fundSociety = function(society, amount) fundSociety =
function(society, amount)
exports['Renewed-Banking']:addAccountMoney(society, amount) exports['Renewed-Banking']:addAccountMoney(society, amount)
end, 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 =
function(society, amount)
exports["fd_banking"]:RemoveMoney(society, amount) exports["fd_banking"]:RemoveMoney(society, amount)
end, end,
fundSociety = function(society, amount) fundSociety =
function(society, amount)
exports["fd_banking"]:AddMoney(society, amount) exports["fd_banking"]:AddMoney(society, amount)
end, 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 =
function(society, amount)
exports['okokBanking']:RemoveMoney(society, amount) exports['okokBanking']:RemoveMoney(society, amount)
end, end,
fundSociety = function(society, amount) fundSociety =
function(society, amount)
exports['okokBanking']:AddMoney(society, amount) exports['okokBanking']:AddMoney(society, amount)
end, 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 =
function(society, amount)
if Jobs[society] then if Jobs[society] then
exports["tgiann-bank"]:RemoveJobMoney(society, amount) exports["tgiann-bank"]:RemoveJobMoney(society, amount)
else else
exports["tgiann-bank"]:RemoveGangMoney(society, amount) exports["tgiann-bank"]:RemoveGangMoney(society, amount)
end end
end, end,
fundSociety = function(society, amount) fundSociety =
function(society, amount)
if Jobs[society] then if Jobs[society] then
exports["tgiann-bank"]:AddJobMoney(society, amount) exports["tgiann-bank"]:AddJobMoney(society, amount)
else else
@@ -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,9 +18,9 @@
]] ]]
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] = {
@@ -36,7 +36,8 @@ local targetFunc = {
exports[OXTargetExport]:addLocalEntity(entity, options) exports[OXTargetExport]:addLocalEntity(entity, options)
end, end,
boxTarget = function(data, opts, dist) boxTarget =
function(data, opts, dist)
local options = {} local options = {}
for i = 1, #opts do for i = 1, #opts do
options[i] = { options[i] = {
@@ -67,7 +68,8 @@ local targetFunc = {
return target return target
end, end,
circleTarget = function(data, opts, dist) circleTarget =
function(data, opts, dist)
local options = {} local options = {}
for i = 1, #opts do for i = 1, #opts do
options[i] = { options[i] = {
@@ -89,7 +91,8 @@ local targetFunc = {
return target return target
end, end,
modelTarget = function(models, opts, dist) modelTarget =
function(models, opts, dist)
local options = {} local options = {}
for i = 1, #opts do for i = 1, #opts do
options[i] = { options[i] = {
@@ -105,83 +108,98 @@ local targetFunc = {
exports[OXTargetExport]:addModel(models, options) exports[OXTargetExport]:addModel(models, options)
end, end,
removeTargetEntity = function(entity) removeTargetEntity =
function(entity)
exports[OXTargetExport]:removeLocalEntity(entity, nil) exports[OXTargetExport]:removeLocalEntity(entity, nil)
end, end,
removeTargetZone = function(target) removeTargetZone =
function(target)
exports[OXTargetExport]:removeZone(target, true) exports[OXTargetExport]:removeZone(target, true)
end, end,
removeTargetModel = function(model) removeTargetModel =
function(model)
exports[OXTargetExport]:removeModel(model, nil) exports[OXTargetExport]:removeModel(model, nil)
end, 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 =
function(data, opts, dist)
local options = { options = opts, distance = dist } local options = { options = opts, distance = dist }
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options) local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
return data[1] return data[1]
end, end,
circleTarget = function(data, opts, dist) circleTarget =
function(data, opts, dist)
local options = { options = opts, distance = dist } local options = { options = opts, distance = dist }
local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options) local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options)
return data[1] return data[1]
end, end,
modelTarget = function(models, opts, dist) modelTarget =
function(models, opts, dist)
local options = { options = opts, distance = dist } local options = { options = opts, distance = dist }
exports[QBTargetExport]:AddTargetModel(models, options) exports[QBTargetExport]:AddTargetModel(models, options)
end, end,
removeTargetEntity = function(entity) removeTargetEntity =
function(entity)
exports[QBTargetExport]:RemoveTargetEntity(entity) exports[QBTargetExport]:RemoveTargetEntity(entity)
end, end,
removeTargetZone = function(target) removeTargetZone =
function(target)
exports[QBTargetExport]:RemoveZone(target) exports[QBTargetExport]:RemoveZone(target)
end, end,
removeTargetModel = function(model) removeTargetModel =
function(model)
exports[QBTargetExport]:RemoveTargetModel(model, "Test") exports[QBTargetExport]:RemoveTargetModel(model, "Test")
end, 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 =
function(data, opts, dist)
return exports.jim_bridge:createZoneTarget(data, opts, dist) return exports.jim_bridge:createZoneTarget(data, opts, dist)
end, end,
circleTarget = function(data, opts, dist) circleTarget =
function(data, opts, dist)
return exports.jim_bridge:createZoneTarget(data, opts, dist) return exports.jim_bridge:createZoneTarget(data, opts, dist)
end, end,
modelTarget = function(models, opts, dist) modelTarget =
function(models, opts, dist)
return exports.jim_bridge:createModelTarget(models, opts, dist) return exports.jim_bridge:createModelTarget(models, opts, dist)
end, end,
removeTargetEntity = function(entity) removeTargetEntity =
function(entity)
exports.jim_bridge:removeEntityTarget(entity) exports.jim_bridge:removeEntityTarget(entity)
end, end,
removeTargetZone = function(target) removeTargetZone =
function(target)
exports.jim_bridge:removeZoneTarget(target) exports.jim_bridge:removeZoneTarget(target)
end, end,
removeTargetModel = function(model) removeTargetModel =
function(model)
exports.jim_bridge:removeZoneTarget(model) exports.jim_bridge:removeZoneTarget(model)
end, 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