sourcemod.clients — Client manipulation.

Module Contents

sourcemod.clients.BANFLAG_AUTO
Auto-detects whether to ban by steamid or IP
sourcemod.clients.BANFLAG_IP
Always ban by IP
sourcemod.clients.BANFLAG_AUTHID
Always ban by authstring (Steam ID) if possible
sourcemod.clients.BANFLAG_NOKICK
Does not kick the client
sourcemod.clients.create_fake_client(name)

Creates a fake client.

Parameter:name (str) – The name to assign to the fake client
Return type:Client
Returns:A valid Client Object on success, None otherwise.
sourcemod.clients.get_client(index)

Retrieves the Client object with that client index.

Parameter:index (int) – The client index
Return type:Client
Returns:A valid Client object on success, None if an invalid client index.
sourcemod.clients.get_client_count([in_game_only=True])

Returns the number of clients put in the server.

Parameter:in_game_only (bool) – If False, players currently connecting are also counted.
Return type:int
sourcemod.clients.get_client_from_serial(serial)

Retrieves a Client by their serial number.

Parameter:serial (int) – The Client‘s serial number
Return type:Client
Returns:A valid Client object on success, None if an invalid client serial.
sourcemod.clients.get_client_from_userid(userid)

Translates a userid index into a Client object

Parameter:userid (int) – Userid value
Return type:Client
Returns:A valid Client object on success, None if an invalid userid.
sourcemod.clients.get_max_clients()
Returns the maximum number of clients allowed on the server. This may return 0 if called before the global forward on_map_start.

Client Objects

Client.fake_command(cmd)

Executes a client command on the server without being networked.

Parameter:cmd (str) – The command string to execute.
Client.is_timing_out()
Returns if the client is timing out.
Client.kick([msg=""[, delay=True]])

Disconnects a player from the server.

Parameters:
  • msg (str) – A message to show the user as a disconnect reason. Note that a period is automatically appended to the message by the engine.
  • delay (bool) – If True, the client is kicked in the next game frame. If False, the client is kicked immediately. The delay exists to prevent accidental engine crashes.
Return type:

bool

Returns:

True on successful kick, False if the player is already in the kick queue.

Client.notify_post_admin_check()
Signals that a player has completed post-connection admin checks. Has no effect if the player has already had this event signalled. Note: This must be sent even if no admin id was assigned.
Client.print_center(message)

Prints a message to this client in the center of the screen.

Parameter:message (str) – The message to print.
Client.print_chat(message)

Prints a message to this client’s chat area.

Parameter:message (str) – The message to print.
Client.print_console(message)

Prints a message to this client’s console.

Parameter:message (str) – The message to print.
Client.print_hint(message)

Prints a message to this client inside a hint box.

Parameter:message (str) – The message to print.
Client.set_fake_client_convar(convar, value)

Sets a convar value on a fake client.

Parameters:
  • convar (str) – The ConVar’s name
  • value (str) – The value to set the ConVar to.
Client.show_vgui_panel(name[, kv=None[, show=True]])

Show a VGUI panel to the client.

Parameters:
  • name (str) – Panel type name (see viewport_panel_names.h for a list of panel names)
  • kv (KeyValues) – A KeyValues with all the data for the panel setup. The data inside the KeyValues depends on the panel type.
  • show (bool) – True to show the panel, or False to remove it from the client’s screen.

Attributes

Client.abs_angles

The client’s angles vector.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.abs_origin

The client’s origin vector.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.alive

Whether the client is alive or dead.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.avg_choke

The client’s average packet choke. Value is a percentage ranging from 0.0 to 1.0

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_choke_in

The client’s average incoming packet choke. Value is a percentage ranging from 0.0 to 1.0.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_choke_out

The client’s average outgoing packet choke. Value is a percentage ranging from 0.0 to 1.0.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_data

The client’s data flow, incoming and outgoing, in bytes per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.avg_data_in

The client’s incoming data flow in bytes per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.avg_data_out

The client’s outgoing data flow in bytes per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.avg_latency

The client’s average packet latency, both incoming and outgoing, in seconds.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_latency_in

The client’s average incoming packet latency in seconds.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_latency_out

The client’s average outgoing packet latency in seconds.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_loss

The client’s average packet loss. Value is a percentage ranging from 0.0 to 1.0.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_loss_in

The client’s average incoming packet loss. Value is a percentage ranging from 0.0 to 1.0.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_loss_out

The client’s average outgoing packet loss. Value is a percentage ranging from 0.0 to 1.0.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_packets

The client’s average packet frequency, incoming and outgoing, in packets per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_packets_in

The client’s average incoming packet frequency, in packets per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.avg_packets_out

The client’s average outgoing packet frequency, in packets per second.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.data_rate

The client’s send date rate in bytes per second

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.deaths

The player’s death count.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.entity
The Entity of the Client.
Client.fake

Whether the client is fake or not.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.frags

The player’s frag count.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.health

The health of the player.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.ip

The IP address of this client.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.lang_id

The client’s language ID as an int.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.latency

The client’s packet latency (RTT), both incoming and outgoing, in seconds. This is more accurate than the average latency, but jittery.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.latency_in

The client’s incoming packet latency (RTT) in seconds. This is more accurate than the average latency, but jittery.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.latency_out

The client’s outgoing packet latency (RTT) in seconds. This is more accurate than the average latency, but jittery.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.maxs

The client’s max size vector.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.mins

The client’s min size vector.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.model

The client’s model name.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.
Client.name

The name of this client.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.serial
The client’s unique serial identifier.
Client.steamid

The Steam ID of this client. This is None when the client is not authorized, yet.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.team

The player’s team.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, no mod support, or client not in-game.
Client.time_connected

The amount of time the client has been connected in seconds.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or client is a fake client.
Client.userid

The userid of this client.

Raises sourcemod.ViperError:
 Invalid client or client not connected.
Client.weapon

The player’s weapon name.

Raises sourcemod.ViperError:
 Invalid client, client not in-game, or no mod support.

Table Of Contents

Previous topic

sourcemod — The standard Viper library

Next topic

sourcemod.console — Console interaction.

This Page