milbradt
New Member
- Joined
- Dec 25, 2011
- Messages
- 177
- Solutions
- 1
- Reaction score
- 4
Hello
I'm trying to make a script that checks if the server is connected to the database.
However .. I'm not succeeding.
Someone suggests an idea?
My script...
My idea is to restart the server if you do not check the database.
I'm trying to make a script that checks if the server is connected to the database.
However .. I'm not succeeding.
Someone suggests an idea?
My script...
Code:
STORAGE_CHECK_BUG_INVALID = 777
function onThink(interval, lastExecution)
local function checkbug()
resultw2 = db.getResult("SELECT `value` FROM `global_storage` WHERE `key` = ".. STORAGE_CHECK_BUG_INVALID ..";")
keyx2 = resultw2:getDataInt("value")
if keyx2 == 1 then
print("SHUTDOWN 1 TEST")
end
end
local function bugcheck()
resultw3 = db.getResult("SELECT `value` FROM `global_storage` WHERE `key` = ".. STORAGE_CHECK_BUG_INVALID ..";")
keyx3 = resultw3:getDataInt("value")
if keyx3 == 2 then
print("SHUTDOWN 2 TEST")
end
end
resultw = db.getResult("SELECT `value` FROM `global_storage` WHERE `key` = ".. STORAGE_CHECK_BUG_INVALID ..";")
keyx = resultw:getDataInt("value")
if keyx == 1 then
print("one")
db.executeQuery("UPDATE `global_storage` SET `value` = 2 WHERE `key` = ".. STORAGE_CHECK_BUG_INVALID ..";")
addEvent(checkbug, 500)
elseif keyx == 2 then
print("two")
db.executeQuery("UPDATE `global_storage` SET `value` = 1 WHERE `key` = ".. STORAGE_CHECK_BUG_INVALID ..";")
addEvent(bugcheck, 500)
end
return TRUE
end
My idea is to restart the server if you do not check the database.
Last edited: