Skip to content

Commit 151eaa5

Browse files
Bugfix - Loading modules
- Fix a bug that caused MSync 2 to load modules on the clientside, despite the module not having loaded on the server ( mainly due to a "Not connected" error )
1 parent 90871fd commit 151eaa5

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

lua/msync/client_gui/cl_net.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ net.Receive( "msync.enableModule", function( len, pl )
125125
local module = net.ReadString()
126126
MSync.log(MSYNC_DBG_DEBUG, "Net: msync.enableModule Return: " .. module)
127127
MSync.enableModule( module )
128+
MSync.moduleState[module] = true
128129
end )
129130

130131
--[[
@@ -135,4 +136,5 @@ net.Receive( "msync.disableModule", function( len, pl )
135136
local module = net.ReadString()
136137
MSync.log(MSYNC_DBG_DEBUG, "Net: msync.disableModule Return: " .. module)
137138
MSync.disableModule( module )
139+
MSync.moduleState[module] = nil
138140
end )

lua/msync/server/sv_hooks.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
MSync = MSync or {}
2+
MSync.mysql = MSync.mysql or {}
3+
MSync.net = MSync.net or {}
4+
MSync.loadedModules = MSync.loadedModules or {}
15
--[[
26
Description: hook to initialize MSync 2
37
Returns: nothing
@@ -27,7 +31,7 @@ end)
2731
]]
2832
hook.Add("PlayerInitialSpawn", "msync.createUser", function( ply )
2933
MSync.mysql.addUser(ply)
30-
MSync.net.sendTable(ply, "modulestate", MSync.settings.data.enabledModules)
34+
MSync.net.sendTable(ply, "modulestate", MSync.loadedModules)
3135

3236
if ply:query("msync.openAdminGUI") then
3337
MSync.net.dbStatus(ply)

lua/msync/server/sv_init.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
MSync = MSync or {}
2-
MSync.net = MSync.net or {}
3-
MSync.mysql = MSync.mysql or {}
4-
MSync.modules = MSync.modules or {}
5-
MSync.settings = MSync.settings or {}
6-
MSync.func = MSync.func or {}
7-
MSync.ulx = MSync.ulx or {}
1+
MSync = MSync or {}
2+
MSync.net = MSync.net or {}
3+
MSync.mysql = MSync.mysql or {}
4+
MSync.modules = MSync.modules or {}
5+
MSync.settings = MSync.settings or {}
6+
MSync.func = MSync.func or {}
7+
MSync.ulx = MSync.ulx or {}
8+
MSync.loadedModules = MSync.loadedModules or {}
89

910
--[[
1011
Description: Function to load the server side files

lua/msync/server/sv_modules.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
MSync = MSync or {}
2-
MSync.mysql = MSync.mysql or {}
3-
MSync.settings = MSync.settings or {}
4-
MSync.modules = MSync.modules or {}
1+
MSync = MSync or {}
2+
MSync.mysql = MSync.mysql or {}
3+
MSync.settings = MSync.settings or {}
4+
MSync.modules = MSync.modules or {}
5+
MSync.loadedModules = MSync.loadedModules or {}
56

67
--[[
78
Description: Loads all server side modules
@@ -36,6 +37,8 @@ function MSync.initModules()
3637
v["net"]()
3738
v["ulx"]()
3839
v["hooks"]()
40+
MSync.loadedModules[v["info"].ModuleIdentifier] = true
41+
MSync.net.sendModuleEnable( v["info"].ModuleIdentifier )
3942
MSync.log(MSYNC_DBG_INFO, "["..v["info"]["Name"].."] Module loaded")
4043
end
4144
end

0 commit comments

Comments
 (0)