players._base module

Provides a class used to interact with a specific player.

class players._base.Player(index)[source]

Bases: entities._base.Entity, _players.PlayerMixin

Class used to interact directly with players.

__init__(index)[source]

Initialize the object.

Parameters:index (int) – A valid player index.
Raises:ValueError – Raised if the index is invalid.
ban(duration=0, kick=True, write_ban=True)[source]

Ban a player from the server.

Parameters:
  • duration (int) – Duration of the ban in minutes. Use 0 for permament.
  • kick (bool) – If True, the player will be kicked as well.
  • write_ban (bool) – If True, the ban will be written to cfg/banned_users.cfg.
client_command(command, server_side=False)[source]

Execute a command on the client.

Parameters:
  • command (str) – The command to execute.
  • server_side (bool) – If True the command will be emulated by the server.
classmethod from_userid(userid)[source]

Create an instance from a userid.

Parameters:userid (int) – The userid.
Return type:Player
get_active_weapon()[source]

Return the player’s active weapon.

Returns:None if the player does not have an active weapon.
Return type:Weapon
get_flashlight()[source]

Return whether or not the flashlight of the player is turned on.

Return type:bool
get_frozen()[source]

Return whether frozen mode is enabled.

Return type:bool
get_godmode()[source]

Return whether god mode is enabled.

Return type:bool

Todo

Add m_takedamage to the data files. Which name do we want to use? We can’t use take_damage.

get_jetpack()[source]

Return whether jetpack mode is enabled.

Return type:bool
get_name()[source]

Return the player’s name.

Return type:str
get_noblock()[source]

Return whether noblock mode is enabled.

Return type:bool
get_noclip()[source]

Return whether noclip mode is enabled.

Return type:bool
get_projectile_ammo(projectile)[source]

Return the player’s ammo value of the given projectile.

Parameters:projectile (str) – The name of the projectile to get the ammo of.
Return type:int
get_stuck()[source]

Return whether stuck mode is enabled.

Return type:bool
get_team()[source]

Return the player’s team.

Return type:int
get_trace_ray(mask=<ContentMasks.ALL: 4294967295>, trace_filter=None)[source]

Return the player’s current trace data.

Parameters:
Return type:

GameTrace

get_view_angle()[source]

Return the player’s view angle.

Return type:QAngle
get_view_coordinates()[source]

Return the coordinates the player is currently looking at.

Return None if the player is not looking at anything.

Return type:Vector
get_view_entity()[source]

Return the entity that the player is looking at.

Return None if the player is not looking at an entity.

Return type:Entity
get_view_player()[source]

Return the player that the player is looking at.

Return None if the player is not looking at a player.

Return type:Player
get_weapon(classname=None, is_filters=None, not_filters=None)[source]

Return the first found weapon for the given arguments.

Return type:Weapon
has_c4()[source]

Raise an error because this method is game specific.

is_bot()[source]

Return whether the player is a bot.

Return type:bool
is_connected()[source]

Return whether the player is connected.

Return type:bool
is_fake_client()[source]

Return whether the player is a fake client.

Return type:bool
is_hltv()[source]

Return whether the player is HLTV.

Return type:bool
is_in_a_vehicle()[source]

Return whether the player is in a vehicle.

Return type:bool
is_muted(receivers=None)[source]

Return True if the player is currently muted.

See players.voice.mute_manager.is_muted for more information.

is_observer()[source]

Return whether the player is an observer.

Return type:bool
is_weapon_restricted(weapon)[source]

Return whether the player is restricted from the given weapon.

Parameters:weapon (str) – The name of the weapon to check against restriction.
Return type:bool
kick(message='')[source]

Kick the player from the server.

Parameters:message (str) – A message the kicked player will receive.
mute(receivers=None)[source]

Mute the player.

See players.voice.mute_manager.mute_player for more information.

play_sound(sample, volume=1.0, attenuation=<Attenuation.NONE: 0.0>, channel=_engines._sound.Channel.AUTO, flags=_engines._sound.SoundFlags.NO_FLAGS, pitch=_engines._sound.Pitch.NORMAL, origin=Vector(0.0, 0.0, 0.0), direction=Vector(0.0, 0.0, 0.0), origins=(), update_positions=True, sound_time=0.0, speaker_entity=-1, download=False, stream=False)[source]

Play a sound to the player.

Parameters:
  • sample (str) – Sound file relative to the sounds directory.
  • volume (float) – Volume of the sound.
  • attenuation (Attenuation) – How far the sound should reaches.
  • channel (int) – Channel to emit the sound with.
  • flags (SoundFlags) – Flags of the sound.
  • pitch (Pitch) – Pitch of the sound.
  • origin (Vector) – Origin of the sound.
  • direction (Vector) – Direction of the sound.
  • origins (tuple) – Origins of the sound.
  • update_positions (bool) – Whether or not the positions should be updated.
  • sound_time (float) – Time to play the sound for.
  • speaker_entity (int) – Index of the speaker entity.
  • download (bool) – Whether or not the sample should be added to the downloadables.
  • stream (bool) – Whether or not the sound should be streamed.
projectile_indexes(projectile)[source]

Yield all indexes of the given projectile for the player.

Parameters:projectile (str) – The name of the projectile to find indexes of.
push(horiz_mul, vert_mul, vert_override=False)[source]

Push the player along his view vector.

Parameters:
  • horiz_mul (float) – Horizontal multiplier.
  • vert_mul (float) – Vertical multiplier.
  • vert_override (bool) – If True, vert_mul will be used as a static value and not as a multiplier.
restrict_weapons(*weapons)[source]

Restrict the weapon for the player.

Parameters:weapons (str) – A weapon or any number of weapons to add as restricted for the player.
say(message)[source]

Force the player to say something in the global chat.

Parameters:message (str) – The text the player should say.
say_team(message)[source]

Force the player to say something in the team chat.

Parameters:message (str) – The text the player should say.
send_convar_value(cvar_name, value)[source]

Send a convar value.

Parameters:
  • cvar_name (str) – Name of the convar.
  • value (str) – Value to send.
set_active_weapon(weapon)[source]

Set the player’s active weapon.

Parameters:weapon (Weapon) – The weapon to set as active.
set_eye_location(eye_location)[source]

Set the player’s eye location.

set_flashlight(enable)[source]

Turn on/off the flashlight of the player.

Parameters:enable (bool) – True to turn on, False to turn off.
set_frozen(enable)[source]

Enable/disable frozen mode.

Frozen mode makes the player unable to move, look and shoot.

Parameters:enable (bool) – If True frozen mode will be enabled.
set_godmode(enable)[source]

Enable/disable god mode.

Godmode makes the player invulnerable.

Parameters:enable (bool) – If True god mode will be enabled.

Todo

Add m_takedamage to the data files. Which name do we want to use? We can’t use take_damage.

set_jetpack(enable)[source]

Enable/disable jetpack mode.

Jetpack mode gives the player the ability to use a jetpack.

Parameters:enable (bool) – If True jetpack mode will be enabled.
set_name(name)[source]

Set the player’s name.

set_noblock(enable)[source]

Enable/disable noblock mode.

Noblock mode assigns a new collision group to the player that doesn’t block other players. That means players can run through each other.

Parameters:enable (bool) – If True noblock mode will be enabled.
set_noclip(enable)[source]

Enable/disable noclip mode.

Noclip mode gives the player the ability to fly through the map.

Parameters:enable (bool) – If True noclip mode will be enabled.
set_projectile_ammo(projectile, value)[source]

Set the player’s ammo value for the given projectile.

Parameters:
  • projectile (str) – The name of the projectile to set the ammo of.
  • value (int) – The value to set the projectile’s ammo to.
set_stuck(enable)[source]

Enable/disable stuck mode.

Stuck mode forces the player to stay exactly at his current position even if he is currently in the air. He’s still able to look and shoot.

Parameters:enable (bool) – If True stuck mode will be enabled.
set_team(value)[source]

Set the players team.

set_view_angle(angle)[source]

Set the player’s view angle.

set_view_coordinates(coords)[source]

Force the player to look at the given coordinates.

Parameters:coords (Vector) – The coordinates the player should look at.
set_view_entity(entity)[source]

Force the player to look at the origin of the given entity.

Parameters:entity (Entity) – The entity the player should look at.
set_view_player(player)[source]

Force the player to look at the other player’s eye location.

Parameters:player (Player) – The other player.
slay()[source]

Slay the player.

spawn(force=False)[source]

Spawn the player.

Parameters:force (bool) – Whether or not the spawn should be forced.
unmute(receivers=None)[source]

Unmute the player.

See players.voice.mute_manager.unmute_player for more information.

unrestrict_weapons(*weapons)[source]

Restrict the weapon for the player.

Parameters:weapons (str) – A weapon or any number of weapons to remove as restricted for the player.
weapon_indexes(classname=None, is_filters=None, not_filters=None)[source]

Iterate over the player’s weapon indexes for the given arguments.

Returns:A generator of indexes.
Return type:generator
weapons(classname=None, is_filters=None, not_filters=None)[source]

Iterate over the player’s weapons for the given arguments.

Returns:A generator of weapons.entity.Weapon objects.
Return type:generator
active_weapon

Return the player’s active weapon.

Returns:None if the player does not have an active weapon.
Return type:Weapon
address

Return the player’s IP address and port.

If the player is a bot, an empty string will be returned.

Returns:The IP address. E.g. ‘127.0.0.1:27015’
Return type:str
base_client

Return the player’s base client instance.

Return type:BaseClient
client

Return the player’s client instance.

Return type:Client
drop_weapon

Drop a weapon.

Parameters:
  • weapon (Pointer) – Weapon to drop.
  • target (Vector) – Target location to drop the weapon at.
  • velocity (Vector) – Velocity to use to drop the weapon.
eye_location
get_eye_location( (BaseEntity)arg1) -> Vector :

Return the entitiy’s eye location.

rtype:Vector
flashlight

Return whether or not the flashlight of the player is turned on.

Return type:bool
frozen

Return whether frozen mode is enabled.

Return type:bool
godmode

Return whether god mode is enabled.

Return type:bool

Todo

Add m_takedamage to the data files. Which name do we want to use? We can’t use take_damage.

jetpack

Return whether jetpack mode is enabled.

Return type:bool
language

Return the player’s language.

If the player is a bot, an empty string will be returned.

Return type:str
name

Return the player’s name.

Return type:str
noblock

Return whether noblock mode is enabled.

Return type:bool
noclip

Return whether noclip mode is enabled.

Return type:bool
permissions

Return the player’s permissions.

Return type:PlayerPermissions
playerinfo

Return player information.

Return type:PlayerInfo
primary

Return the player’s primary weapon.

Return type:Weapon
raw_steamid

Return the player’s unformatted SteamID.

Return type:SteamID
secondary

Return the player’s secondary weapon.

Return type:Weapon
spectators

Return all players observing this player.

Returns:The generator yields players.entity.Player objects.
Return type:generator
steamid

Return the player’s SteamID.

Return type:str
stuck

Return whether stuck mode is enabled.

Return type:bool
team

Return the player’s team.

Return type:int
uniqueid

Return the player’s unique ID.

Return type:str
userid

Return the player’s userid.

Return type:int
view_angle

Return the player’s view angle.

Return type:QAngle
view_coordinates

Return the coordinates the player is currently looking at.

Return None if the player is not looking at anything.

Return type:Vector
view_entity

Return the entity that the player is looking at.

Return None if the player is not looking at an entity.

Return type:Entity
view_player

Return the player that the player is looking at.

Return None if the player is not looking at a player.

Return type:Player
class _players.PlayerMixin

Bases: _entities._entity.BaseEntity

__init__((object)arg1, (int)entity_index) → object
active_devices

Get/set the player’s active devices.

Note

Only available in HL2.

Return type:int
active_weapon_handle

Get/set the player’s active weapon_handle.

Return type:int
armor

Get/set the player’s armor.

Note

Only available in CS:GO and CS:S.

Return type:int
buttons

Get/set the player’s currently pressed buttons.

Return type:float
cash

Get/set the player’s cash.

Note

Only available in CS:GO and CS:S.

Return type:int
dead

Return whether the player is dead.

Return type:bool
deaths

Get/set the player’s death count.

Return type:int
default_fov

Get/set the player’s default field of view (FOV).

Return type:int
desired_player_class

Get/set the player’s desired player class.

Note

Only available in TF2.

Return type:int
draw_view_model

Get/set the player’s draw view model.

Return type:int
eye_angle

Get/set the player’s eye angle.

Return type:QAngle
fall_velocity

Get/set the player’s fall velocity.

Return type:float
flags

Get/set the player’s flags.

Return type:int
flash_alpha

Get/set the player’s flash alpha.

Note

Only available in CS:GO and CS:S.

Return type:int
flash_duration

Get/set the player’s flash duration.

Note

Only available in CS:GO and CS:S.

Return type:int
fov

Get/set the player’s field of view (FOV).

Return type:int
fov_rate

Get/set the player’s field of view (FOV) rate.

Return type:float
fov_start

Get/set the player’s field of view (FOV) start.

Return type:int
fov_time

Get/set the player’s field of view (FOV) time.

Return type:float
gun_offset

Get/set the player’s gun offset.

Return type:Vector
has_defuser

Get/set whether the player has a defuser.

Note

Only available in CS:GO and CS:S.

Return type:bool
has_helmet

Get/set whether the player has a helmet.

Note

Only available in CS:GO and CS:S.

Return type:bool
hidden_huds

Get/set the player’s hidden HUDs.

Return type:int
in_bomb_zone

Get/set whether the player is in a bomb zone.

Note

Only available in CS:GO and CS:S.

Return type:bool
in_buy_zone

Get/set whether the player is in a buy zone.

Note

Only available in CS:GO and CS:S.

Return type:bool
in_rescue_zone

Get/set whether the player is in a hostage rescue zone.

Note

Only available in CS:GO and CS:S.

Return type:bool
is_defusing

Get/set whether the player is currently defusing the bomb.

Note

Only available in CS:GO and CS:S.

Return type:bool
is_ducked

Return whether the player is ducked.

Return type:bool
is_ducking

Return whether the player is duckeding.

Return type:bool
kills

Get/set the player’s kill count.

Return type:int
last_hitgroup

Get/set the player’s last hitgroup.

Return type:int
last_weapon

Get/set the player’s last weapon.

Return type:int
life_state

Get/set the player’s life state.

Return type:int
nightvision_on

Get/set whether the player is currently using nightvision.

Note

Only available in CS:GO and CS:S.

Return type:bool
observer_mode

Get/set the player’s observer mode.

Return type:int
observer_target

Get/set the player’s observer target.

Return type:int
phys_damage_scale

Get/set the player’s physical damage scale.

Return type:float
place

Get/set the player’s current place.

Return type:str
player_class

Get/set the player’s player class.

Return type:int
player_state

Get/set the player’s player state.

Return type:int
ragdoll

Get/set the player’s ragdoll.

Return type:int
relationship

Get/set the player’s relationship.

Return type:str
shots_fired

Get/set the the number of shots fired by the player.

Note

Only available in CS:GO and CS:S.

Return type:int
speed

Get/set the player’s speed.

Return type:float
stamina

Get/set the player’s stamina.

Note

Only available in CS:GO and CS:S.

Return type:float
suit_power_load

Get/set the player’s suit power load.

Note

Only available in HL2.

Return type:float
view_angle

Get/set the player’s view angle.

Return type:QAngle
view_offset

Get/set the player’s view offset.

Return type:Vector
view_vector

Get/set the player’s view vector.

Return type:Vector