events.hooks module¶
Provides event hooking functionality.
- classevents.hooks.EventAction[source]¶
Bases:
enum.IntEnumEnum class used to know what to do with a pre-hooked event.
- Attr:
CONTINUE: Allow the event to be fired on theserver and transmitted to clients.
- Attr:
STOP_BROADCAST: Allow the event to be fired on the serverbut not to be transmitted to clients.
- Attr:
BLOCK: Stop the event from being fired on the server.
- @events.hooks.PreEvent(*event_names)[source]¶
Bases:
core.AutoUnloadFired when any event in
event_namesis about to be fired on the server.- Parameters:
event_names (str) – An event name or any number ofevent names to register to the decorated function.
The decorated function is passed the following parameters whenan event in
event_namesis going to be fired on the server:- Parameters:
game_event (GameEvent) – The fired event object.
- Return type:
Examples:
fromeventsimportPreEvent@PreEvent('player_death')defpre_player_died(game_event):# Code...
@PreEvent('round_start','round_freeze_end')defsome_pre_function(game_event):# Code...# Stop the event from being fired at all on the serverreturnEventAction.BLOCK
@PreEvent('player_team')defpre_player_team(game_event):# Code...# Stop the event from being transmitted to clientsreturnEventAction.STOP_BROADCAST
See also
Events for a list of supported events per game.
- events.hooks.pre_event_manager¶
The singleton object of the
_PreEventManagerclass.
