So i was setting up GForum and noticed that it disconnects a lot so i tried timer.Simple to make it run the ConnectToSQL() Function every few minutes and didn’t seem to work.
In Fact the timer doesn’t run at all, It only reconnects with the ls_reconnect command.
I haven’t noticed any lua errors so i’m not sure what the problem is.
function ConnectToSQL() require("mysqloo") database = mysqloo.connect(Host, User, Pass, DB, Port) database.onConnected = function() database.connected = true print("Successfully to connected to database.") end database.onConnectionFailed = function() database.connected = false print("Failed to connect to the database.") end database:connect() timer.Simple(3, function() if !database.connected then return MsgC(Color(255, 0, 0), "Warning the Login System isn't connected to the database. You will be unable to use gForum until your connect to the database. ") end local query1 = database:query( "CREATE TABLE IF NOT EXISTS " .. Prefix .. "_link (`id` INTEGER NOT NULL, `steamid` TEXT NOT NULL)") query1:start() local query2 = database:query( "CREATE TABLE IF NOT EXISTS " .. Prefix .. "_rank (`id` INTEGER NOT NULL, `rank` TEXT NOT NULL, `steamid` TEXT NOT NULL)") query2:start() end) end concommand.Add("ls_reconnect", ConnectToSQL ) function Reconnect() ConnectToSQL() if !database.connected then print("Login System Re-Connected") end end timer.Simple( 950, Reconnect )