listeners package

Module contents

Provides listener based functionality.

class listeners.ButtonStatus[source]

Bases: enum.IntEnum

Indicate whether a button has been pressed or released.

_member_type_

alias of int

_generate_next_value_(name, start, count, last_values)
PRESSED = <ButtonStatus.PRESSED: 1>
RELEASED = <ButtonStatus.RELEASED: 0>
_member_map_ = OrderedDict([('RELEASED', <ButtonStatus.RELEASED: 0>), ('PRESSED', <ButtonStatus.PRESSED: 1>)])
_member_names_ = ['RELEASED', 'PRESSED']
_value2member_map_ = {0: <ButtonStatus.RELEASED: 0>, 1: <ButtonStatus.PRESSED: 1>}
class listeners.ListenerManager

Bases: Boost.Python.instance

__init__((object)arg1) → None
clear((ListenerManager)arg1) → None :

Remove all registered callbacks.

notify(*args, **kw)

PY signature :Notifies all registered listeners.

register_listener((ListenerManager)arg1, (object)callable) → None :

Registers a callable object. If it was already registered it will be ignored.

unregister_listener((ListenerManager)arg1, (object)callable) → None :

Removes a callable object. If it was not registered nothing will happen.

class listeners.ListenerManagerDecorator(callback)[source]

Bases: core.AutoUnload

Base decorator class used to register/unregister a listener.

__init__(callback)[source]

Store the callback and register the listener.

_unload_instance()[source]

Unregister the listener.

manager

Return a ListenerManager object.

name

Return the class name of the instance.

class listeners.OnClientActive(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientActive listener.

manager = <_listeners.ListenerManager object>
class listeners.OnClientConnect(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientConnect listener.

manager = <_listeners.ListenerManager object>
class listeners.OnClientDisconnect(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientDisconnect listener.

manager = <_listeners.ListenerManager object>
class listeners.OnClientFullyConnect(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientFullyConnect listener.

manager = <_listeners.ListenerManager object>
class listeners.OnClientPutInServer(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientPutInServer listener.

manager = <_listeners.ListenerManager object>
class listeners.OnClientSettingsChanged(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ClientSettingsChanged listener.

manager = <_listeners.ListenerManager object>
class listeners.OnCombinerPreCache(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnCombinerPreCache listener.

manager = <_listeners.ListenerManager object>
class listeners.OnConVarChanged(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ConVar listener.

manager = <_listeners.ListenerManager object>
class listeners.OnDataLoaded(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnDataLoaded listener.

manager = <_listeners.ListenerManager object>
class listeners.OnDataUnloaded(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnDataUnloaded listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEdictAllocated(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister an OnEdictAllocated listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEdictFreed(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister an OnEdictFreed listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEntityCreated(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnEntityCreated listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEntityDeleted(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnEntityDeleted listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEntityOutput(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister an EntityOutput listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEntityPreSpawned(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnEntityPreSpawned listener.

manager = <_listeners.ListenerManager object>
class listeners.OnEntitySpawned(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a OnEntitySpawned listener.

manager = <_listeners.ListenerManager object>
class listeners.OnLevelInit(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a LevelInit listener.

manager = <_listeners.ListenerManager object>
class listeners.OnLevelShutdown(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a LevelShutdown listener.

manager = <_listeners.ListenerManager object>
class listeners.OnLevelEnd(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a map end listener.

_level_initialized = True
manager = <_listeners.ListenerManager object>
class listeners.OnNetworkidValidated(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a NetworkidValidated listener.

manager = <_listeners.ListenerManager object>
class listeners.OnButtonStateChanged(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a button state change listener.

manager = <_listeners.ListenerManager object>
class listeners.OnPlayerRunCommand(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a run command listener.

manager = <_listeners.ListenerManager object>
class listeners.OnPluginLoaded(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a plugin loaded listener.

manager = <_listeners.ListenerManager object>
class listeners.OnPluginLoading(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a plugin loading listener.

manager = <_listeners.ListenerManager object>
class listeners.OnPluginUnloaded(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a plugin unloaded listener.

manager = <_listeners.ListenerManager object>
class listeners.OnPluginUnloading(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a plugin unloading listener.

manager = <_listeners.ListenerManager object>
class listeners.OnQueryCvarValueFinished(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister an OnQueryCvarValueFinished listener.

manager = <_listeners.ListenerManager object>
class listeners.OnServerActivate(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a ServerActivate listener.

manager = <_listeners.ListenerManager object>
class listeners.OnTick(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a Tick listener.

manager = <_listeners.ListenerManager object>
class listeners.OnVersionUpdate(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a version update listener.

manager = <_listeners.ListenerManager object>
class listeners.OnServerOutput(callback)[source]

Bases: listeners.ListenerManagerDecorator

Register/unregister a server output listener.

manager = <_listeners.ListenerManager object>
listeners.get_button_combination_status(old_buttons, new_buttons, combination)[source]

Return the status of a button combination.

Parameters:
Returns:

Return the status of the button combination. If the combination was neither pressed nor released, None will be returned.

Return type:

ButtonStatus

Example:

@OnButtonStateChanged
def on_buttons_state_changed(player, old_buttons, new_buttons):
    status = get_button_combination_status(old_buttons, new_buttons,
        PlayerButtons.ATTACK|PlayerButtons.JUMP)

    if status == ButtonStatus.PRESSED:
        SayText2(
            '{} is jumping and attacking.'.format(player.name)).send()

    elif status == ButtonStatus.RELEASED:
        SayText2(
            '{} stopped jumping and attacking at the same time.'.format(
            player.name)).send()