Skip to content

Interface:Global Events

Stefan A. Brannfjell edited this page Dec 19, 2017 · 4 revisions

Global stuff... (TODO)

-- Empty!

Available events:

onRecord()
onShutdown()
onStartup()
onTime()


onRecord()

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


onShutdown()

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


onStartup()

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


onTime()

Description: N/A
Parameters: N/A
Accepted return values: N/A
Example:

N/A  

Added in version: 1.0

Clone this wiki locally