EasyPlayer is a custom package for Source.Python, designed to make it easier for plugin developers to interact with player entities.
EasyPlayer's main purpose is the ability to manage "player effects", like burn, freeze, and noclip. Player effects allow you to safely apply effects without having to worry about another plugin using them simultaneously.
Without EasyPlayer, you might run into a scenario where your plugin applies an effect on a player, only to have someone elses plugin immediately cancel the effect:
- Plugin A freezes a player for 2 seconds.
- Plugin B freezes the player for 5 seconds.
- Plugin A unfreezes the player after 2 seconds.
- Plugin B's freeze was cancelled prematurely.
EasyPlayer ensures this doesn't happen, as it checks that all freezes are cancelled before unfreezing the player.
Currently you can call any of the following effects on a player:
player.noclip()
player.freeze()
player.fly()
player.burn()
player.noblock()
player.godmode()
You can pass in a duration as an optional argument to make the effect temporary (as opposed to permanent).
For example, player.noclip(3)
gives a noclip for three seconds.
All of these effect calls return an EffectHandler
instance.
To remove an infinite effect, or to prematurely cancel an effect with a duration,
store the returned instance and call .cancel()
on it:
freeze = player.freeze(duration=10) # Keywording is optional!
freeze.cancel() # Cancel manually before duration has ended
Keep in mind that none of these function calls interfere with each other,
so calling .cancel()
might not unfreeze the player completely; the player might still be frozen by another effect.
EasyPlayer also provides additional helper functions and features to make player entity usage seamless:
- Automatically resets most attributes like gravity and color on death.
- Implements
shift_property(prop_name, shift[, duration])
to shift a numeric property by the providedshift
. - Allows custom effects to be created on a subclass by using the
PlayerEffect
class. See how to use it at the bottom of theeasyplayer/player.py
file. - Implements
hip_location
,stomach_location
, andchest_location
for the player.
To install EasyPlayer onto your game server:
- Make sure you have Source.Python installed.
- Download it from the releases page.
- Extract the
addons
folder into your game's directory (e.g.csgo
). - Restart your game server.
To use EasyPlayer in your plugins:
- Import it using
from easyplayer import EasyPlayer
. - Use it like you would use Source.Python's
players.entity.Player
class.