Skip to content

Mahi/EasyEvents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

EasyEvents

EasyEvents is a custom package for Source.Python, designed to make it easier for plugin developers to interact with events.

Usage

EasyEvents provides an EasyEvents class to manage both game events and custom events in an easy and uniform manner. It simplifies Source.Python's event management by replacing all the userids with instances of Player entity or its subclass. In other words, your event listeners will receive your player objects as arguments.

from easyevents import EasyEvents

player_dict = PlayerDictionary(MyPlayer)
events = EasyEvents(player_dict)

@events.on('player_kill')
def on_player_kill(player, victim, **eargs):  # You can pick any arguments from the event args ("eargs")
    assert type(player) == MyPlayer
    print(victim.my_custom_attribute)  # No userids, no index conversions

You can easily create and fire custom events, or even fire pre-created events:

events.create_event('my_custom_event')

events['my_custom_event'].fire(player=my_player, some_argument='some value')
events['player_jump'].fire(player=my_player)

You can also listen to multiple events at once:

@events.on('player_jump', 'my_custom_event')
def on_multiple_events(player, **eargs):
    print(f'Player {player.name} did something!')

Or better yet, use the named keyword argument to receive the event's name as an argument:

@events.on('player_jump', 'my_custom_event', named=True)
def on_multiple_events(event_name, player, **eargs):
    print(f'Player {player.name} did {event_name}!')

Installation

To install EasyEvents onto your game server:

  1. Make sure you have Source.Python installed.
  2. Download it from the releases page.
  3. Extract the addons folder into your game directory (e.g. csgo).
  4. Restart your game server.

About

Advanced events package for Source.Python

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages