• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Globalevents errors when launching server.

svettis-

New Member
Joined
May 22, 2008
Messages
90
Reaction score
0
Namnlös3.jpg

Anyone know whats wrong?

My globalevents.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
	<!-- XTibia.com -->
	<globalevent name="save" interval="1800000" event="script" value="save.lua"/>
	<globalevent name="clean" interval="7200000" event="script" value="clean.lua"/>
        <globalevent name="playersrecord" type="record" event="script" value="record.lua"/>
	<globalevent name="raid" interval="108000" event="script" value="raid.lua"/>
        <globalevent name="serverstart" type="start" event="script" value="start.lua"/>

</globalevents>

start.lua
Code:
function onStartup()
	db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
	return true
end

and record.lua
Code:
function onRecord(current, old, cid)
        db.executeQuery("INSERT INTO `server_record` (`record`, `world_id`, `timestamp`) VALUES (" .. current .. ", " .. getConfigValue('worldId') .. ", " .. os.time() .. ");")
        addEvent(doBroadcastMessage, 150, "New record: " .. current .. " players are logged in.", MESSAGE_STATUS_DEFAULT)
end

Thanks in advance
<3
 
Did you use an other config or did you already had this error the moment you started the server for the first time. Or did you changed something else?
 
Try this as start.lua


function onStartup()
db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
return true
end
 
Try this as start.lua


function onStartup()
db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
return true
end

Now I got this error:
Code:
[18:54:18.830] [Error - GlobalEvent Interface]
[18:54:18.830] data/globalevents/scripts/start.lua:onStartup
[18:54:18.831] Description:
[18:54:18.831] data/globalevents/scripts/start.lua:2: attempt to call field 'executeQuery' <a nil value>
[18:54:18.831] stack traceback:
[18:54:18.832] data/globalevents/scripts/start.lua:2: in fuction <data/globalevents/scripts/start.lua:1>

Also to mention, I get error everytime someone logs in:
Code:
[18:57:46.582] [Error - GlobalEvent Interface]
[18:57:46.584] data/globalevents/scripts/record.lua:onStartup
[18:57:46.586] Description:
[18:57:46.589] data/globalevents/scripts/record.lua:2: attempt to call field 'executeQuery' <a nil value>
[18:57:46.591] stack traceback:
[18:57:46.593] data/globalevents/scripts/record.lua:2: in fuction <data/globalevents/scripts/record.lua:1>
 
Last edited:
Looks like your server just doesn't recognize the code. You can also try this.

LUA:
function onStartup()
	db.escapeString("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
	return true
end
 
Back
Top