-
Notifications
You must be signed in to change notification settings - Fork 171
Server Script Events
MaribelHearn edited this page Nov 6, 2015
·
14 revisions
-
loadScript: function ()
When the script is loaded, can be stopped with sys.stopEvent(); -
unloadScript: function()
When the script is unloaded. -
switchError: function(scr)
When the script is unloaded, but the new script didn't load, and the old script is put back. Should bring the script back into a usable state. -
warning: function(wrn)
When a script function emits a warning control is transfered to the warning function which acts similarly to a signal handler. Beware that the script may be in an arbitrary state. If you throw the warning as an error this will be thrown to the function that caused the warning.
-
serverStartUp: function()
When the server starts up. For most things,loadScript
is better. -
serverShutDown: function()
When the server shuts off. For most tings,unloadScript
is better. -
[before/after]NewMessage: function(msg)
When a message is printed to the console. WARNING: Don't print messages carelessly in this event, otherwise it can cause an infinite loop. -
step
Every second.
-
battleSetup(source, target, battleId)
between 'beforeBattleStarted' and 'afterBattleStarted'. Used to setup battle effects. See prepareWeather() function.
-
attemptToSpectateBattle(src, player_id_1, player_id_2)
if function implementing it will return "allow" (case insensitive) player will be allowed to watch even if spectators are disabled and auth is not high enough. Otherwise has no effect and normal rules apply.
These events have a beforeEvent and afterEvent version.
-
IPConnected(IP)
When an IP tries to interface with the server, before and information is sent/received, useful for anti-dos. -
LogIn(source)
When a player logs in. -
LogOut(source)
When a player logs out.
-
ChatMessage(source, message, channel_id)
When the message of a player is displayed. There's a possibility that in the future, the client could talk directly to the server not being in a channel, and then the id would be -1.
-
ChannelJoin(player_id, channel_id)
When a player logs on, this event will be called, even if this is on the main channel. -
ChannelLeave(player_id, channel_id)
when a player logs off, this event will be called on all channels the player is on. -
ChannelCreated(channel_id, channel_name, player_id)
the player_id is for when a player joins a channel that doesn't exist (hence creating it), you have the id of the player who is creating the channel. ChannelDestroyed(channel_id)
In these events clauses
is an integer between 0 and 1023 depending on what clauses are enabled
SleepClause = 1 (1 << 0) 0b-0001
FreezeClause = 2 (1 << 1) 0b-0010
DisallowSpectator = 4 (1 << 2) 0b-0100
ItemClause = 8 (1 << 3) 0b-1000
ChallengeCup = 16 (1 << 4) 0b-0001-0000
NoTimeOut = 32 (1 << 5) 0b-0010-0000
SpeciesClause = 64 (1 << 6) 0b-0100-0000
RearrangeTeams = 128 (1 << 7) 0b-1000-0000
SelfKO = 256 (1 << 8) 0b-0001-0000-0000
InvertedBattle = 512 (1 << 9) 0b-0010-0000-0000
-
BattleMatchup(source, target, clauses, rated, mode,team1, team2)
When a battle using findBattle is decided. Stop the event if you don't want the matchup. -
BattleStarted(source, target, clauses, rated, mode, battleid, team1, team2)
When a battle starts. -
BattleEnded(winner, loser, result, battle_id)
When a battle ends. result is either "win", "forfeit", or "tie". -
ChallengeIssued(source, target, clauses, rated, mode, team1, team2)
When a player is challenged. mode is 0 for Singles, 1 for Doubles and 2 for Triples. rated is always false now that rated battles through direct challenges are disabled. SpectateBattle(source, battler1, battler2)
-
NewPM(source)
When a player pms another player and the PM window is opened for the first time.source
is the player sending the message. Useful to detect mass PMing. -
ChangeTeam(source)
When a player changes teams. -
ChangeTier(source, team, oldtier, newtier)
When a player changes tiers. Stoppable(?) event. -
PlayerAway(source, away)
When a player goes or comes back from away. away is set to true or false, depending on if the players goes away or not. -
PlayerBan(source, dest)
When player source bans dest via control panel -
PlayerKick(source, dest)
When player source kicks dest via control panel -
PlayerRegister(playerID)
When a player registers