-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Interface:Global Events
Stefan A. Brannfjell edited this page Dec 19, 2017
·
4 revisions
Global stuff... (TODO)
-- Empty!
onRecord()
onShutdown()
onStartup()
onTime()
Description: Execute Lua code when a new concurrent players online record occurs.
Parameters: current, old
Accepted return values: boolean (true/false)
Example:
function onRecord(current, old)
addEvent(broadcastMessage, 150, "New record: " .. current .. " players are logged in.", MESSAGE_STATUS_DEFAULT)
return true
end
Added in version: 1.0
Description: Execute Lua code just before the server shuts down. Note: May not execute if server crashes. Parameters: N/A
Accepted return values: N/A
Example:
N/A
Added in version: 1.0
Description: N/A
Parameters: N/A
Accepted return values: N/A
Example:
function onStartup()
math.randomseed(os.mtime())
-- store towns in database
db.query("TRUNCATE TABLE `towns`")
for i, town in ipairs(Game.getTowns()) do
local position = town:getTemplePosition()
db.query("INSERT INTO `towns` (`id`, `name`, `posx`, `posy`, `posz`) VALUES (" .. town:getId() .. ", " .. db.escapeString(town:getName()) .. ", " .. position.x .. ", " .. position.y .. ", " .. position.z .. ")")
end
end
Added in version: 1.0
Description: N/A
Parameters: N/A
Accepted return values: N/A
Example:
N/A
Added in version: 1.0