mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 06:46:04 +01:00
Tidy up and make ESX timeout longer
This commit is contained in:
@@ -53,7 +53,7 @@ function craftingMenu(data)
|
|||||||
end
|
end
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
|
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
|
||||||
if data.stashName ~= nil then disable = stashhasItem(stashItems, itemTable) else disable = hasItem(itemTable) end
|
if data.stashName ~= nil then disable = stashhasItem(stashItems, itemTable) else disable = hasItem(itemTable) end
|
||||||
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
setheader = (Items[tostring(k)] and Items[tostring(k)].label or "error - "..tostring(k))..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
||||||
Menu[#Menu + 1] = {
|
Menu[#Menu + 1] = {
|
||||||
isMenuHeader = not disable,
|
isMenuHeader = not disable,
|
||||||
icon = invImg(tostring(k)),
|
icon = invImg(tostring(k)),
|
||||||
@@ -297,7 +297,7 @@ function getStash(stashName) local stashResource = ""
|
|||||||
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
||||||
|
|
||||||
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
||||||
stashItems = exports[OrigenInv]:GetStash(stashName)
|
stashItems = exports[OrigenInv]:GetStashItems(stashName)
|
||||||
|
|
||||||
elseif GetResourceState(QBInv):find("start") then stashResource = QBInv
|
elseif GetResourceState(QBInv):find("start") then stashResource = QBInv
|
||||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
|
|||||||
32
wrapper.lua
32
wrapper.lua
@@ -27,8 +27,7 @@ for k, v in pairs(Exports) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local loadItems = function() local itemResource = ""
|
local loadItems = function() local itemResource = ""
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then itemResource = OXInv
|
||||||
itemResource = OXInv
|
|
||||||
Items = exports[OXInv]:Items()
|
Items = exports[OXInv]:Items()
|
||||||
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
|
||||||
@@ -39,12 +38,10 @@ local loadItems = function() local itemResource = ""
|
|||||||
Items[k].hunger = v.client and v.client.hunger or nil
|
Items[k].hunger = v.client and v.client.hunger or nil
|
||||||
Items[k].thirst = v.client and v.client.thirst or nil
|
Items[k].thirst = v.client and v.client.thirst or nil
|
||||||
end
|
end
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") then itemResource = QBExport
|
||||||
itemResource = QBExport
|
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
Items = Core and Core.Shared.Items or nil
|
Items = Core and Core.Shared.Items or nil
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
elseif GetResourceState(ESXExport):find("start") then itemResource = ESXExport
|
||||||
itemResource = ESXExport
|
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
Items = ESX and ESX.Items or nil
|
Items = ESX and ESX.Items or nil
|
||||||
end
|
end
|
||||||
@@ -85,7 +82,7 @@ local loadVehicles = function() local vehResource = ""
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local timeout = 1000 while not Vehicles and timeout > 0 do timeout -=1 Wait(0) end
|
local timeout = 5000 while not Vehicles and timeout > 0 do timeout -=1 Wait(0) end
|
||||||
if not Vehicles then
|
if not Vehicles then
|
||||||
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
else
|
else
|
||||||
@@ -123,6 +120,8 @@ local loadJobs = function() local jobResource = ""
|
|||||||
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then jobResource = ESXExport
|
elseif GetResourceState(ESXExport):find("start") then jobResource = ESXExport
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
|
CreateThread(function()
|
||||||
|
while not ESX do Wait(0) end
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
Jobs = ESX.GetJobs()
|
Jobs = ESX.GetJobs()
|
||||||
for k, v in pairs(Jobs) do
|
for k, v in pairs(Jobs) do
|
||||||
@@ -130,23 +129,16 @@ local loadJobs = function() local jobResource = ""
|
|||||||
Jobs[k].grades[tostring(count)].isBoss = true
|
Jobs[k].grades[tostring(count)].isBoss = true
|
||||||
end
|
end
|
||||||
Gangs = Jobs
|
Gangs = Jobs
|
||||||
end
|
createCallback(GetCurrentResourceName()..":getJobs", function(source) return Jobs end)
|
||||||
CreateThread(function()
|
|
||||||
while not ESX do Wait(0) end
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getJobs", function(source)
|
|
||||||
return Jobs
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
||||||
Gangs = Jobs
|
Gangs = Jobs
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local timeout = 1000 while not Jobs and timeout > 0 do timeout -=1 Wait(0) end
|
local timeout = 5000 while not Jobs and timeout > 0 do timeout -=1 Wait(0) end
|
||||||
if Jobs then
|
if Jobs then
|
||||||
print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource)
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource, 0"^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource)
|
||||||
print("^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource)
|
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Job/Gang info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Job/Gang info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
@@ -181,11 +173,7 @@ function createPoly(data) local Location = nil
|
|||||||
if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7PolyZone "..data.name) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7PolyZone "..data.name) end
|
||||||
Location = PolyZone:Create(data.points, { name = data.name, debugPoly = data.debug })
|
Location = PolyZone:Create(data.points, { name = data.name, debugPoly = data.debug })
|
||||||
Location:onPlayerInOut(function(isPointInside)
|
Location:onPlayerInOut(function(isPointInside)
|
||||||
if isPointInside then
|
if isPointInside then data.onEnter() else data.onExit() end
|
||||||
data.onEnter()
|
|
||||||
else
|
|
||||||
data.onExit()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
|
|||||||
Reference in New Issue
Block a user