Constructor
new Player(players, data, partial)
Properties:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
players |
object | The |
|||||||||||||||||||||||||||
partial |
bool | Whether this object is partial or not. Partial objects are only guaranteed to contain the |
|||||||||||||||||||||||||||
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: |
|||||||||||||||||||||||||||
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
|
Parameters:
Name | Type | Description |
---|---|---|
players |
Players | The |
data |
object | Player data sent from the server. |
partial |
bool | Whether this object is partial or not. Defaults to false. |
Methods
applyCondition(condition, duration)
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)
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)
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}
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)
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)
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)
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)
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()
Regenerates a player's health and ammo. Team Fortress 2 only! SourceMod API Reference
resetRendering()
Resets the player's rendering color/effect/mode. SourceMod API Reference (SetEntityRenderColor) SourceMod API Reference (SetEntityRenderFx) SourceMod API Reference (SetEntityRenderMode)
setRendering(r, g, b, a, effect, mode)
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)
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)
Teleports a player to another player. SourceMod API Reference
Parameters:
Name | Type | Description |
---|---|---|
player |
Player | The player to teleport to. |
update() → {Object}
Updates the player with new information from Player.fetch()
. Used internally.
Returns:
The new player object with fetched information.
- Type
- Object
Events
chat
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. |