mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Increase timer again on cache timeout
Also moved around the cache timers to be a bit more accurate (timers start when the cache creation is triggered)
This commit is contained in:
@@ -49,17 +49,19 @@ end
|
|||||||
|
|
||||||
local function endTimer(label)
|
local function endTimer(label)
|
||||||
timers[label] = GetGameTimer() - (timers[label] or GetGameTimer())
|
timers[label] = GetGameTimer() - (timers[label] or GetGameTimer())
|
||||||
timers[label] = timers[label] / 1000
|
timers[label] = "("..(timers[label] / 1000).."s)"
|
||||||
end
|
end
|
||||||
startTimer("Cache")
|
startTimer("Cache") startTimer("Items") startTimer("Vehicles") startTimer("Jobs") startTimer("InvWeight") startTimer("InvSlots")
|
||||||
-- Helper function to check if resource exists in server (instead of if it is already started)
|
-- Helper function to check if resource exists in server (instead of if it is already started)
|
||||||
local function checkExists(resourceName)
|
local function checkExists(resourceName)
|
||||||
return GetResourceState(resourceName):find("start") or GetResourceState(resourceName):find("stopped")
|
return GetResourceState(resourceName):find("start") or GetResourceState(resourceName):find("stopped")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure oxmysql resource is loaded
|
-- Ensure oxmysql resource is loaded
|
||||||
|
if checkExists(Exports.OXCoreExport) or checkExists(Exports.OXCoreExport) then
|
||||||
local fileLoader = assert(load(LoadResourceFile("oxmysql", ('lib/MySQL.lua')), ('@@oxmysql/lib/MySQL.lua')))
|
local fileLoader = assert(load(LoadResourceFile("oxmysql", ('lib/MySQL.lua')), ('@@oxmysql/lib/MySQL.lua')))
|
||||||
fileLoader()
|
fileLoader()
|
||||||
|
end
|
||||||
|
|
||||||
if checkExists(Exports.OXCoreExport) then
|
if checkExists(Exports.OXCoreExport) then
|
||||||
-- Detected OX_Core in server, wait for it to be started if needed
|
-- Detected OX_Core in server, wait for it to be started if needed
|
||||||
@@ -88,7 +90,6 @@ end
|
|||||||
---- Load Items -----
|
---- Load Items -----
|
||||||
---------------------
|
---------------------
|
||||||
-- Items initialization based on detected inventory system
|
-- Items initialization based on detected inventory system
|
||||||
startTimer("Items")
|
|
||||||
if checkExists(Exports.OXInv) then
|
if checkExists(Exports.OXInv) then
|
||||||
-- Wait for OX Inventory to start if it's not already started
|
-- Wait for OX Inventory to start if it's not already started
|
||||||
while GetResourceState(Exports.OXInv) ~= "started" do Wait(100) end
|
while GetResourceState(Exports.OXInv) ~= "started" do Wait(100) end
|
||||||
@@ -171,7 +172,6 @@ endTimer("Items")
|
|||||||
---------------------
|
---------------------
|
||||||
--- Load Vehicles ---
|
--- Load Vehicles ---
|
||||||
---------------------
|
---------------------
|
||||||
startTimer("Vehicles")
|
|
||||||
-- Vehicle loading depending on framework
|
-- Vehicle loading depending on framework
|
||||||
if checkExists(Exports.QBXExport) then
|
if checkExists(Exports.QBXExport) then
|
||||||
vehResource = Exports.QBXExport
|
vehResource = Exports.QBXExport
|
||||||
@@ -215,7 +215,6 @@ endTimer("Vehicles")
|
|||||||
---------------------
|
---------------------
|
||||||
----- Load Jobs -----
|
----- Load Jobs -----
|
||||||
---------------------
|
---------------------
|
||||||
startTimer("Jobs")
|
|
||||||
-- Jobs loading based on framework
|
-- Jobs loading based on framework
|
||||||
if checkExists(Exports.QBXExport) then
|
if checkExists(Exports.QBXExport) then
|
||||||
jobResource = Exports.QBXExport
|
jobResource = Exports.QBXExport
|
||||||
@@ -308,8 +307,6 @@ end
|
|||||||
-- Forcefully load the the specified config file from inventory scripts
|
-- Forcefully load the the specified config file from inventory scripts
|
||||||
-- This allows to get information required for certain functions that need to detect how much space is left in a players inventory
|
-- This allows to get information required for certain functions that need to detect how much space is left in a players inventory
|
||||||
-- This is born from too many tickets of me needing to explain that they need to change "InventoryWeight" to match their inv setting
|
-- This is born from too many tickets of me needing to explain that they need to change "InventoryWeight" to match their inv setting
|
||||||
startTimer("InvWeight")
|
|
||||||
startTimer("InvSlots")
|
|
||||||
local function getInventoryConfig(resource, data)
|
local function getInventoryConfig(resource, data)
|
||||||
if data.convars then
|
if data.convars then
|
||||||
return function(path)
|
return function(path)
|
||||||
@@ -419,17 +416,17 @@ CreateThread(function()
|
|||||||
if type(v) ~= "number" then for count in pairs(v) do counts[k] += 1 end end
|
if type(v) ~= "number" then for count in pairs(v) do counts[k] += 1 end end
|
||||||
end
|
end
|
||||||
if cache.InventoryWeight then
|
if cache.InventoryWeight then
|
||||||
print("^6FrameWorkCache^7: ^4"..invResource.."^2 InventoryWeight^7: ^3"..cache.InventoryWeight.."^7 (^3"..(cache.InventoryWeight / 1000).."kg^7) ^7("..timers["InvWeight"].."s)")
|
print("^6FrameWorkCache^7: ^4"..invResource.."^2 InventoryWeight^7: ^3"..cache.InventoryWeight.."^7 (^3"..(cache.InventoryWeight / 1000).."kg^7) ^7"..timers["InvWeight"])
|
||||||
end
|
end
|
||||||
if cache.InventorySlots then
|
if cache.InventorySlots then
|
||||||
print("^6FrameWorkCache^7: ^4"..invResource.."^2 InventorySlots^7: ^3"..cache.InventorySlots.." ^7("..timers["InvSlots"].."s)")
|
print("^6FrameWorkCache^7: ^4"..invResource.."^2 InventorySlots^7: ^3"..cache.InventorySlots.." ^7"..timers["InvSlots"])
|
||||||
end
|
end
|
||||||
print("^6FrameworkCache^7: ^4"..itemResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Items).."^2 Items ^7("..timers["Items"].."s)")
|
print("^6FrameworkCache^7: ^4"..itemResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Items).."^2 Items ^7"..timers["Items"])
|
||||||
print("^6FrameworkCache^7: ^4"..vehResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Vehicles).."^2 Vehicles ^7("..timers["Vehicles"].."s)")
|
print("^6FrameworkCache^7: ^4"..vehResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Vehicles).."^2 Vehicles ^7"..timers["Vehicles"])
|
||||||
print("^6FrameworkCache^7: ^4"..jobResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Jobs).."^2 Jobs ^7("..timers["Jobs"].."s)")
|
print("^6FrameworkCache^7: ^4"..jobResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Jobs).."^2 Jobs ^7"..timers["Jobs"])
|
||||||
print("^6FrameworkCache^7: ^4"..jobResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Gangs).."^2 Gangs ^7("..timers["Jobs"].."s)")
|
print("^6FrameworkCache^7: ^4"..jobResource:gsub("-", "^7-^4"):gsub("_", "^7_^4").."^2 Loaded ^3"..tostring(counts.Gangs).."^2 Gangs ^7"..timers["Jobs"])
|
||||||
endTimer("Cache")
|
endTimer("Cache")
|
||||||
print("^6FrameworkCache^7: ^2Cache Ready ^7("..timers["Cache"].."s)")
|
print("^6FrameworkCache^7: ^2Cache Ready ^7"..timers["Cache"])
|
||||||
cacheReady = true
|
cacheReady = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ end
|
|||||||
|
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
local cache = nil
|
local cache = nil
|
||||||
local timeout = GetGameTimer() + 120000 -- 2 minutes max wait (had to up this from 5 seconds because of slow servers)
|
local timeout = GetGameTimer() + 900000 -- 15 minutes max wait (had to up this from 2 minutes because of slow servers)
|
||||||
|
|
||||||
-- Wait until jim_bridge is started and export is available
|
-- Wait until jim_bridge is started and export is available
|
||||||
while not cache and GetGameTimer() < timeout do
|
while not cache and GetGameTimer() < timeout do
|
||||||
|
|||||||
Reference in New Issue
Block a user