OptionalmodifyIf defined, runs only for the current player in a client room and modifies its ping value.
Current ping value of the current player.
OptionalcustomData: anyThe new ping value of the current player.
OptionalmodifyCalled just before the player has joined the room. Using this callback, you may block all players or modify all players' name, flag and avatar properties just before they join the room.
Id of the new player who is about to join the room.
Name of the new player who is about to join the room.
Country code of the new player who is about to join the room.
Avatar of the new player who is about to join the room.
Connection string of the new player who is about to join the room.
Auth string of the new player who is about to join the room.
OptionalcustomData: anynull: Blocks the player from joining the room.
[modifiedName: string, modifiedFlag: string, modifiedAvatar: string]: Modifies the name, flag and avatar values.Promise<[modifiedName: string, modifiedFlag: string, modifiedAvatar: string]>: Modifies the name, flag and avatar values after the promise might be resolved.(sync)
this.modifyPlayerData = function(playerId, name, flag, avatar, conn, auth){
if (name=="abc")
return null; // block anyone trying to join the room with name "abc", before he can join the room.
return [
"[" + playerId + "] " + name, // prefix everyone's name with [playerId]
"tr", // set everyone's flag to tr
avatar // do not change avatars
];
};
(async)
this.modifyPlayerData = async function(playerId, name, flag, avatar, conn, auth){
// connect to whatever database you want
var dbPlayerSpecs = await db.getPlayerSpecs(conn, auth);
if (!dbPlayerSpecs)
return null; // blocked.
return [
"[" + playerId + "] {" + dbPlayerSpecs.name + "}" + name, // prefix everyone's name with [playerId] and then player's name in the database.
dbPlayerSpecs.flag, // always use player's flag in the database.
dbPlayerSpecs.avatar // always use player's avatar in the database.
];
};
OptionalmodifyIf defined, runs for all players except host in a host room. Modifies the ping value of the player whose id is playerId.
Host player's ping will not change using this callback. In order to change host player's ping, you need to modify room.hostPing value directly.
Id of the current player.
Current ping value of the current player.
OptionalcustomData: anyThe new ping value of the current player.
OptionalonCalled just after an announcement was made by the room host.
The announcement message.
The color of the announcement message. Range: -1 <= color < 16777216.
Utils.numberToColor function.-1 means transparent color.The style of the announcement message. Must be one of the following:
The sound of the announcement message. Must be one of the following:
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an announcement has been sent using the improved announcement api.
The announcement message. ( max length = 1000 )
OptionalcssVar: stringThe cssVar of the announcement message.
Optionalsound: stringThe sound of the announcement message.
OptionaltargetId: numberId of the player who will receive this announcement. If this value is null, the announcement is sent to everyone.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an "auto" event has been triggered to automatically move at least one, at most two players from spectators to teams.
Id of the first player affected by this event.
Id of the team which the first player was moved into.
Id of the second player affected by this event, or null if there was only one spectator when this event was triggered.
Id of the team which the second player was moved into, or null if there was only one spectator when this event was triggered.
Id of the player who has triggered the event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the ban of a player has been cleared using room.clearBan(id).
Id of the player whose ban has just been cleared.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after all bans have been cleared using room.clearBans().
OptionalcustomData: anyvoid or a custom data to pass to the next callback.
OptionalonCalled just after a binary custom event has been triggered.
Any integer value to hold the type of the custom event.
Any Uint8Array to store the properties of the custom event. This object is directly sent/received by Mooball's original event mechanism.
Id of the player who has triggered this custom event.
OptionalcustomData: anyAny custom data that might be returned from the previous addon's calback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game clock has been paused/resumed.
Whether the game will be paused(1) or resumed(0).
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a collision has happened between two discs.
Id of the first collided disc.
The player's id that the first disc belongs to. If the disc is not a player's disc, this value will be null.
Id of the second collided disc.
The player's id that the second disc belongs to. If the disc is not a player's disc, this value will be null.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a collision has happened between a disc and a plane.
Id of the collided disc.
The player's id that the disc belongs to. If the disc is not a player's disc, this value will be null.
Id of the collided plane.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a collision has happened between a disc and a segment.
Id of the collided disc.
The player's id that the disc belongs to. If the disc is not a player's disc, this value will be null.
Id of the collided segment.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's config object has been replaced by a new one.
The old RoomConfig object.
The new RoomConfig object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after game input controls have been modified.
Type of the operation. (0: add, 1: remove)
Parameters for the specific operation.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a custom event has been triggered.
Any integer value to hold the type of the custom event.
Any JSON object to store the properties of the custom event. This object is converted to a string and sent/received by Mooball's original event mechanism.
Id of the player who has triggered this custom event.
OptionalcustomData: anyAny custom data that might be returned from the previous addon's calback.
void or a custom data to pass to the next callback.
OptionalonCalled just after room.directionActive has been changed.
New directionActive value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current elapsed time has been changed.
New elapsed time value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game has ended.
Id of the team that won the game.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game has been paused or resumed.
Whether the game has been paused or not.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game has been started.
Id of the player who has started the game.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game has been stopped.
Id of the player who has stopped the game.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a game tick has occurred. This will run a lot of times per second. Be careful not to make too many calculations here, otherwise the game might slow down.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the local ping handicap value has been changed.
The new ping handicap value in milliseconds. Range: 0 <= value <= 300.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an identity event has been triggered.
Id of the player whose identity data is desired to be changed.
The identity data that should be received from the backend. It can be any JSON object.
Id of the player who has triggered this custom event.
OptionalcustomData: anyAny custom data that might be returned from the previous addon's calback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a kick-off event has occurred.
OptionalcustomData: anyvoid or a custom data to pass to the next callback.
OptionalonCalled just after the room's kick rate limit has been changed.
The new min part of kick rate limit.
The new rate part of kick rate limit.
The new burst part of kick rate limit.
Id of the player who has changed the kick rate limit.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the API's language has been changed.
The new language's abbreviation value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a library object has been added.
The Library object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a library object has been moved.
The Library object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a library object has been removed.
The Library object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an old library object has been replaced by a new one.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current max end ticks has been changed.
New max end ticks value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current max goal ticks has been changed.
New max goal ticks value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current max pause ticks has been changed.
New max pause ticks value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonIf defined, runs for each message received from all clients in a host room, before they are processed and sent to all clients. This is the most important callback inside a host room; all permission logic should reside here. You are also allowed to freely modify the contents of all messages here.
Type of the received message. We have to look it up in the global OperationType object to understand what type of message it actually is.
The original message object. We can directly modify all contents of this object here as we wish.
The global frame no that host's physics engine is at, at the time that the message is received.
The frame no that this client's physics engine is at, at the time that the message is received.
OptionalcustomData: anytrue: accept event.
false: block message from being processed.throw exception: break the connection of the sender of this message.this.onOperationReceived = function(type, msg, globalFrameNo, clientFrameNo, customData){
switch (type){
case OperationType.KickBanPlayer: { // if someone is leaving or being kicked/banned by someone else
var reason = msg.reason; // get the reason. this is null if the player is leaving by himself/herself.
if (reason!=null && playerId!=0) // if any player sends a kick/ban event message other than room host
return false; // block the event message
break;
}
}
return true;
};
OptionalonCalled just after room's overtime limit has been changed.
The desired overtime limit of the game.
OptionalcustomData: anyvoid or a custom data to pass to the next callback.
OptionalonCalled just after the ping value of the current player has been calculated.
the instant ping value at that moment
the calculated average ping value in a period of time
the calculated maximum ping value in a period of time
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the ping values for all players have been updated.
The updated list of ping values for each player in the same order as the player list in the current room's RoomState object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a custom sound has been played.
Name of the sound to be played.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player's admin rights have been given/taken.
Id of the player whose admin rights have been given/taken.
The new admin rights status of the player whose id is id.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has changed his/her avatar.
Id of the player who has changed his/her avatar.
The new avatar value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the ball has been kicked.
Id of the player who kicked the ball.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a chat message has been received.
Id of the player who has sent the chat message.
The chat message.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has activated or deactivated his/her chat indicator. This happens when a player focuses/loses focus on the chat input component in the website.
Id of the player whose chat indicator has been activated/deactivated.
Whether the chat indicator has been activated or not.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the cssVar attribute of a player has been changed.
Id of the player whose cssVar will be modified.
New cssVar value of the player.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the direction of an individual player was changed. room.state.directionActive must be true for this to work.
Id of the player whose energy values will be modified.
New direction value of the player.
OptionalcustomData: anyvoid or a custom data to pass to the next callback.
OptionalonCalled just after a disc object has been assigned to a player object.
The new Player object that has just been assigned a disc object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a disc object has been removed from a player object.
The Player object whose disc object has just been removed.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the energy of an individual player has been altered manually.
Id of the player whose energy values will be modified.
New values. Order of values is supposed to be: [energy, kEnergyGain, kEnergyDrain]. null means no change for each value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has changed his/her headless avatar.
Id of the player who triggered this event.
The new headless avatar value.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player's input has been changed.
Id of the player whose input has been changed.
The new input value of the player.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has joined the room.
The data representation of the player that has just joined the room.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has left the room.
The player who has left the room.
The reason of leaving the room. If null, the player has left by himself/herself.
Whether the player has been banned or not. If reason is null, this value is ignored.
Id of the player who has kicked/banned the player. If reason is null, this value is ignored.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player object has been created. This callback can be used to define custom properties inside all player objects.
The new Player object that has just been created.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current skin(textureId) of a player has been updated.
Id of the player whose skin will be modified.
New skin value of the player.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the order of players have been changed.
The ids of players that were removed from the room's players list, reordered to match the order in idList and added back to the room's players list.
The ids of players that were removed from the room's players list, reordered to match the order in idList and added back to the room's players list.
Whether to add the players to the top or bottom of the room's players list.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player's synchronization status has changed.
Id of the player whose synchronization status has changed.
The new synchronization status.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a player has been moved to a different team.
Id of the player who has been moved to a different team.
Id of the player's new team.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a plugin has been activated or deactivated.
The plugin which was activated or deactivated. This property stores the current activation status of the plugin: plugin.active.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a plugin object has been added.
The Plugin object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a plugin object has been moved.
The Plugin object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a plugin object has been removed.
The Plugin object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an old plugin object has been replaced by a new one.
void or a custom data to pass to the next callback.
OptionalonCalled just after the player positions have been reset. This event happens just after a new game has been started or a goal has been scored. The player positions are reset to their corresponding spawn points defined in the current room's Stadium object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's renderer object has been replaced by a new one.
void or a custom data to pass to the next callback.
OptionalonThe room link was received from moo-hoo.com. Called some time after a room is created successfully. Also called when your room stops sending signal to moo-hoo.com, and starts it again after some time. This can happen if your connection gets interrupted or the room somehow becomes unstable due to bugs.
The room link that was just received.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the name of the room has been changed.
The new room name.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's properties have been changed.
The properties that were changed. The current structure of this object is as follows:
props = {
name: string | null,
password: string | null,
fakePassword: boolean | null,
geo: GeoLocation | null,
playerCount: int | null,
maxPlayerCount: int | null
}
Note that only the changed keys will show up in props.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's recaptcha mode was changed using room.requireRecaptcha = on.
The new value; whether to request recaptcha or not while joining the room.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after room recording has been started or stopped.
If true, recording has just been started,
value as an ArrayBuffer. You might want to write the contents to a version-3 replay file.OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just a little after the room's token was changed using room.token = value.
The new token of the room.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after room.runDefaultGameLogic has changed.
Whether the default game logic is active(1) or passive(0).
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the score limit has been changed.
The new score limit value.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a disc's properties have been modified.
The id of player or disc whose disc properties have changed.
The type of object. Must be one of the following:
Must consist of the following properties of the disc in the same order: [x, y, xspeed, yspeed, xgravity, ygravity, radius, bCoeff, invMass, damping].
Must consist of the following properties of the disc in the same order: [color, cMask, cGroup].
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a new stadium object has been added.
Type of the object to be added.
An object that is supposed to contain all parameters required to add that type of object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's current stadium has been changed.
The room's new Stadium object.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an existing stadium object has been removed.
Type of the object to be removed.
Id of the object to be removed.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after an existing stadium object has been updated.
Type of the object to be updated.
Id of the object to be updated.
An object that is supposed to contain all parameters required to update that type of object.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a team's colors have been changed.
The team that colors have been changed.
The new team colors value.
Id of the player who has changed the team colors.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after a goal has been scored.
Id of the team that scored the goal.
Id of the goal object that the ball went in.
The goal object that the ball went in.
Id of the ball disc that caused the goal.
The ball disc that caused the goal.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current team scores has been changed.
Id of the team whose score is desired to be changed.
New score for the team.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the room's teams have been locked/unlocked.
The room's new teams lock value.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the game has ended by timeout.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the time limit has been changed.
The new time limit value.
Id of the player who has triggered this event.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the current contents of a css variable has been altered.
Name of the css variable..
New value of the css variable.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
OptionalonCalled just after the value of a variable has been changed.
The Addon object that the variable belongs to.
The name of the variable whose value has been changeed.
The old value of the variable.
The new value of the variable.
OptionalcustomData: anythe custom data that was returned from the previous callback.
void or a custom data to pass to the next callback.
These events can only be received by a host room.