Skip to main content

Player

To simplify plugin development, we combined two entities from the Source 2 engine - PlayerController and PlayerPawn into a single Player class. Every player, attacker and assister event object properties will return the Player class.

Player class

Currently, this class contains the following methods and properties.

Properties

nametyperead-onlydescription
namestringtruePlayer name
steamIdnumbertrueSteamId 32 (bot = 0)
slotnumbertruePlayer slot number
hpnumberfalse
steamId64string/0trueSteamId 64 as string or 0 if it's a bot
isBotbooleantrue
isAlivestring/0true
isConnectedbooleantrue
isConnectingbooleantrue
isReconnectingbooleantrue
isDisconnectingbooleantrue
iSDisconnectedbooleantrue
isReservedbooleantrue
teamnumbertrue
currentWeaponWeapontruei.e weapon_ak47 (as Enum if ts)
statsStatsfalse
moneynumberfalse
armornumberfalse

Stats class

nametyperead-only
_slotnumbertrue
damagenumberfalse
killsnumberfalse
assistsnumberfalse
deathsnumberfalse

to change player stats you can modify stats object inside player class.

event.player.stats.kills = 100;
event.player.stats.deaths = 0;

Methods

nameparametersdescription
slap(hp: number)Slap play on hp value
slayKill player
respawnRespawn player, works only if a player is alive
changeTeam(team: number, kill: boolean)Change player team, team is a constant number of the selected team
say(message: string)Print message to a player in chat
hint(message: string)Print message to a player in players hint
setModel(path: string)Set the player model, models have to be precached.
setColor(color: Color)Color is a class with RGBA constructor
playSound(path: string)Emits player console command play %path%
kickKick player.
giveWeapon(weapon: Weapon)Give player a weapon (accept an enum Weapon)
dropWeapon(remove: boolean = false)Drop current weapon. If remove is true - it will remove the weapon from map after it dropped.