understanding events
@Katton.listen("event_name")
function handlerName(event) {
// do something with "event"
}
@Katton.listen(...)always takes exactly one string which is the event name- the function always takes exactly one parameter called
event - theres only a limited amount of events (see event list & properties).
player_join and player_quit are NOT server connect/disconnect
player_joinfires when a player entersthe arenaplayer_quitfires when a player leavesthe arena
if you want "a player connected to the server" or "a player disconnected", Katton doesn't expose that directly
@Katton.listen("player_join")
function onArenaEnter(event) {
event.player.sendMessage("&aWelcome!")
}
@Katton.listen("player_quit")
function onArenaLeave(event) {
// fires when they leave the arena
}
next!
- event list & properties, every event name and what you can read off it
- cancelling events, how and when
event.cancel()actually does something