Player

Summary

A server player. Represents a server-side player instance.

Properties

Methods

MethodReturns
SetTeam(team: integer)void
SetWeapon(weaponName: string)void
GetWeapon()DataContainer
SetScore(amount: integer)void
SetKills(amount: integer)void
SetAssists(amount: integer)void
SetDeaths(amount: integer)void
SetBattlepoints(amount: integer)void
GiveBattlepoints(amount: integer)void
SetCustomizationAsset(assetName: string)void
SetUnlock(assetGuid: string, grant: boolean)void
Kick(reason: string)void
SetInvisible(invisible: boolean)void
SetHealth(amount: integer)void
SetMaxHealth(amount: integer)void
SetAbility(abilityId: integer)void
ForceSendChatMessage(channel: integer, message: string)void
SendChatMessage(message: string)void
SetInputEnabled(actionId: integer, enabled: boolean)void
SendSyncedSettings()void
SetImmortal(isImmortal: boolean)void
SetFakeImmortal(isFakeImmortal: boolean)void
SetExplosionDamageModifier(modifier: number)void
SetMoveSpeedMultiplier(modifier: number)void
SetCooldownModifier(modifier: number)void

Properties


name

string

Player's username.


playerId

integer

Player's EA player id.


team

integer

Player's current team.


battlepoints

integer

Player's battlepoint count.


score

integer

The player's current score.


kills

integer

The player's current kill count.


assists

integer

The player's current assist count.


deaths

integer

The player's current death count.


afkTime

number

How long it has been since the player has inputted anything in seconds.


characterEntity

Entity

The character entity the player is currently occupying, or nil if not spawned on foot.


vehicleEntity

Entity

The vehicle entity the player is currently occupying, or nil if not in a vehicle.


activeKit

DataContainer

The active kit/loadout asset for the player, or nil if none is set.


isBot

boolean

If player is a bot.


isAlive

boolean

If player is actively spawned as a character or vehicle.


Methods

SetTeam

Player:SetTeam(team: integer): void

Sets the player's team.

Parameters

NameTypeDescription
teamintegerThe team id to set.

SetWeapon

Player:SetWeapon(weaponName: string): void

Sets the player's primary weapon by asset name. Does nothing if the player has no soldier extent or the asset cannot be found.

Parameters

NameTypeDescription
weaponNamestringThe resource name of the weapon asset to equip.

GetWeapon

Player:GetWeapon(): DataContainer

Returns the player's currently equipped primary weapon as a DataContainer asset. Returns nothing if the player has no soldier extent or no weapon assigned.

Returns

TypeDescription
DataContainerweapon The weapon asset.

SetScore

Player:SetScore(amount: integer): void

Sets the player's score to an exact amount.

Parameters

NameTypeDescription
amountintegerThe score value to set.

SetKills

Player:SetKills(amount: integer): void

Sets the player's kill count to an exact amount.

Parameters

NameTypeDescription
amountintegerThe kill count to set.

SetAssists

Player:SetAssists(amount: integer): void

Sets the player's assist count to an exact amount.

Parameters

NameTypeDescription
amountintegerThe assist count to set.

SetDeaths

Player:SetDeaths(amount: integer): void

Sets the player's death count to an exact amount.

Parameters

NameTypeDescription
amountintegerThe death count to set.

SetBattlepoints

Player:SetBattlepoints(amount: integer): void

Sets player's battlepoints.

Parameters

NameTypeDescription
amountintegerThe amount desired.

GiveBattlepoints

Player:GiveBattlepoints(amount: integer): void

Give player battlepoints

Parameters

NameTypeDescription
amountintegerThe amount desired.

SetCustomizationAsset

Player:SetCustomizationAsset(assetName: string): void

[EXPERIMENTAL] Sets the player's customization asset by resource name. Does nothing if the asset cannot be found.

Parameters

NameTypeDescription
assetNamestringThe resource name of the customization asset.

SetUnlock

Player:SetUnlock(assetGuid: string, grant: boolean): void

Grants or revokes a specific unlock on the player by GUID string. Does nothing if the GUID string or boolean argument is missing.

Parameters

NameTypeDescription
assetGuidstringThe string representation of the unlock's GUID.
grantbooleantrue to grant the unlock, false to revoke it.

Kick

Player:Kick(reason: string): void

Kick server player from the server.

Parameters

NameTypeDescription
reasonstringSet reason for the kick.

SetInvisible

Player:SetInvisible(invisible: boolean): void

Sets the player's character entity visibility. Does nothing if the player has no character entity.

Parameters

NameTypeDescription
invisiblebooleantrue to force the player invisible, false to restore visibility.

SetHealth

Player:SetHealth(amount: integer): void

Sets the player's current health value. Does nothing if the player has no character entity or health component.

Parameters

NameTypeDescription
amountintegerThe health value to set.

SetMaxHealth

Player:SetMaxHealth(amount: integer): void

Sets the player's maximum health value. Only works if the player's health component is a WSServerSoldierHealthComponent. Does nothing if the player has no character entity or the health component is of an incompatible type.

Parameters

NameTypeDescription
amountintegerThe maximum health value to set.

SetAbility

Player:SetAbility(abilityId: integer): void

Sets the player's character (notably not vehicle) active ability by ability ID. Does nothing if the ability asset cannot be loaded for the given ID.

Parameters

NameTypeDescription
abilityIdintegerThe ID of the ability to assign.

ForceSendChatMessage

Player:ForceSendChatMessage(channel: integer, message: string): void

Forces the player to send a chat message on a specified channel.

Parameters

NameTypeDescription
channelintegerThe chat channel ID (maps to ChatChannel enum).
messagestringThe message content to send.

SendChatMessage

Player:SendChatMessage(message: string): void

Sends chat message to the player.

Parameters

NameTypeDescription
messagestringThe message content to send.

SetInputEnabled

Player:SetInputEnabled(actionId: integer, enabled: boolean): void

Enables or disables a specific input action for the player.

Parameters

NameTypeDescription
actionIdintegerThe ID of the input action to control.
enabledbooleantrue to enable the input, false to disable it.

SendSyncedSettings

Player:SendSyncedSettings(): void

Resends synced game settings to the player's connection. Useful after modifying server-side settings that need to be re-synced to the client.

SetImmortal

Player:SetImmortal(isImmortal: boolean): void

Set if the player's character (notably not vehicle) is damageable.

Parameters

NameTypeDescription
isImmortalboolean

SetFakeImmortal

Player:SetFakeImmortal(isFakeImmortal: boolean): void

Set if the player's character (notably not vehicle) is fake damageable.

Parameters

NameTypeDescription
isFakeImmortalboolean

SetExplosionDamageModifier

Player:SetExplosionDamageModifier(modifier: number): void

Set how much the player's character (notably not vehicle) takes explosion damage

Parameters

NameTypeDescription
modifiernumberThe value multiplied with the damage.

SetMoveSpeedMultiplier

Player:SetMoveSpeedMultiplier(modifier: number): void

Set how fast the player's character (notably not vehicle) is.

Parameters

NameTypeDescription
modifiernumberThe value to set.

SetCooldownModifier

Player:SetCooldownModifier(modifier: number): void

Sets the player's character (notably not vehicle) total cooldown timer is. Higher values is slower, lower values is faster.

Parameters

NameTypeDescription
modifiernumberThe value to set.