# Method Global:RegisterServerEvent [-] [+]

Registers a server event handler.

ID | Event | Parameters | Comment
--- | --- | --- | ---
1 | SERVER_EVENT_ON_NETWORK_START |  | Not Implemented
2 | SERVER_EVENT_ON_NETWORK_STOP |  | Not Implemented
3 | SERVER_EVENT_ON_SOCKET_OPEN |  | Not Implemented
4 | SERVER_EVENT_ON_SOCKET_CLOSE |  | Not Implemented
5 | SERVER_EVENT_ON_PACKET_RECEIVE | event, packet, player | Player only if accessible. Can return false, newPacket
6 | SERVER_EVENT_ON_PACKET_RECEIVE_UNKNOWN |  | Not Implemented
7 | SERVER_EVENT_ON_PACKET_SEND | event, packet, player | Player only if accessible. Can return false
8 | WORLD_EVENT_ON_OPEN_STATE_CHANGE | event, open | Needs core support on Mangos
9 | WORLD_EVENT_ON_CONFIG_LOAD | event, reload |
11 | WORLD_EVENT_ON_SHUTDOWN_INIT | event, code, mask |
12 | WORLD_EVENT_ON_SHUTDOWN_CANCEL | event |
13 | WORLD_EVENT_ON_UPDATE | event, diff |
14 | WORLD_EVENT_ON_STARTUP | event |
15 | WORLD_EVENT_ON_SHUTDOWN | event |
16 | ELUNA_EVENT_ON_LUA_STATE_CLOSE | event | triggers just before shutting down eluna (on shutdown and restart)
17 | MAP_EVENT_ON_CREATE | event, map |
18 | MAP_EVENT_ON_DESTROY | event, map |
19 | MAP_EVENT_ON_GRID_LOAD |  | Not Implemented
20 | MAP_EVENT_ON_GRID_UNLOAD |  | Not Implemented
21 | MAP_EVENT_ON_PLAYER_ENTER | event, map, player |
22 | MAP_EVENT_ON_PLAYER_LEAVE | event, map, player |
23 | MAP_EVENT_ON_UPDATE | event, map, diff |
24 | TRIGGER_EVENT_ON_TRIGGER | event, player, triggerId | Can return true
25 | WEATHER_EVENT_ON_CHANGE | event, zoneId, state, grade |
26 | AUCTION_EVENT_ON_ADD | event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow |
27 | AUCTION_EVENT_ON_REMOVE | event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow |
28 | AUCTION_EVENT_ON_SUCCESSFUL | event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow |
29 | AUCTION_EVENT_ON_EXPIRE | event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow |
30 | ADDON_EVENT_ON_MESSAGE | event, sender, type, prefix, msg, target | Target can be nil/whisper_target/guild/group/channel. Can return false
31 | WORLD_EVENT_ON_DELETE_CREATURE | event, creature |
32 | WORLD_EVENT_ON_DELETE_GAMEOBJECT | event, gameobject |
33 | ELUNA_EVENT_ON_LUA_STATE_OPEN | event | Triggers after all scripts are loaded
34 | GAME_EVENT_START | event, gameeventid |
35 | GAME_EVENT_STOP | event, gameeventid |

## Synopsis

`cancel = RegisterServerEvent( event, function )`

`cancel = RegisterServerEvent( event, function, shots )`

## Arguments

`number event`

  Server event ID, refer to table above.

  Valid numbers: integers from 0 to 4,294,967,295.

`function function`

  Function that will be called when the event occurs.

`number shots (0)`

  The number of times the function will be called, 0 means "always call this function".

  Valid numbers: integers from 0 to 4,294,967,295.

## Returns

`function cancel`

  A function that cancels the binding when called.

# Keyboard shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

# Search tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct` (or `str`), `enum`, `trait`, `typedef` (or `tdef`).

Generated on
© 2010 - 2024 Eluna Lua Engine