Player

Player

Object representing a player currently connected to the server.

Constructor

new Player(players, data, partial)

Source:
Properties:
Name Type Description
players object

The Players object this belongs to.

partial bool

Whether this object is partial or not. Partial objects are only guaranteed to contain the id property.

id number

ID of the player.

authid string

SteamID of the player.

name string

Name of the player.

ip string

IP address of the player. (without the port)

health number

Amount of health the player has.

gravity number

Gravity of the player.

weapon string

The current weapon the player has equipped. (Example: tf_weapon_scattergun)

kills number

Amount of kills the player currently has.

deaths number

Amount of deaths the player currently has.

team number

Team index of the player. Keep in mind that this is a generic response from the engine and not the game.

connectionTime number

The amount of time (in seconds) the player has been connected to the server. Will be 0 if the player is a bot/fake.

render object

Rendering information about the player (effects, color, etc).

Properties
Name Type Description
color object

Rendering color information

Properties
Name Type Description
r number

Rendering color (red 0-255)

g number

Rendering color (green 0-255)

b number

Rendering color (blue 0-255)

a number

Rendering color (alpha 0-255)

effect number

Rendering effect

mode number

Rendering mode

Parameters:
Name Type Description
players Players

The Players object this belongs to.

data object

Player data sent from the server.

partial bool

Whether this object is partial or not. Defaults to false.

Methods

applyCondition(condition, duration)

Source:

Adds a condition to a player. Team Fortress 2 only. SourceMod API Reference

Parameters:
Name Type Default Description
condition Condition
duration number 0

How long to apply the condition for.

centerHint(message)

Source:

Sends a message to a player's center hint box. Cannot exceed 256 bytes. SourceMod API Reference

Parameters:
Name Type Description
message string

The message to send.

chat(message)

Source:

Sends a message to a player's chatbox. Cannot exceed 256 bytes. SourceMod API Reference

Parameters:
Name Type Description
message string

The message to send.

fetch() → {Object}

Source:

Fetches information about this player from the server. Keep in mind that you must run this function to keep this player up-to-date. Similar to Players.fetch()

Returns:

The new player object with fetched information.

Type
Object

giveWeapon(weapon)

Source:

Gives a player a weapon with custom stats. Team Fortress 2 only! Requires TF2Items.

Parameters:
Name Type Description
weapon Weapon

The weapon object to give.

hint(message)

Source:

Sends a message to a player's hint box. Cannot exceed 256 bytes. SourceMod API Reference

Parameters:
Name Type Description
message string

The message to send.

kick(reason)

Source:

Kicks a player from the server. SourceMod API Reference

Parameters:
Name Type Description
reason string

The reason for the kick. Cannot exceed 256 bytes.

playSound(path)

Source:

Plays a sound. The file path must be a game sound from scripts/game_sound.txt or sound_misc_dir.vpk. Cannot exceed 256 bytes. SourceMod API Reference

Parameters:
Name Type Description
path string

File path to the sound

regenerate()

Source:

Regenerates a player's health and ammo. Team Fortress 2 only! SourceMod API Reference

resetRendering()

Source:

setRendering(r, g, b, a, effect, mode)

Source:

Updates the player's rendering, such as the color and render effects/modes. Every argument is optional, and won't change the value if not provided. SourceMod API Reference (SetEntityRenderColor) SourceMod API Reference (SetEntityRenderFx) SourceMod API Reference (SetEntityRenderMode)

Parameters:
Name Type Description
r number

Rendering color (red 0-255)

g number

Rendering color (green 0-255)

b number

Rendering color (blue 0-255)

a number

Rendering color (alpha 0-255)

effect number

Rendering effect

mode number

Rendering mode

slap(damage)

Source:

Slaps the player, with an optional amount of damage. SourceMod API Reference

Parameters:
Name Type Description
damage number

The amount of damage to deal. Defaults to 0.

teleport(player)

Source:

Teleports a player to another player. SourceMod API Reference

Parameters:
Name Type Description
player Player

The player to teleport to.

update() → {Object}

Source:

Updates the player with new information from Player.fetch(). Used internally.

Returns:

The new player object with fetched information.

Type
Object

Events

chat

Source:

Fires when this player sends a chat message. SourceMod API Reference

Parameters:
Name Type Description
message string

Content of the chat message.

team bool

True if the chat message was a team message, and false otherwise.