Commit 9f1f2037 authored by Maximilian Grüttemeier's avatar Maximilian Grüttemeier
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
parent 4341766c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -88,3 +88,11 @@ end )
net.Receive( "msync.openAdminGUI", function( len, pl )
    MSync.AdminPanel.InitPanel()
end )

--[[
    Description:  Net Receiver - Gets called when server sent the db status
    Returns: nothing
]]
net.Receive( "msync.dbStatus", function( len, pl )
    MSync.DBStatus = net.ReadBool()
end )
 No newline at end of file
+4 −5
Original line number Diff line number Diff line
@@ -128,7 +128,9 @@ function MSync.modules.MRSync.adminPanel(sheet)
        end
    end

    if MSync.DBStatus then
        MSync.modules.MRSync.getSettings()
    end

    if not MSync.modules.MRSync.settings then
        timer.Create("mrsync.t.checkSettings", 1, 0, function()
@@ -199,7 +201,6 @@ function MSync.modules.MRSync.net()
        Returns: nothing
    ]]   
    net.Receive("msync.mrsync.sendSettingsPly", function(len, ply)
        
        MSync.modules.MRSync.settings = net.ReadTable()
    end )
end
@@ -215,9 +216,7 @@ end
    Define hooks your module is listening on e.g. PlayerDisconnect
]]
function MSync.modules.MRSync.hooks() 
    hook.Add("initialize", "msync_sampleModule_init", function()

    end)
end

--[[
+4 −0
Original line number Diff line number Diff line
@@ -28,4 +28,8 @@ end)
hook.Add("PlayerInitialSpawn", "msync.createUser", function( ply )
    MSync.mysql.addUser(ply)
    MSync.net.sendTable(ply, "modulestate", MSync.settings.data.enabledModules)

    if ply:query("msync.openAdminGUI") then
        MSync.net.dbStatus(ply)
    end
end)
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
@@ -49,6 +49,23 @@ function MSync.net.openAdminGUI(ply)
end
util.AddNetworkString("msync.openAdminGUI")

--[[
    Description: Function to send the database status to the client
    Arguments:
        player [player] - the player that wants to know the db status
    Returns: nothing
]]   
function MSync.net.dbStatus(ply)
    net.Start("msync.dbStatus")
        if MSync.DBServer then
            net.WriteBool(true)
        else
            net.WriteBool(false)
        end
    net.Send(ply)
end
util.AddNetworkString("msync.dbStatus")

--[[
    Description: Net Receiver - Gets called when the client requests a table
    Returns: nothing