Merge branch 'jimathy:main' into main

This commit is contained in:
oosayeroo
2025-06-03 08:54:36 +01:00
committed by GitHub
15 changed files with 270 additions and 91 deletions

View File

@@ -23,24 +23,36 @@ function CheckBridgeVersion()
CreateThread(function() CreateThread(function()
Wait(4000) Wait(4000)
local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version') local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version')
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersionRaw, headers) --PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/test.txt', function(err, body, headers)
if not newestVersionRaw then PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, body, headers)
if not body then
print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)") print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)")
return return
end end
newestVersionRaw = newestVersionRaw:match("[^\r\n]+") local lines = {}
for line in body:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
local newestVersionRaw = lines[1] or "0.0.0"
local changelog = {}
for i = 2, #lines do
table.insert(changelog, lines[i])
end
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw) local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
if compareResult == 0 then if compareResult == 0 then
print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)") print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then elseif compareResult < 0 then
-- Made the check a bit more obvious
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)") print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() SetTimeout(1200000, function()
-- Do a naughty repeat message every 20 minutes until the the script is updated
CheckBridgeVersion() CheckBridgeVersion()
end) end)
else else
@@ -51,4 +63,5 @@ function CheckBridgeVersion()
end end
end end
CheckBridgeVersion() CheckBridgeVersion()

View File

@@ -1,6 +1,6 @@
name "Jim_Bridge" name "Jim_Bridge"
author "Jimathy" author "Jimathy"
version "2.0.11" version "2.0.14"
description "Framework Bridge By Jimathy" description "Framework Bridge By Jimathy"
fx_version "cerulean" fx_version "cerulean"
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'

View File

@@ -110,7 +110,7 @@ function onResourceStart(func, thisScript)
AddEventHandler('onResourceStart', function(resourceName) AddEventHandler('onResourceStart', function(resourceName)
if getScript() == resourceName and (thisScript or true) then if getScript() == resourceName and (thisScript or true) then
if waitForSharedLoad() then if waitForSharedLoad() then
print("^6Bridge^7: ^2Shared Load Detected^7.") debugPrint("^6Bridge^7: ^2Shared Load Detected^7.")
if isStarted(ESXExport) then Wait(10000) end if isStarted(ESXExport) then Wait(10000) end
func() func()
end end

View File

@@ -15,7 +15,7 @@ function compareVersions(current, newest)
if c < n then return -1 if c < n then return -1
elseif c > n then return 1 end elseif c > n then return 1 end
end end
return 0 -- equal return 0
end end
function capitalize(str) function capitalize(str)
@@ -33,51 +33,63 @@ function CheckVersion()
if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then
CreateThread(function() CreateThread(function()
Wait(4000) Wait(4000)
local script = getScript() local script = getScript()
local currentVersionRaw = GetResourceMetadata(script, 'version') local currentVersionRaw = GetResourceMetadata(script, 'version')
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers) PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers)
if not newestVersionRaw then if not newestVersionRaw then
-- fallback
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers) PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers)
if not fallbackVersionRaw then if not fallbackVersionRaw then
print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)") print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)")
return return
end end
fallbackVersionRaw = fallbackVersionRaw:match("[^\r\n]+"):gsub("v", "") local lines = {}
for line in fallbackVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
local fallbackVersion = (lines[1] or "0.0.0"):gsub("v", "")
local changelog = {}
for i = 2, #lines do table.insert(changelog, lines[i]) end
local compareResult = compareVersions(currentVersionRaw, fallbackVersionRaw) local compareResult = compareVersions(currentVersionRaw, fallbackVersion)
if compareResult == 0 then if compareResult == 0 then
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersion.."^7)")
if #changelog > 0 then
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() SetTimeout(1200000, function() CheckVersion() end)
-- Do a naughty repeat message every 20 minutes until the the script is updated
CheckVersion()
end)
else else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersion.."^7)")
end end
end) end)
else else
newestVersionRaw = newestVersionRaw:match("[^\r\n]+"):gsub("v", "") local lines = {}
for line in newestVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
local newestVersion = (lines[1] or "0.0.0"):gsub("v", "")
local changelog = {}
for i = 2, #lines do table.insert(changelog, lines[i]) end
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw) local compareResult = compareVersions(currentVersionRaw, newestVersion)
if compareResult == 0 then if compareResult == 0 then
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersion.."^7)")
if #changelog > 0 then
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() SetTimeout(1200000, function() CheckVersion() end)
-- Do a naughty repeat message every 20 minutes until the the script is updated
CheckVersion()
end)
else else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)")
end end
end end
end) end)

View File

@@ -73,6 +73,29 @@ local itemResource, jobResource, vehResource = "", "", ""
if isStarted(OXInv) then if isStarted(OXInv) then
itemResource = OXInv itemResource = OXInv
Items = exports[OXInv]:Items() Items = exports[OXInv]:Items()
-- Add weapons to Items from QBXCore if available
if isStarted(QBXExport) then
local tempWeapons = exports[QBExport]:GetCoreObject().Shared.Weapons
for k, v in pairs(tempWeapons) do
local tempWeaponInfo = exports[OXInv]:Items(v.name)
local weight = 0
if tempWeaponInfo then
weight = tempWeaponInfo.weight
end
if not Items[v.name] then
Items[v.name] = {
name = v.name,
label = v.label,
type = "weapon",
ammotype = v.ammotype or "AMMO_PISTOL",
weight = weight,
image = v.image or (v.name..".png"),
description = v.label or "",
}
end
end
end
for k, v in pairs(Items) do for k, v in pairs(Items) do
if v.client and v.client.image then if v.client and v.client.image then
Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "") Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "")
@@ -195,10 +218,8 @@ end
if vehResource == nil then if vehResource == nil then
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7") print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7")
else else
CreateThread(function()
while not Vehicles do Wait(1000) end while not Vehicles do Wait(1000) end
debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource) debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource)
end)
end end
------------------------------------------------------------- -------------------------------------------------------------
@@ -211,23 +232,36 @@ if isStarted(QBXExport) then
Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs() Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs()
elseif isStarted(OXCoreExport) then elseif isStarted(OXCoreExport) then
jobResource = OXExport jobResource = OXCoreExport
CreateThread(function() CreateThread(function()
if isServer() then if isServer() then
Jobs = {}
createCallback(getScript()..":getOxGroups", function(source) createCallback(getScript()..":getOxGroups", function(source)
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`')
return Jobs return Jobs
end) end)
else local tempJobs = MySQL.query.await('SELECT * FROM `ox_groups`')
local TempJobs = triggerCallback(getScript()..":getOxGroups") local tempGrades = MySQL.query.await('SELECT * FROM `ox_group_grades`')
Jobs = {} -- Index all grades by group
for k, v in pairs(TempJobs) do local gradeMap = {}
local grades = {} for _, grade in pairs(tempGrades) do
--for i = 1, #v.grades do gradeMap[grade.group] = gradeMap[grade.group] or {}
-- grades[i] = { name = v.grades[i], isboss = (i == #v.grades) } gradeMap[grade.group][grade.grade] = {
--end name = grade.label
Jobs[v.name] = { label = v.label, grades = grades } }
end end
-- Process jobs and attach grades
for _, job in pairs(tempJobs) do
Jobs[job.name] = {
label = job.label,
grades = gradeMap[job.name] or {}
}
end
-- Copy to Gangs
Gangs = Jobs
else
Jobs = triggerCallback(getScript()..":getOxGroups")
Gangs = Jobs Gangs = Jobs
end end
end) end)
@@ -252,15 +286,37 @@ elseif isStarted(ESXExport) then
end) end)
-- Populate jobs table with ESX.GetJobs() -- Populate jobs table with ESX.GetJobs()
Jobs = ESX.GetJobs() Jobs = ESX.GetJobs()
--jsonPrint(Jobs)
--If retreived jobs is empty, wait for ESX to load --If retreived jobs is empty, wait for ESX to load
while countTable(Jobs) == 0 do while countTable(Jobs) == 0 do
Jobs = ESX.GetJobs() Jobs = ESX.GetJobs()
Wait(100) Wait(100)
end end
-- Organise into a table the script can use -- Organise into a table the script can use
for k, v in pairs(Jobs) do for Role, Grades in pairs(Jobs) do
local count = countTable(Jobs[k].grades) - 1
Jobs[k].grades[tostring(count)].isBoss = true -- Check for "Boss" in name of grades
for grade, info in pairs(Grades.grades) do
--print(grade)
--jsonPrint(info)
if info.label then
--print(info)
if info.label:find("boss") or info.label:find("Boss") then
--print("Found Boss label for:", Grades.label)
Jobs[Role].grades[grade].isBoss = true
goto continue
end
end
end
-- If no roles with "boss" in the name, revert to max grade
-- Count grades
local count = countTable(Grades.grades)
Jobs[Role].grades[tostring(count-1)].isBoss = true
--print(Grades.label.." Grade: "..count.." is Boss")
::continue::
end end
-- ESX Default doesn't have gangs, so copy jobs to gangs -- ESX Default doesn't have gangs, so copy jobs to gangs
Gangs = Jobs Gangs = Jobs
@@ -282,7 +338,7 @@ elseif isStarted(RSGExport) then
end end
if jobResource == nil then if jobResource == nil then
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7") print("^4ERROR^7: ^2No Job info detected ^7- ^2Check ^3starter^1.^2lua^7")
else else
while not Jobs do Wait(1000) end while not Jobs do Wait(1000) end
debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource) debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource)

View File

@@ -550,6 +550,24 @@ end
RegisterNetEvent(getScript()..":server:sendlog", sendServerLog) RegisterNetEvent(getScript()..":server:sendlog", sendServerLog)
-- This function was created to help create random numbers
-- When you create a table of items with a random hunger value for example
-- `hunger = math.random(10, 20)` this will be set at script start and never change
-- using `hunger = {10, 20}` and then calling this function will make it generate a random number every time
-- It also fallsback if it simply recieved a number instead of a table
-- For example:
-- local hunger = {10, 20}
-- local hungerAmount = GetRandomTiming(hunger)
-- print(hungerAmount) -- number between 10, 20
function GetRandomTiming(tbl)
if type(tbl) == "table" then
return math.random(tbl[1], tbl[2])
else
return tbl
end
end
------------------------------------------------------------- -------------------------------------------------------------
-- Material and Prop Functions -- Material and Prop Functions
------------------------------------------------------------- -------------------------------------------------------------

View File

@@ -640,7 +640,7 @@ function canCarry(itemTable, src)
end end
for k, v in pairs(itemTable) do for k, v in pairs(itemTable) do
local itemInfo = Items[k] local itemInfo = Items[k]
if not itemInfo and not Player.Offline then if not itemInfo then
resultTable[k] = true resultTable[k] = true
else else
resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight
@@ -657,7 +657,7 @@ function canCarry(itemTable, src)
end end
for k, v in pairs(itemTable) do for k, v in pairs(itemTable) do
local itemInfo = Items[k] local itemInfo = Items[k]
if not itemInfo and not Player.Offline then if not itemInfo then
resultTable[k] = true resultTable[k] = true
else else
resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight

View File

@@ -46,7 +46,7 @@ function makeBossRoles(role)
local data = (Jobs and Jobs[role]) or (Gangs and Gangs[role]) local data = (Jobs and Jobs[role]) or (Gangs and Gangs[role])
if data then if data then
for grade, info in pairs(data.grades) do for grade, info in pairs(data.grades) do
if info.isboss or info.bankAuth then if info.isboss or info.bankAuth or info.isBoss then
boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade) boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade)
end end
end end

View File

@@ -54,7 +54,7 @@ function makeBlip(data)
AddTextComponentString(tostring(data.name)) AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
-- Handle preview image if certain resources are running -- Handle preview image if certain resources are running
if isStarted("fs_smallresources") or isStarted("blip_info") or isStarted("blipinfo") then if isStarted("jim-blipcontroller") then
if data.preview then if data.preview then
local txname = string.gsub(tostring(data.name..'preview'..string.gsub(data.coords.z, "%.", "")), "[ ()~]", "") local txname = string.gsub(tostring(data.name..'preview'..string.gsub(data.coords.z, "%.", "")), "[ ()~]", "")
if data.preview:find("http") or data.preview:find("nui") then if data.preview:find("http") or data.preview:find("nui") then
@@ -62,8 +62,11 @@ function makeBlip(data)
else else
CreateRuntimeTextureFromImage(scriptTxd, txname, data.preview) CreateRuntimeTextureFromImage(scriptTxd, txname, data.preview)
end end
exports["fs_smallresources"]:SetBlipInfoImage(blip, getScript()..'scriptTxd', txname) exports["jim-blipcontroller"]:ShowBlipInfo(blip, {
exports["fs_smallresources"]:SetBlipInfoTitle(blip, data.name, false) title = data.name,
dict = getScript()..'scriptTxd',
tex = txname,
})
end end
end end
end end

View File

@@ -539,6 +539,7 @@ function getPlayer(source)
local src = tonumber(source) local src = tonumber(source)
if isStarted(ESXExport) then if isStarted(ESXExport) then
local info = ESX.GetPlayerFromId(src) local info = ESX.GetPlayerFromId(src)
if not info then return {} end
Player = { Player = {
name = info.getName(), name = info.getName(),
cash = info.getMoney(), cash = info.getMoney(),
@@ -563,6 +564,7 @@ function getPlayer(source)
local chunk = assert(load(import, ('@@ox_core/%s'):format(file))) local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
chunk() chunk()
local player = Ox.GetPlayer(src) local player = Ox.GetPlayer(src)
if not player then return {} end
Player = { Player = {
firstname = player.firstName, firstname = player.firstName,
lastname = player.lastName, lastname = player.lastName,
@@ -577,10 +579,11 @@ function getPlayer(source)
--onDuty = info.job.onduty, --onDuty = info.job.onduty,
--account = info.charinfo.account, --account = info.charinfo.account,
citizenId = player.stateId, citizenId = player.stateId,
} }
elseif isStarted(QBXExport) then elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayer(src) local info = exports[QBXExport]:GetPlayer(src)
if not info then return {} end
Player = { Player = {
firstname = info.PlayerData.charinfo.firstname, firstname = info.PlayerData.charinfo.firstname,
lastname = info.PlayerData.charinfo.lastname, lastname = info.PlayerData.charinfo.lastname,
@@ -601,9 +604,11 @@ function getPlayer(source)
isDown = info.PlayerData.metadata["inlaststand"], isDown = info.PlayerData.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
elseif isStarted(QBExport) and not isStarted(QBXExport) then elseif isStarted(QBExport) and not isStarted(QBXExport) then
if Core.Functions.GetPlayer then if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData local info = Core.Functions.GetPlayer(src).PlayerData
if not info then return {} end
Player = { Player = {
firstname = info.charinfo.firstname, firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname, lastname = info.charinfo.lastname,
@@ -625,9 +630,11 @@ function getPlayer(source)
charInfo = info.charinfo, charInfo = info.charinfo,
} }
end end
elseif isStarted(RSGExport) then elseif isStarted(RSGExport) then
if Core.Functions.GetPlayer then if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData local info = Core.Functions.GetPlayer(src).PlayerData
if not info then return {} end
Player = { Player = {
firstname = info.charinfo.firstname, firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname, lastname = info.charinfo.lastname,
@@ -648,6 +655,7 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
end end
else else
print("^4ERROR^7: ^2No Core detected for getPlayer() - Check starter.lua") print("^4ERROR^7: ^2No Core detected for getPlayer() - Check starter.lua")
@@ -656,6 +664,8 @@ function getPlayer(source)
-- Client-side: Get current player info. -- Client-side: Get current player info.
if isStarted(ESXExport) and ESX ~= nil then if isStarted(ESXExport) and ESX ~= nil then
local info = ESX.GetPlayerData() local info = ESX.GetPlayerData()
if not info.firstName then return {} end
local cash, bank = 0, 0 local cash, bank = 0, 0
for k, v in pairs(info.accounts) do for k, v in pairs(info.accounts) do
if v.name == "money" then cash = v.money end if v.name == "money" then cash = v.money end
@@ -678,7 +688,9 @@ function getPlayer(source)
isDead = IsEntityDead(PlayerPedId()), isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true) isDown = IsPedDeadOrDying(PlayerPedId(), true)
} }
elseif isStarted(OXCoreExport) then elseif isStarted(OXCoreExport) then
if not OxPlayer.userId then return {} end
Player = { Player = {
firstname = OxPlayer.get("firstName"), firstname = OxPlayer.get("firstName"),
lastname = OxPlayer.get("lastName"), lastname = OxPlayer.get("lastName"),
@@ -696,8 +708,10 @@ function getPlayer(source)
isDead = IsEntityDead(PlayerPedId()), isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true) isDown = IsPedDeadOrDying(PlayerPedId(), true)
} }
elseif isStarted(QBXExport) then elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayerData() local info = exports[QBXExport]:GetPlayerData()
if not info.charinfo then return {} end
Player = { Player = {
firstname = info.charinfo.firstname, firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname, lastname = info.charinfo.lastname,
@@ -718,9 +732,12 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
elseif isStarted(QBExport) and not isStarted(QBXExport) then elseif isStarted(QBExport) and not isStarted(QBXExport) then
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
Player = { Player = {
firstname = info.charinfo.firstname, firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname, lastname = info.charinfo.lastname,
@@ -741,9 +758,12 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
elseif isStarted(RSGExport) then elseif isStarted(RSGExport) then
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
Player = { Player = {
firstname = info.charinfo.firstname, firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname, lastname = info.charinfo.lastname,
@@ -764,6 +784,7 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"], isDown = info.metadata["inlaststand"],
charInfo = info.charinfo, charInfo = info.charinfo,
} }
else else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3starter^1.^2lua^7") print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3starter^1.^2lua^7")
end end

View File

@@ -35,7 +35,8 @@ function sellMenu(data)
isMenuHeader = not hasTable[k].hasItem, isMenuHeader = not hasTable[k].hasItem,
icon = invImg(k), icon = invImg(k),
header = Items[k].label..(hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""), header = Items[k].label..(hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""),
txt = Loc[Config.Lan].info["sell_all"]..v.." "..Loc[Config.Lan].info["sell_each"], txt = (Loc and Loc[Config.Lan]) and Loc[Config.Lan].info["sell_all"]..v.." "..Loc[Config.Lan].info["sell_each"]
or "Sell ALL at $"..v.." each",
onSelect = function() onSelect = function()
sellAnim({ item = k, price = v, ped = data.ped, onBack = function() sellMenu(data) end }) sellAnim({ item = k, price = v, ped = data.ped, onBack = function() sellMenu(data) end })
end, end,

View File

@@ -8,6 +8,7 @@
• Renewed-Banking • Renewed-Banking
• fd_banking • fd_banking
• okokBanking • okokBanking
• Tgiann-bank
]] ]]
--- Retrieves the current balance of a society's bank account. --- Retrieves the current balance of a society's bank account.
@@ -54,6 +55,14 @@ function getSocietyAccount(society)
elseif isStarted("okokBanking") then elseif isStarted("okokBanking") then
bankScript = "okokBanking" bankScript = "okokBanking"
amount = exports['okokBanking']:GetAccount(society) amount = exports['okokBanking']:GetAccount(society)
elseif isStarted("tgiann-bank") then
bankScript = "tgiann-bank"
if Jobs[society] then
amount = exports["tgiann-bank"]:GetJobAccountBalance(society)
else
amount = exports["tgiann-bank"]:GetGangAccountBalance(society)
end
end end
if bankScript == "" then if bankScript == "" then
@@ -104,6 +113,13 @@ function chargeSociety(society, amount)
bankScript = "okokBanking" bankScript = "okokBanking"
exports['okokBanking']:RemoveMoney(society, amount) exports['okokBanking']:RemoveMoney(society, amount)
elseif isStarted("tgiann-bank") then
bankScript = "tgiann-bank"
if Jobs[society] then
exports["tgiann-bank"]:RemoveJobMoney(society, amount)
else
exports["tgiann-bank"]:RemoveGangMoney(society, amount)
end
end end
if bankScript == "" then if bankScript == "" then
@@ -122,7 +138,7 @@ end
--- fundSociety("police", 500) --- fundSociety("police", 500)
--- ``` --- ```
function fundSociety(society, amount) function fundSociety(society, amount)
local bankScript, newAmount = "", 0 local bankScript, newAmount, success = "", 0, false
if isStarted("qb-banking") then if isStarted("qb-banking") then
@@ -159,6 +175,13 @@ function fundSociety(society, amount)
bankScript = "okokBanking" bankScript = "okokBanking"
exports['okokBanking']:AddMoney(society, amount) exports['okokBanking']:AddMoney(society, amount)
elseif isStarted("tgiann-bank") then
bankScript = "tgiann-bank"
if Jobs[society] then
exports["tgiann-bank"]:AddJobMoney(society, amount)
else
exports["tgiann-bank"]:AddGangMoney(society, amount)
end
end end
if bankScript == "" then if bankScript == "" then

View File

@@ -161,7 +161,10 @@ function openStash(data)
}) })
else else
TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, {
slots = data.slots or 50,
maxWeight = data.maxWeight or 600000
})
end end
elseif isStarted(PSInv) then elseif isStarted(PSInv) then
@@ -174,7 +177,10 @@ function openStash(data)
}) })
else else
TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, {
slots = data.slots or 50,
maxWeight = data.maxWeight or 600000
})
end end
elseif isStarted(RSGInv) then elseif isStarted(RSGInv) then
@@ -188,7 +194,10 @@ function openStash(data)
else else
--Fallback to these commands --Fallback to these commands
TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, {
slots = data.slots or 50,
maxWeight = data.maxWeight or 600000
})
end end
lookEnt(data.coords) lookEnt(data.coords)
@@ -393,6 +402,9 @@ function stashRemoveItem(stashItems, stashName, items)
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v) debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v)
end end
else else
if not stashItems or not next(stashItems) then
stashItems = getStash(stashName[1])
end
for k, v in pairs(items) do for k, v in pairs(items) do
for l in pairs(stashItems) do for l in pairs(stashItems) do
if stashItems[l].name == k then if stashItems[l].name == k then
@@ -414,6 +426,9 @@ function stashRemoveItem(stashItems, stashName, items)
end end
elseif isStarted(PSInv) then elseif isStarted(PSInv) then
if not stashItems or not next(stashItems) then
stashItems = getStash(stashName[1])
end
for k, v in pairs(items) do for k, v in pairs(items) do
for l in pairs(stashItems) do for l in pairs(stashItems) do
if stashItems[l].name == k then if stashItems[l].name == k then
@@ -520,9 +535,9 @@ function registerStash(name, label, slots, weight, owner, coords)
debugPrint("^6Bridge^7: ^2Registering ^3OX ^2Stash^7:", name, label, owner or nil) debugPrint("^6Bridge^7: ^2Registering ^3OX ^2Stash^7:", name, label, owner or nil)
exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000, owner or nil) exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000, owner or nil)
elseif isStarted(QSInv) then --elseif isStarted(QSInv) then
debugPrint("^6Bridge^7: ^2Registering ^3QS ^2Stash^7:", name, label) -- debugPrint("^6Bridge^7: ^2Registering ^3QS ^2Stash^7:", name, label)
exports[QSInv]:RegisterStash(name, label, slots or 50, weight or 4000000) -- exports[QSInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
--elseif isStarted(CoreInv) then --elseif isStarted(CoreInv) then
-- debugPrint("^6Bridge^7: ^2Registering ^3CoreInv ^2Stash^7:", name, label) -- debugPrint("^6Bridge^7: ^2Registering ^3CoreInv ^2Stash^7:", name, label)
@@ -578,6 +593,5 @@ RegisterNetEvent(getScript()..":openGrabBox", function(data)
end end
openStash({ openStash({
stash = id, stash = id,
coords = GetEntityCoords(PlayerPedId())
}) })
end) end)

View File

@@ -81,17 +81,24 @@ for Type, ScriptTable in pairs(filesToLoad) do
local state = GetResourceState(scriptName) local state = GetResourceState(scriptName)
-- if the resource is started, load the file -- if the resource is started, load the file
if state == "started" then if state == "started" then
if scriptName == Exports.OXLibExport and GetResourceState(Exports.OXCoreExport):find("start") then
if debugMode then print("OX_Core found, skipping OX_Lib loading") end
goto skip
end
-- Force items into a table if they are not -- Force items into a table if they are not
if type(files) == "string" then if type(files) == "string" then
files = { files } files = { files }
end end
for _, file in pairs(files) do for _, file in pairs(files) do
--print("^5CoreLoader^7: '"..k.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...") --print("^5CoreLoader^7: '"..scriptName.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...")
local fileLoader = assert(load(LoadResourceFile(scriptName, (file)), ('@@'..scriptName..'/'..file))) local fileLoader = assert(load(LoadResourceFile(scriptName, (file)), ('@@'..scriptName..'/'..file)))
fileLoader() fileLoader()
if debugMode then
print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'")
end end
end end
::skip::
end
-- if script is in server, but not started warn the user -- if script is in server, but not started warn the user
if state == "uninitialized" or state == "stopped" then if state == "uninitialized" or state == "stopped" then
@@ -118,7 +125,7 @@ for _, v in pairs({ -- This is a specific load order
'_eventDebug.lua', '_eventDebug.lua',
'callback.lua', 'callback.lua',
'coreloader.lua', -- needs to be second to load all core related stuff before everything else 'coreloader.lua',
'duifunctions.lua', 'duifunctions.lua',

View File

@@ -1 +1,12 @@
2.0.11 2.0.14
- Add getPlayer() fallbacks for if player isn't loaded
- Add fallback for sellMenu missing locales
- Change blip preview export to "jim-blipcontroller"
- Support for tgiann-bank
- Fixes for OX_Core COX version
- Fix QBOX weapons not being added to "Items" cache
- Remove Player.Offline from canCarry() as it was erroring
- Possible fix for QS_Inv stashes wiping on script start
https://github.com/jimathy/jim_bridge