2025-01-09 00:11:53 +02:00
|
|
|
Bridge = {}
|
2025-01-08 06:33:31 -05:00
|
|
|
|
2025-01-09 00:11:53 +02:00
|
|
|
local function registerModule(moduleName, moduleTable)
|
|
|
|
|
local wrappedModule = {}
|
|
|
|
|
for functionName, func in pairs(moduleTable) do
|
|
|
|
|
wrappedModule[functionName] = func
|
2025-01-08 06:33:31 -05:00
|
|
|
end
|
2025-01-09 00:11:53 +02:00
|
|
|
print("Registering module:", moduleName)
|
|
|
|
|
Bridge[moduleName] = wrappedModule
|
2025-01-08 06:33:31 -05:00
|
|
|
end
|
|
|
|
|
|
2025-01-09 10:57:51 +02:00
|
|
|
function Bridge.RegisterModule(moduleName, moduleTable, useFrameworkFunctions)
|
2025-01-09 00:11:53 +02:00
|
|
|
if not moduleTable then
|
|
|
|
|
moduleTable = Framework
|
|
|
|
|
registerModule(moduleName, moduleTable)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if Bridge[moduleName] then
|
|
|
|
|
print("Module already registered:", moduleName)
|
|
|
|
|
return
|
2025-01-08 06:33:31 -05:00
|
|
|
end
|
2025-01-09 10:57:51 +02:00
|
|
|
if useFrameworkFunctions and Framework then
|
|
|
|
|
for functionName, func in pairs(Framework) do
|
|
|
|
|
if not moduleTable[functionName] then
|
|
|
|
|
moduleTable[functionName] = func
|
|
|
|
|
print(string.format("Added function '%s' from Framework to module '%s'", functionName, moduleName))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-01-09 00:11:53 +02:00
|
|
|
registerModule(moduleName, moduleTable)
|
2025-01-08 06:33:31 -05:00
|
|
|
end
|
2025-01-09 00:11:53 +02:00
|
|
|
--TODO: Create a way to overide functions or create a new functions for module
|
|
|
|
|
-- local OverRide = function(module, key, value)
|
|
|
|
|
-- module[key] = value
|
|
|
|
|
-- end
|
2025-01-08 06:33:31 -05:00
|
|
|
|
2025-01-09 00:11:53 +02:00
|
|
|
-- RegisterCompatibility = function(moduleName, key, func)
|
|
|
|
|
-- local module = Bridge[moduleName] or {}
|
|
|
|
|
|
|
|
|
|
-- if not module[key] then
|
|
|
|
|
-- module[key] = func
|
|
|
|
|
-- print("Registered function for:", moduleName, key)
|
|
|
|
|
-- else
|
|
|
|
|
-- print("Key already exists for:", moduleName, key)
|
|
|
|
|
-- end
|
|
|
|
|
-- Bridge[moduleName] = module
|
|
|
|
|
-- Bridge[moduleName].OverRide = function(k, v)
|
|
|
|
|
-- OverRide(module, k, v)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- exports('RegisterCompatibility', RegisterCompatibility)
|
2025-01-08 10:49:21 -05:00
|
|
|
|
2025-01-09 00:11:53 +02:00
|
|
|
Bridge.RegisterModule("Framework", Framework)
|
2025-01-09 10:57:51 +02:00
|
|
|
Bridge.RegisterModule("Inventory", Inventory, true)
|
2025-01-09 00:11:53 +02:00
|
|
|
Bridge.RegisterModule("Notify", Notify)
|
|
|
|
|
Bridge.RegisterModule("Utility", Utility)
|
|
|
|
|
Bridge.RegisterModule("Progressbar", Progressbar)
|
|
|
|
|
Bridge.RegisterModule("Clothing", Clothing)
|
|
|
|
|
Bridge.RegisterModule("Menu", Menu)
|
|
|
|
|
Bridge.RegisterModule("Language", Language)
|
|
|
|
|
Bridge.RegisterModule("Debugger", Debugger)
|
|
|
|
|
Bridge.RegisterModule("Doorlock", Doorlock)
|
|
|
|
|
Bridge.RegisterModule("Phone", Phone)
|
|
|
|
|
Bridge.RegisterModule("Vehicle", Vehicle)
|
|
|
|
|
Bridge.RegisterModule("Dispatch", Dispatch)
|
|
|
|
|
Bridge.RegisterModule("Weather", Weather)
|
|
|
|
|
Bridge.RegisterModule("Target", Target)
|
|
|
|
|
Bridge.RegisterModule("Table", Table)
|
|
|
|
|
Bridge.RegisterModule("Math", Math)
|
|
|
|
|
Bridge.RegisterModule("Prints", Prints)
|
2025-01-08 10:49:21 -05:00
|
|
|
|
2025-01-09 00:11:53 +02:00
|
|
|
-- Fill the bridge tables with player data.
|
2025-01-08 10:49:21 -05:00
|
|
|
function FillBridgeTables()
|
|
|
|
|
PlayerLoaded = true
|
|
|
|
|
PlayerIdentifier = Framework.GetPlayerIdentifier()
|
|
|
|
|
PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Clean the bridge tables.
|
|
|
|
|
function ClearClientSideVariables()
|
|
|
|
|
PlayerLoaded = false
|
|
|
|
|
PlayerIdentifier = nil
|
|
|
|
|
PlayerJobName = nil
|
|
|
|
|
PlayerJobLabel = nil
|
|
|
|
|
PlayerJobGradeName = nil
|
|
|
|
|
PlayerJobGradeLevel = nil
|
|
|
|
|
StoredOldClothing = {}
|
2025-01-09 00:11:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
CreateThread(function()
|
|
|
|
|
for k, v in pairs(Bridge) do
|
|
|
|
|
if type(v) == 'table' then
|
|
|
|
|
exports(k, function()
|
|
|
|
|
return v
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
exports(k, v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
exports('Bridge', function()
|
|
|
|
|
return Bridge
|
|
|
|
|
end)
|