Skip to content

Commit 9f1f203

Browse files
Added MSync.DBStatus to client
Added variable to client that indicates if there is a working database connection. This is importent for possible bugs that occur when there was a error with the DB connection. UPDATE: CHEESE_0.2.1
1 parent 4341766 commit 9f1f203

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

msync/client_gui/cl_net.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,12 @@ end )
8787
]]
8888
net.Receive( "msync.openAdminGUI", function( len, pl )
8989
MSync.AdminPanel.InitPanel()
90+
end )
91+
92+
--[[
93+
Description: Net Receiver - Gets called when server sent the db status
94+
Returns: nothing
95+
]]
96+
net.Receive( "msync.dbStatus", function( len, pl )
97+
MSync.DBStatus = net.ReadBool()
9098
end )

msync/client_gui/modules/cl_mrsync.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ function MSync.modules.MRSync.adminPanel(sheet)
128128
end
129129
end
130130

131-
MSync.modules.MRSync.getSettings()
131+
if MSync.DBStatus then
132+
MSync.modules.MRSync.getSettings()
133+
end
132134

133135
if not MSync.modules.MRSync.settings then
134136
timer.Create("mrsync.t.checkSettings", 1, 0, function()
@@ -199,7 +201,6 @@ function MSync.modules.MRSync.net()
199201
Returns: nothing
200202
]]
201203
net.Receive("msync.mrsync.sendSettingsPly", function(len, ply)
202-
203204
MSync.modules.MRSync.settings = net.ReadTable()
204205
end )
205206
end
@@ -215,9 +216,7 @@ end
215216
Define hooks your module is listening on e.g. PlayerDisconnect
216217
]]
217218
function MSync.modules.MRSync.hooks()
218-
hook.Add("initialize", "msync_sampleModule_init", function()
219-
220-
end)
219+
221220
end
222221

223222
--[[

msync/server/sv_hooks.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ end)
2828
hook.Add("PlayerInitialSpawn", "msync.createUser", function( ply )
2929
MSync.mysql.addUser(ply)
3030
MSync.net.sendTable(ply, "modulestate", MSync.settings.data.enabledModules)
31+
32+
if ply:query("msync.openAdminGUI") then
33+
MSync.net.dbStatus(ply)
34+
end
3135
end)

msync/server/sv_net.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ function MSync.net.openAdminGUI(ply)
4949
end
5050
util.AddNetworkString("msync.openAdminGUI")
5151

52+
--[[
53+
Description: Function to send the database status to the client
54+
Arguments:
55+
player [player] - the player that wants to know the db status
56+
Returns: nothing
57+
]]
58+
function MSync.net.dbStatus(ply)
59+
net.Start("msync.dbStatus")
60+
if MSync.DBServer then
61+
net.WriteBool(true)
62+
else
63+
net.WriteBool(false)
64+
end
65+
net.Send(ply)
66+
end
67+
util.AddNetworkString("msync.dbStatus")
68+
5269
--[[
5370
Description: Net Receiver - Gets called when the client requests a table
5471
Returns: nothing

0 commit comments

Comments
 (0)