Ir para o conteúdo principal
Version: latest - a1.172.0 ⚖️

👩‍💻 Player

Players are Entities that represents the individual behind the mouse and keyboard. Players are spawned automatically when connected to the server

👪Inheritance
This class shares methods and events from Base Entity.

Autoridade

🟥 You cannot spawn or Destroy Players.

🎒 Examples​

Server/Index.lua
-- Spawns and possess a Character when a Player joins the server
Player.Subscribe("Spawn", function(player)
local new_char = Character(Vector(), Rotator(), "nanos-world::SK_Male")
player:Possess(new_char)
end)

-- Destroys the Character when the Player leaves the server
Player.Subscribe("Destroy", function(player)
local character = player:GetControlledCharacter()
if (character) then
character:Destroy()
end
end)

🗿 Static Functions​

Account
GetBySteamID: Player or nilRetrieves a player by their Steam ID

Inherited static functions

Accountstatic functions​

GetBySteamIDSlow​

Retrieves a player by their Steam ID

local player = Player.GetBySteamID(steam_id)
Parameters
NameTypeDescrição
steam_idstringThe Steam ID (SteamID64) to look for
Returns
TypeDescrição
Player or nilPlayer by their Steam ID

🦠 Functions​

Account
GetAccountIconURL: stringReturn a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)
GetAccountID: stringGets the Player's nanos world account ID
GetAccountName: stringGets the Player's nanos world account name
GetName: stringGets the Player's name
GetSteamID: stringGets the Player's Steam ID
SetNameSets the player's name
Audio
GetVOIPAmplitude: floatReturns how loud this player is talking right now
GetVOIPGlobalHighPassFilter: integerReturns the global VOIP high-pass filter threshold frequency
GetVOIPGlobalLowPassFilter: integerReturns the global VOIP low-pass filter threshold frequency
GetVOIPGlobalVolume: floatReturns the global VOIP volume
GetVOIPListeningChannels: table of integerReturns a list of VOIP channels this player is listening to
GetVOIPLocalAttenuation: integer, AttenuationFunctionReturns how the local/proximity VOIP fades with distance
GetVOIPLocalHighPassFilter: integerReturns the local/proximity VOIP high-pass filter threshold frequency
GetVOIPLocalLowPassFilter: integerReturns the local/proximity VOIP low-pass filter threshold frequency
GetVOIPLocalMaxDistance: integerReturns the local/proximity VOIP max distance
GetVOIPLocalOcclusion: boolean, integer, floatReturns the automatic occlusion settings of the local/proximity VOIP
GetVOIPLocalVolume: floatReturns the local/proximity VOIP volume
GetVOIPSpeakingChannels: table of integerReturns a list of VOIP channels this player is currently speaking to
IsVOIPMuted: booleanReturns whether VOIP is muted for this player
SetVOIPGlobalAllChannelsSettingSets the VOIP setting for all global channels
SetVOIPGlobalChannelSettingSets the VOIP setting for a specific global channel
SetVOIPGlobalHighPassFilterSets the global VOIP high-pass filter threshold frequency
SetVOIPGlobalLowPassFilterSets the global VOIP low-pass filter threshold frequency
SetVOIPGlobalVolumeSets the global VOIP volume. It only affects the global channels
SetVOIPLocalAttenuationSets how the local/proximity VOIP fades with distance
SetVOIPLocalHighPassFilterSets the local/proximity VOIP high-pass filter threshold frequency
SetVOIPLocalLowPassFilterSets the local/proximity VOIP low-pass filter threshold frequency
SetVOIPLocalMaxDistanceSets the local/proximity VOIP max distance. This also affects networking usage
SetVOIPLocalOcclusionConfigures the automatic occlusion of the local/proximity VOIP
SetVOIPLocalSettingSets the VOIP setting for the local/proximity
SetVOIPLocalVolumeSets the local/proximity VOIP input/output volume. It only affects the local/proximity channel
SetVOIPMutedMutes or unmutes VOIP for this player
Camera
AttachCameraToAttaches the Player's Camera to an Actor
GetCameraArmLength: floatGets the Player's camera arm (spring arm) length
GetCameraLocation: VectorGets the location of the Player's camera
GetCameraRotation: RotatorGets the rotation of the Player's camera
ResetCameraResets the Camera to default state (Unspectate and Detaches)
RotateCameraToSmoothly moves the Player's Camera Rotation
SetCameraArmLengthSets the Player's Camera Arm Length (Spring Arm length)
SetCameraFOVSets the Player's Camera FOV (if not possessing a Character)
SetCameraLocationSets the Player's Camera Location (only works if not possessing any Character)
SetCameraRotationSets the Player's Camera Rotation
SetCameraSocketOffsetSets the Player's Camera Socket Offset (Spring Arm Offset)
SetCameraSpeedSettingsSets the Player's Camera Speed Settings (if not possessing a Character)
SetManualCameraFadeTurns on camera fading at the given opacity
StartCameraFadeDoes a camera fade to/from a solid color
StopCameraFadeStops camera fading
TranslateCameraToSmoothly moves the Player's Camera Location (only works if not possessing any Character)
Control
GetControlledCharacter: Base Pawn or nilGets the Pawn (Character) this Player is currently possessing
PossessMakes this Player possess and control a Pawn (Character)
SpectateMakes this Player spectate another Player
UnPossessRelease the Player from the Character
Network
BanBans the player from the server
ConnectRedirects the player to another server
GetDimension: integerGets this Player's dimension
GetIP: stringGets the Player's IP address
GetPing: integerGets the Player's ping
IsHost: booleanGets if this Player is the host of a P2P (listen) server
IsLocalPlayer: booleanGets if this Player is the local Player (the one running this client)
KickKicks the player from the server
SetDimensionSets this Player's dimension
SetDistanceOptimizationMultiplierSets the multiplier for how much this Player's is affected by distance optimization from other actors

Accountfunctions​

GetAccountIconURLOptimal​

Return a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)

local account_icon_url = my_player:GetAccountIconURL()
Returns
TypeDescrição
stringURL of the Steam avatar image

GetAccountIDOptimal​

Gets the Player's nanos world account ID

local account_id = my_player:GetAccountID()
Returns
TypeDescrição
stringThe nanos world account ID

GetAccountNameOptimal​

Gets the Player's nanos world account name

local account_name = my_player:GetAccountName()
Returns
TypeDescrição
stringThe account name

GetNameOptimal​

Gets the Player's name

local player_name = my_player:GetName()
Returns
TypeDescrição
stringThe Player's name

See also SetName.

GetSteamIDOptimal​

Gets the Player's Steam ID

local steam_id = my_player:GetSteamID()
Returns
TypeDescrição
stringThe Steam ID (SteamID64)

SetNameOptimal​

Sets the player's name

my_player:SetName(player_name)
Parameters
NameTypeDescrição
player_namestringThe new player's name

See also GetName.

Audiofunctions​

GetVOIPAmplitudeModerate​

Returns how loud this player is talking right now

It is the RMS of the last voice data received from this player, before distance attenuation, occlusion and filters. Normal speech stays low in the scale, usually between 0.05 and 0.3. It only works for players the local player is receiving voice from, and for the local player while the voice is being transmitted. The local player's voice is only measured while this method keeps being called, so the first call returns 0

local ret = my_player:GetVOIPAmplitude()
Returns
TypeDescrição
floatThe voice amplitude from 0 to 1, or 0 if the player is not talking

See also VOIP.

GetVOIPGlobalHighPassFilterOptimal​

Returns the global VOIP high-pass filter threshold frequency

local ret = my_player:GetVOIPGlobalHighPassFilter()
Returns
TypeDescrição
integerThe threshold frequency in Hz, 0 if disabled

See also SetVOIPGlobalHighPassFilter.

GetVOIPGlobalLowPassFilterOptimal​

Returns the global VOIP low-pass filter threshold frequency

local ret = my_player:GetVOIPGlobalLowPassFilter()
Returns
TypeDescrição
integerThe threshold frequency in Hz, 0 if disabled

See also SetVOIPGlobalLowPassFilter.

GetVOIPGlobalVolumeOptimal​

Returns the global VOIP volume

local ret = my_player:GetVOIPGlobalVolume()
Returns
TypeDescrição
floatThe global VOIP volume

See also SetVOIPGlobalVolume.

GetVOIPListeningChannelsModerate​

Returns a list of VOIP channels this player is listening to

local ret = my_player:GetVOIPListeningChannels()
Returns
TypeDescrição
table of integerlist of channel indexes

GetVOIPLocalAttenuationOptimal​

Returns how the local/proximity VOIP fades with distance

local inner_radius, falloff_function = my_player:GetVOIPLocalAttenuation()
Returns
TypeDescrição
integerThe inner radius, where the voice plays at full volume
AttenuationFunctionHow the volume fades between the inner radius and the max distance

See also SetVOIPLocalAttenuation.

GetVOIPLocalHighPassFilterOptimal​

Returns the local/proximity VOIP high-pass filter threshold frequency

local ret = my_player:GetVOIPLocalHighPassFilter()
Returns
TypeDescrição
integerThe threshold frequency in Hz, 0 if disabled

See also SetVOIPLocalHighPassFilter.

GetVOIPLocalLowPassFilterOptimal​

Returns the local/proximity VOIP low-pass filter threshold frequency

local ret = my_player:GetVOIPLocalLowPassFilter()
Returns
TypeDescrição
integerThe threshold frequency in Hz, 0 if disabled

See also SetVOIPLocalLowPassFilter.

GetVOIPLocalMaxDistanceOptimal​

Returns the local/proximity VOIP max distance

local ret = my_player:GetVOIPLocalMaxDistance()
Returns
TypeDescrição
integerThe local/proximity VOIP max distance

See also SetVOIPLocalMaxDistance.

GetVOIPLocalOcclusionOptimal​

Returns the automatic occlusion settings of the local/proximity VOIP

local enabled, low_pass_frequency, volume_multiplier = my_player:GetVOIPLocalOcclusion()
Returns
TypeDescrição
booleanIf the voice is automatically occluded
integerThe low-pass filter threshold frequency applied when occluded, in Hz
floatThe volume multiplier applied when occluded

See also SetVOIPLocalOcclusion.

GetVOIPLocalVolumeOptimal​

Returns the local/proximity VOIP volume

local ret = my_player:GetVOIPLocalVolume()
Returns
TypeDescrição
floatThe local/proximity VOIP volume

See also SetVOIPLocalVolume.

GetVOIPSpeakingChannelsModerate​

Returns a list of VOIP channels this player is currently speaking to

local ret = my_player:GetVOIPSpeakingChannels()
Returns
TypeDescrição
table of integerlist of channel indexes

IsVOIPMutedOptimal​

Returns whether VOIP is muted for this player

local ret = my_player:IsVOIPMuted()
Returns
TypeDescrição
booleanWhether VOIP is muted for this player

See also SetVOIPMuted.

SetVOIPGlobalAllChannelsSettingOptimal​

Sets the VOIP setting for all global channels

my_player:SetVOIPGlobalAllChannelsSetting(setting)
Parameters
NameTypeDescrição
settingVOIPSettingThe new VOIP setting for all global channels

See also SetVOIPGlobalChannelSetting, GetVOIPListeningChannels, GetVOIPSpeakingChannels, VOIPGlobalChannelSettingChange.

SetVOIPGlobalChannelSettingOptimal​

Sets the VOIP setting for a specific global channel

my_player:SetVOIPGlobalChannelSetting(channel, setting)
Parameters
NameTypeDescrição
channelintegerChannel number, from 1 to 63
settingVOIPSettingWhether this Player listens, speaks, both or none on this channel

See also SetVOIPGlobalAllChannelsSetting, GetVOIPListeningChannels, GetVOIPSpeakingChannels, VOIPGlobalChannelSettingChange.

SetVOIPGlobalHighPassFilterOptimal​

Sets the global VOIP high-pass filter threshold frequency

Set it to 0 to disable it

my_player:SetVOIPGlobalHighPassFilter(threshold)
Parameters
NameTypeDescrição
thresholdintegerThe new global VOIP high-pass filter threshold frequency

See also SetVOIPGlobalLowPassFilter, GetVOIPGlobalHighPassFilter.

SetVOIPGlobalLowPassFilterOptimal​

Sets the global VOIP low-pass filter threshold frequency

Set it to 0 to disable it

my_player:SetVOIPGlobalLowPassFilter(threshold)
Parameters
NameTypeDescrição
thresholdintegerThe new global VOIP low-pass filter threshold frequency

See also SetVOIPGlobalHighPassFilter, GetVOIPGlobalLowPassFilter.

SetVOIPGlobalVolumeOptimal​

Sets the global VOIP volume. It only affects the global channels

my_player:SetVOIPGlobalVolume(volume)
Parameters
NameTypeDescrição
volumefloatThe new global VOIP volume. It only affects the global channels

See also GetVOIPGlobalVolume.

SetVOIPLocalAttenuationModerate​

Sets how the local/proximity VOIP fades with distance

The voice plays at full volume inside the inner radius, then fades to silence at the max distance set with SetVOIPLocalMaxDistance

my_player:SetVOIPLocalAttenuation(inner_radius, falloff_function?)
Parameters
NameTypeDescrição
inner_radiusintegerDistance where the voice plays at full volume. Default is 800. It is clamped to the max distance
falloff_function?AttenuationFunctionHow the volume fades between the inner radius and the max distance Default AttenuationFunction.Logarithmic

See also SetVOIPLocalMaxDistance, GetVOIPLocalAttenuation.

SetVOIPLocalHighPassFilterModerate​

Sets the local/proximity VOIP high-pass filter threshold frequency

Set it to 0 to disable it. On server side, it applies to everyone hearing this player. On client side, it only applies to the local listener

my_player:SetVOIPLocalHighPassFilter(threshold)
Parameters
NameTypeDescrição
thresholdintegerThe new local/proximity VOIP high-pass filter threshold frequency, in Hz

See also SetVOIPLocalLowPassFilter, SetVOIPLocalOcclusion, GetVOIPLocalHighPassFilter.

SetVOIPLocalLowPassFilterModerate​

Sets the local/proximity VOIP low-pass filter threshold frequency

Set it to 0 to disable it. Useful to muffle a voice, like a player behind a wall, inside a vehicle or wearing a mask. On server side, it applies to everyone hearing this player. On client side, it only applies to the local listener

my_player:SetVOIPLocalLowPassFilter(threshold)
Parameters
NameTypeDescrição
thresholdintegerThe new local/proximity VOIP low-pass filter threshold frequency, in Hz

See also SetVOIPLocalHighPassFilter, SetVOIPLocalOcclusion, GetVOIPLocalLowPassFilter.

SetVOIPLocalMaxDistanceOptimal​

Sets the local/proximity VOIP max distance. This also affects networking usage

my_player:SetVOIPLocalMaxDistance(max_distance)
Parameters
NameTypeDescrição
max_distanceintegerFalloff Distance. Default is 3600

See also SetVOIPLocalSetting, SetVOIPLocalVolume, SetVOIPLocalAttenuation, GetVOIPLocalMaxDistance.

SetVOIPLocalOcclusionModerate​

Configures the automatic occlusion of the local/proximity VOIP

When something blocks the line between the listener and this player, the voice gets a low-pass filter and a volume multiplier. It is enabled by default. Disable it to control the muffling from a script, with SetVOIPLocalLowPassFilter and SetVOIPLocalVolume

my_player:SetVOIPLocalOcclusion(enabled, low_pass_frequency?, volume_multiplier?)
Parameters
NameTypeDescrição
enabledbooleanIf the voice is automatically occluded
low_pass_frequency?integerThe low-pass filter threshold frequency applied when occluded, in Hz Default 3500
volume_multiplier?floatThe volume multiplier applied when occluded Default 0.85

See also SetVOIPLocalLowPassFilter, SetVOIPLocalVolume, GetVOIPLocalOcclusion.

SetVOIPLocalSettingOptimal​

Sets the VOIP setting for the local/proximity

my_player:SetVOIPLocalSetting(setting)
Parameters
NameTypeDescrição
settingVOIPSettingThe new VOIP setting for the local/proximity

See also SetVOIPLocalMaxDistance, SetVOIPLocalVolume, VOIPLocalSettingChange.

SetVOIPLocalVolumeOptimal​

Sets the local/proximity VOIP input/output volume. It only affects the local/proximity channel

my_player:SetVOIPLocalVolume(volume)
Parameters
NameTypeDescrição
volumefloatThe new local/proximity VOIP input/output volume. It only affects the local/proximity channel

See also SetVOIPLocalSetting, SetVOIPLocalMaxDistance, GetVOIPLocalVolume, VOIPLocalSettingChange.

SetVOIPMutedOptimal​

Mutes or unmutes VOIP for this player

On server side, the player is muted for everyone. On client side, it is a local mute only

my_player:SetVOIPMuted(is_muted)
Parameters
NameTypeDescrição
is_mutedbooleanWhether VOIP is muted

See also IsVOIPMuted.

Camerafunctions​

AttachCameraToOptimal​

Attaches the Player's Camera to an Actor

my_player:AttachCameraTo(actor, socket_offset?, blend_speed?)
Parameters
NameTypeDescrição
actorBase ActorThe Actor to attach the camera to
socket_offset?VectorOffset of the camera relative to the Actor Default Vector(0, 0, 0)
blend_speed?floatSpeed of the camera blend, 0 to snap immediately Default 0.0

GetCameraArmLengthOptimal​

Gets the Player's camera arm (spring arm) length

local length = my_player:GetCameraArmLength(return_base?)
Parameters
NameTypeDescrição
return_base?booleanWhether to return the current (false) or base (true) value. The base is the same value set by SetCameraArmLength(). Use base if you want to get the original value set by SetCameraArmLength() and not the current (interpolated) value Default false
Returns
TypeDescrição
floatThe camera arm length, in units

See also SetCameraArmLength.

GetCameraLocationOptimal​

Gets the location of the Player's camera

local location = my_player:GetCameraLocation()
Returns
TypeDescrição
VectorThe camera location

See also SetCameraLocation.

GetCameraRotationOptimal​

Gets the rotation of the Player's camera

local rotation = my_player:GetCameraRotation()
Returns
TypeDescrição
RotatorThe camera rotation

See also SetCameraRotation.

ResetCameraOptimal​

Resets the Camera to default state (Unspectate and Detaches)

my_player:ResetCamera()

RotateCameraToOptimal​

Smoothly moves the Player's Camera Rotation

my_player:RotateCameraTo(rotation, time, exp?)
Parameters
NameTypeDescrição
rotationRotatorThe target camera rotation
timefloatSeconds to reach the target
exp?floatExponential used to smooth interp, use 0 for linear movement Default 0

SetCameraArmLengthOptimal​

Sets the Player's Camera Arm Length (Spring Arm length)

my_player:SetCameraArmLength(length, force?)
Parameters
NameTypeDescrição
lengthfloatLength of the camera spring arm, in units
force?booleanWhether to bypass interpolation and set the target to its value directly Default false

See also GetCameraArmLength.

SetCameraFOVOptimal​

Sets the Player's Camera FOV (if not possessing a Character)

my_player:SetCameraFOV(fov?)
Parameters
NameTypeDescrição
fov?floatValue must be between 5 and 170. Pass empty to reset to default Default 90

SetCameraLocationOptimal​

Sets the Player's Camera Location (only works if not possessing any Character)

my_player:SetCameraLocation(location)
Parameters
NameTypeDescrição
locationVectorThe new Player's Camera Location

See also GetCameraLocation.

SetCameraRotationOptimal​

Sets the Player's Camera Rotation

my_player:SetCameraRotation(rotation)
Parameters
NameTypeDescrição
rotationRotatorThe new Player's Camera Rotation

See also GetCameraRotation.

SetCameraSocketOffsetOptimal​

Sets the Player's Camera Socket Offset (Spring Arm Offset)

my_player:SetCameraSocketOffset(socket_offset)
Parameters
NameTypeDescrição
socket_offsetVectorThe new Player's Camera Socket Offset

SetCameraSpeedSettingsOptimal​

Sets the Player's Camera Speed Settings (if not possessing a Character)

my_player:SetCameraSpeedSettings(max_speed?, acceleration?, deceleration?, turning_boost?)
Parameters
NameTypeDescrição
max_speed?floatMaximum velocity magnitude allowed Default 1200
acceleration?floatAcceleration applied by input (rate of change of velocity) Default 4000
deceleration?floatDeceleration applied when there is no input (rate of change of velocity) Default 4000
turning_boost?floatSetting affecting extra force applied when changing direction, making turns have less drift and become more responsive. Velocity magnitude is not allowed to increase, that only happens due to normal acceleration. It may decrease with large direction changes. Larger values apply extra force to reach the target direction more quickly, while a zero value disables any extra turn force Default 8

SetManualCameraFadeOptimal​

Turns on camera fading at the given opacity

Does not auto-animate, allowing user to animate themselves. Call StopCameraFade to turn fading back off

my_player:SetManualCameraFade(in_fade_amount, color, in_fade_audio)
Parameters
NameTypeDescrição
in_fade_amountfloatRange [0..1], where 0 is fully transparent and 1 is fully opaque solid color
colorColorThe color to use
in_fade_audiobooleanWhether to fade the audio as well

StartCameraFadeModerate​

Does a camera fade to/from a solid color

Animates automatically

my_player:StartCameraFade(from_alpha, to_alpha, duration, to_color, should_fade_audio?, hold_when_finished?)
Parameters
NameTypeDescrição
from_alphafloatAlpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color
to_alphafloatAlpha at which to finish the fade
durationfloatHow long the fade should take, in seconds
to_colorColorColor to fade to/from
should_fade_audio?booleanTrue to fade audio volume along with the alpha of the solid color Default false
hold_when_finished?booleanTrue for fade to hold at the ToAlpha until explicitly stopped (e.g. with StopCameraFade) Default false

StopCameraFadeOptimal​

Stops camera fading

my_player:StopCameraFade()

TranslateCameraToOptimal​

Smoothly moves the Player's Camera Location (only works if not possessing any Character)

my_player:TranslateCameraTo(location, time, exp?)
Parameters
NameTypeDescrição
locationVectorThe target camera location
timefloatSeconds to reach the target
exp?floatExponential used to smooth interp, use 0 for linear movement Default 0

Controlfunctions​

GetControlledCharacterOptimal​

Gets the Pawn (Character) this Player is currently possessing

local controlled_character = my_player:GetControlledCharacter()
Returns
TypeDescrição
Base Pawn or nilThe possessed Pawn, or nil if not possessing any

PossessModerate​

Makes this Player possess and control a Pawn (Character)

my_player:Possess(new_pawn, blend_time?, exp?)
Parameters
NameTypeDescrição
new_pawnBase PawnThe Pawn to possess
blend_time?floatSeconds to smoothly blend the camera to the new Pawn Default 0
exp?floatExponent used to smooth the blend, use 0 for linear Default 0

SpectateOptimal​

Makes this Player spectate another Player

my_player:Spectate(player, blend_speed?)
Parameters
NameTypeDescrição
playerPlayerThe Player
blend_speed?floatSpeed of the camera blend, 0 to snap immediately Default 0

UnPossessOptimal​

Release the Player from the Character

my_player:UnPossess()

Networkfunctions​

BanSlow​

Bans the player from the server

my_player:Ban(reason)
Parameters
NameTypeDescrição
reasonstringThe reason shown to the Player

ConnectOptimal​

Redirects the player to another server

my_player:Connect(ip, password?)
Parameters
NameTypeDescrição
ipstringThe server address to connect to, in the format IP:PORT
password?stringServer password Default

GetDimensionOptimal​

Gets this Player's dimension

local dimension = my_player:GetDimension()
Returns
TypeDescrição
integerThis Player's dimension

See also SetDimension, DimensionChange.

GetIPOptimal​

Gets the Player's IP address

local ip = my_player:GetIP()
Returns
TypeDescrição
stringThe IP address

GetPingOptimal​

Gets the Player's ping

local ping = my_player:GetPing()
Returns
TypeDescrição
integerThe ping, in milliseconds

IsHostOptimal​

Gets if this Player is the host of a P2P (listen) server

local is_host = my_player:IsHost()
Returns
TypeDescrição
booleanWhether this Player is the host

IsLocalPlayerOptimal​

Gets if this Player is the local Player (the one running this client)

local is_local_player = my_player:IsLocalPlayer()
Returns
TypeDescrição
booleanWhether this is the local Player

KickModerate​

Kicks the player from the server

my_player:Kick(reason)
Parameters
NameTypeDescrição
reasonstringThe reason shown to the Player

SetDimensionSlow​

Sets this Player's dimension

my_player:SetDimension(dimension)
Parameters
NameTypeDescrição
dimensionintegerThe new dimension

See also GetDimension, DimensionChange.

SetDistanceOptimizationMultiplierOptimal​

Sets the multiplier for how much this Player's is affected by distance optimization from other actors

A value of 0 disables optimization. Values under 1 decrease the effect, while values over 1 increase it

my_player:SetDistanceOptimizationMultiplier(multiplier)
Parameters
NameTypeDescrição
multiplierfloatThe new multiplier for how much this Player's is affected by distance optimization from other actors

🚀 Events​

DimensionChangeTriggered when a Player changes its dimension
PossessTriggered when Player starts controlling a Pawn (Character)
ReadyTriggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
UnPossessA Pawn (Character) was unpossessed from the Player
VOIPWhen a Player starts/ends using VOIP
VOIPGlobalChannelSettingChangeTriggered when a global VOIP channel setting changes for this player
VOIPLocalSettingChangeTriggered when the local VOIP setting changes for this player

Inherited events

From Entity4 events

DimensionChange​

Triggered when a Player changes its dimension

Player.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)
-- DimensionChange was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
old_dimensionintegerThe previous dimension
new_dimensionintegerThe new dimension

See also SetDimension, GetDimension.

Possess​

Triggered when Player starts controlling a Pawn (Character)

Player.Subscribe("Possess", function(self, pawn)
-- Possess was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
pawnBase PawnThe Pawn being possessed

See also GetControlledCharacter.

Ready​

Triggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)

Player.Subscribe("Ready", function(self)
-- Ready was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event

UnPossess​

A Pawn (Character) was unpossessed from the Player

Player.Subscribe("UnPossess", function(self, pawn)
-- UnPossess was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
pawnBase PawnThe Pawn being unpossessed

See also GetControlledCharacter.

VOIP​

When a Player starts/ends using VOIP

Player.Subscribe("VOIP", function(self, is_talking)
-- VOIP was called
return true
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
is_talkingbooleanWhether the Player started (true) or stopped (false) talking
Returns
TypeDescrição
booleanWhen 'is_talking' is true, return false to prevent this voice stream from playing (on server will prevent for everyone, on client will prevent only for the client)

VOIPGlobalChannelSettingChange​

Triggered when a global VOIP channel setting changes for this player

Player.Subscribe("VOIPGlobalChannelSettingChange", function(self, channel, old_setting, new_setting)
-- VOIPGlobalChannelSettingChange was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
channelintegerThe channel that changed (1-63)
old_settingVOIPSettingThe previous setting
new_settingVOIPSettingThe new setting

See also SetVOIPGlobalChannelSetting, SetVOIPGlobalAllChannelsSetting.

VOIPLocalSettingChange​

Triggered when the local VOIP setting changes for this player

Player.Subscribe("VOIPLocalSettingChange", function(self, old_setting, new_setting)
-- VOIPLocalSettingChange was called
end)
Arguments
NameTypeDescrição
selfPlayerThe Player that triggered the event
old_settingVOIPSettingThe previous setting
new_settingVOIPSettingThe new setting

See also SetVOIPLocalSetting.