Skip to content

Javascript Events

zeroKilo edited this page Dec 3, 2018 · 1 revision

Javascript Events

these names can be assigned handlers for various game events and these function templates can be used for them

`

// js object is "this.frontend"
"onDisabled"
function onDisabledFrontend() {}

"onEnabled"
function onEnabledFrontend() {}


// js object is "this.login"
"onError"
function onLoginError(data) { data.message ...}

"onStateChanged"
function onLoginStateChange(oldState, state) {}


// js object is "this.matchmaking"
"onGameStarted"
function onGameStarted(gameId) {}

"onStateChanged"
function onStateChanged(oldState, newState, errorCode) {}

"onQueueUpdated"
function onQueueUpdated() {}

"onPingResponse"
function onPingResponse(ip, ms) {}


// js object is "this.game"
"onLoadingAborted"
function onLoadingAborted() {}

"onLoadingComplete"
function onLoadingComplete() {}

"onLoadingProgressUpdated"
function onLoadingProgressUpdated(progress) {}

"onLoadingStart"
function onLoadingStart() {}

"onBeginRoundStateChanged"
function onBeginRoundStateChanged(state) {}


// js object is "this.bookmarks"
"onServerAdded"
function onServerAdded(response, guid) {}

"onServerRemoved"
function onServerRemoved(response, guid) {}`

example usage:

game.addEventHandler('onLoadingStart', 'showLoading');

Clone this wiki locally