AddEventHandler Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version:

NOTE! Events are special function, which are called when something specific happend. For example, when player join to the server, is called event named onPlayerJoin.

NOTE! New event must be registered via addEvent function.

Function add a handler to the specified event.


bool addEventHandler(string eventName, function callback[, int priority])

Required Arguments

  • eventName: The name of event.
  • callback: The function, which will be called when event will be triggered.

Optional Arguments

  • priority: Priority by which event will be sorted in event queue and then called in order.



addEventHandler("onPlayerJoin", function(pid)
	sendMessageToAll(0, 255, 0, getPlayerName(pid) + " joined to the server");

addEventHandler("onPlayerDisconnect", function(pid, reason)
	sendMessageToAll(255, 0, 0, getPlayerName(pid) + " disconnected from the server. Reason " + reason);



Related functions