Compare commits

..

5 Commits

Author SHA1 Message Date
Jim Shield
4c89ec3190 Version Bump
`2.0.07` - `2.0.08`
2025-05-10 19:55:51 +01:00
Jim Shield
b2fa1ef247 Update starter.lua
Updated and putting into use the core file loader function in starter.lua
2025-05-10 19:54:31 +01:00
Jim Shield
9872c77591 Only allow script version checks for my scripts
Added a check to version check for if "Jimathy" is the author, this then stops it and doesn't check for the versions on my github repositories
2025-05-10 19:20:47 +01:00
Jim Shield
7ecb2f18e9 Refactor ESX Core loading
I realised I was loading ESX the stupidest way

I think I was loading ESX object, then instantly clearing it and then used workarounds to try and reload it (thinking is hard ok)

It should now load correctly and faster

also I realised my custom `onPlayerLoaded()` function was loading too fast, so I've added a delay to it but removed the while loops for esx checks that could potentially break the script
2025-05-07 23:01:29 +01:00
Jim Shield
d0c09f3e00 switch old ps-inv stash call back to old event
older ps didn't call `ps-inventory` for stash, just `inventory`
2025-05-07 21:12:38 +01:00
7 changed files with 55 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
name "Jim_Bridge"
author "Jimathy"
version "2.0.07"
version "2.0.08"
description "Framework Bridge By Jimathy"
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.'

View File

@@ -40,6 +40,7 @@ function onPlayerLoaded(func, onStart)
if not loaded then
local tempFunc = function()
Wait(2000)
debugPrint("^6Bridge^7: ^2Executing onPlayerLoaded")
func()
end
@@ -138,9 +139,7 @@ function waitForLogin()
local loggedIn = false
if isStarted(ESXExport) then
debugPrint("^6Bridge^7: ^3ESX waitForLogin^7() ^2running^7")
while (GetGameTimer() - startTime) < timeout do
while not ESX do Wait(100) end
local playerData = ESX.GetPlayerData()
if playerData and playerData.job then
loggedIn = true

View File

@@ -30,7 +30,7 @@ local scriptAuthor = ("^2by ^4"..GetResourceMetadata(getScript(), 'author', nil)
print(scriptName.." ^7v"..scriptVersion.."^7 - "..scriptDescription.." "..scriptAuthor.."^7")
function CheckVersion()
if isServer() then
if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then
CreateThread(function()
Wait(4000)

View File

@@ -9,7 +9,7 @@
-------------------------------------------------------------
-- Global Variable Initialization
-------------------------------------------------------------
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
Items, Vehicles, Jobs, Gangs, Core = {}, nil, nil, nil, nil
-------------------------------------------------------------
-- Correct QB Inventory Export
@@ -96,13 +96,7 @@ elseif isStarted(QBExport) then
elseif isStarted(ESXExport) then
itemResource = ESXExport
ESX = exports[ESXExport]:getSharedObject()
while ESX == nil do
print("Waiting for ESX")
Wait(0)
end
CreateThread(function()
while not ESX do Wait(0) end
if isServer() then
Items = ESX.GetItems()
while not createCallback do Wait(100) end
@@ -140,6 +134,7 @@ end
-------------------------------------------------------------
-- Compile vehicles from the detected frameworks into a unified table.
if isStarted(QBXExport) or isStarted(QBExport) then
vehResource = QBExport
Core = Core or exports[QBExport]:GetCoreObject()
Vehicles = Core and Core.Shared.Vehicles
if isStarted(QBExport) and not isStarted(QBXExport) then
@@ -148,26 +143,23 @@ if isStarted(QBXExport) or isStarted(QBExport) then
Vehicles = Core and Core.Shared.Vehicles
end)
end
vehResource = QBExport
elseif isStarted(OXCoreExport) then
vehResource = OXCoreExport
Vehicles = {}
for k, v in pairs(Ox.GetVehicleData()) do
Vehicles[k] = { model = k, hash = GetHashKey(k), price = v.price, name = v.name, brand = v.make }
end
vehResource = OXCoreExport
elseif isStarted(ESXExport) then
vehResource = ESXExport
CreateThread(function()
if isServer() then
vehResource = ESXExport
createCallback(getScript()..":getVehiclesPrices", function(source)
return Vehicles
end)
while not MySQL do Wait(2000) print("^1Waiting for MySQL to exist") end
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
--jsonPrint(Vehicles)
--while not createCallback do print("waiting") Wait(100) end
end
if not isServer() then
--while not triggerCallback do print("waiting") Wait(100) end
@@ -186,19 +178,19 @@ elseif isStarted(ESXExport) then
end)
elseif isStarted(RSGExport) then
vehResource = RSGExport
Core = Core or exports[RSGExport]:GetCoreObject()
Vehicles = Core and Core.Shared.Vehicles
RegisterNetEvent('RSGCore:Client:UpdateObject', function()
Core = Core or exports[RSGExport]:GetCoreObject()
Vehicles = Core and Core.Shared.Vehicles
end)
vehResource = RSGExport
end
if vehResource == nil then
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7")
else
CreateThread(function()
while not Vehicles do Wait(1000) print("Waiting") end
while not Vehicles do Wait(1000) end
debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource)
end)
end
@@ -246,7 +238,7 @@ elseif isStarted(QBExport) then
end
elseif isStarted(ESXExport) then
ESX = exports[ESXExport]:getSharedObject()
jobResource = ESXExport
if isServer() then
Jobs = ESX.GetJobs()
for k, v in pairs(Jobs) do
@@ -256,7 +248,6 @@ elseif isStarted(ESXExport) then
Gangs = Jobs
end
CreateThread(function()
while not ESX do Wait(0) end
if isServer() then
createCallback(getScript()..":getJobs", function(source)
return Jobs

View File

@@ -174,7 +174,7 @@ function openStash(data)
})
else
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("ps-inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
end
elseif isStarted(RSGInv) then

View File

@@ -57,78 +57,58 @@ if Config and Config.System then
end
end
-- Testing loading the core files here instead of in fxmanifests
-- Load the core files here instead of in fxmanifests
-- Forcefully loads the files and quietly, compared to fxmanifest complaining if they don't exist when you don't need them all
--[[
-- Shared framework file loader
for k, v in pairs({ -- This is a specific load order
[Exports.OXLibExport] = "init.lua",
[Exports.OXCoreExport] = "lib/init.lua",
[Exports.ESXExport] = "imports.lua",
[Exports.QBXExport] = "modules/playerdata.lua",
}) do
local state = GetResourceState(k)
-- if the resource is started, load the file
if state == "started" then
if type(v) == "string" then
v = { v }
end
for _, file in pairs(v) do
--print("^5CoreLoader^7: '"..k.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...")
local fileLoader = assert(load(LoadResourceFile(k, (file)), ('@@'..k..'/'..file)))
fileLoader()
print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..k.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").."^7")
end
end
-- if script is in server, but not started warn the user
if state == "uninitialized" or state == "stopped" then
print("^5CoreLoader^7: ^3"..k.." ^1 found but it wasn't started^7. ^1Check your ^3server^7.^3cfg ^1load order^7")
end
-- debugging only, if the script is missing, warn the user
if state == "missing" then
if debugMode then
print("^5CoreLoader^7: ^3"..k.." ^2not found^7, ^2skipping")
end
end
end
-- Client only file loader
if not IsDuplicityVersion() then
for k, v in pairs({ -- This is a specific load order
local filesToLoad = {
Shared = {
[Exports.OXLibExport] = { "init.lua" },
[Exports.OXCoreExport] = { "lib/init.lua" },
[Exports.ESXExport] = { "imports.lua" },
[Exports.QBXExport] = { "modules/playerdata.lua" },
},
Client = {
["PolyZone"] = { "client.lua", "BoxZone.lua", "EntityZone.lua", "CircleZone.lua", "ComboZone.lua" },
["warmenu"] = { "warmenu.lua", },
}) do
local state = GetResourceState(k)
-- if the resource is started, load the file
if state == "started" then
if type(v) == "string" then
v = { v }
end
for _, file in pairs(v) do
--print("^5CoreLoader^7: '"..k.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...")
local fileLoader = assert(load(LoadResourceFile(k, (file)), ('@@'..k..'/'..file)))
fileLoader()
print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..k.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").."^7")
end
end
},
}
-- if script is in server, but not started warn the user
if state == "uninitialized" or state == "stopped" then
print("^5CoreLoader^7: ^3"..k.." ^1 found but it wasn't started^7. ^1Check your ^3server^7.^3cfg ^1load order^7")
end
-- Shared framework file loader
for Type, ScriptTable in pairs(filesToLoad) do
if Type == "Client" and IsDuplicityVersion() then
goto continue
else
for scriptName, files in pairs(ScriptTable) do
local state = GetResourceState(scriptName)
-- if the resource is started, load the file
if state == "started" then
-- Force items into a table if they are not
if type(files) == "string" then
files = { files }
end
for _, file in pairs(files) do
--print("^5CoreLoader^7: '"..k.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...")
local fileLoader = assert(load(LoadResourceFile(scriptName, (file)), ('@@'..scriptName..'/'..file)))
fileLoader()
print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'")
end
end
-- debugging only, if the script is missing, warn the user
if state == "missing" then
if debugMode then
print("^3Warning^7: ^3"..k.." ^2not found^7, ^2skipping")
-- if script is in server, but not started warn the user
if state == "uninitialized" or state == "stopped" then
print("^5CoreLoader^7: ^3"..scriptName.." ^1 found but it wasn't started^7.")
print("^1Check your ^3server^7.^3cfg ^1load order^7")
end
-- debugging only, if the script is missing, warn the user
if state == "missing" then
if debugMode then
print("^5CoreLoader^7: ^3"..scriptName.." ^2not found^7, ^2skipping")
end
end
end
end
::continue::
end
]]
-- Load files here into the invoking script
for _, v in pairs({ -- This is a specific load order

View File

@@ -1 +1 @@
2.0.07
2.0.08