Hey,
Is it somehow possible to exclude a file from the LUA autorefresh?
My mysql lua is refreshing and creating new connections this way, which is a issue as the host only allows up to 10 connections, means I can refresh it 9-10 times, before the MySQL just stops working and starts erroring.
I couldn't find a disconnect function in MySQLoo, that I could eventually hook up to GM:OnReload() either.
Why not just add a check before (re)connecting.
Example:
[lua]
function moderator.Connect(host, username, password, database, port)
if !mysqloo then require("mysqloo") end
if !moderator.mysql then
if !host or !username or !password or !database then
return MsgN("[moderator] Failed to connect to the database please check credentials.")
end
moderator.mysql = {}
moderator.mysql = mysqloo.connect(host, username, password, database, port or 3306)
moderator.mysql.onConnected = function()
moderator.mysql.connected = true
MsgN("[moderator] Successfully connected to the database.")
moderator.GetSync()
end
moderator.mysql.onConnectionFailed = function( db, error )
MsgN("[moderator] Failed(" .. error .. ") to connect to the database.")
end
moderator.mysql:connect()
else
if moderator.mysql:status() != 0 then
moderator.mysql:connect()
end
end
end
[/lua]
I check to see if the mysql object is valid because once it's connected it will be valid. If it is valid I only reconnect if the status is not 0.
[code]
mysqloo.DATABASE_CONNECTED -- [Number] 0 - Database is connected
mysqloo.DATABASE_CONNECTING -- [Number] 1 - Datbase is connecting
mysqloo.DATABASE_NOT_CONNECTED -- [Number] 2 - Database is not connected
mysqloo.DATABASE_INTERNAL_ERROR -- [Number] 3 - Internal error
[/code]
Acecool, I summon thee.
acecool is unavailable at this time but you can declare a global variable (globals only get set once when declared and are not reset when autorefreshed), then check if the variable is set
Sorry, you need to Log In to post a reply to this thread.