Passer au contenu principal
Version: latest - a1.73.x ⚖️

👩‍💻 Joueur

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 .
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

Autorité

🟥 Vous ne pouvez pas faire apparaître ou détruire des joueurs.

🎒 Examples

-- 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

Inherited Entity Static Functions
Player inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
of Returns a table containing all Entities of the class this is called on
Returns a specific Entity of this class at an index
Returns how many Entities of this class exist
of Gets a list of all directly inherited classes from this Class created with the Inheriting System
Returns an iterator with all Entities of this class to be used with pairs()
or Gets the parent class if this Class was created with the Inheriting System
Inherits this class with the Inheriting System
Gets if this Class is child of another class if this Class was created with the Inheriting System
Subscribes to an Event for all entities of this Class
Subscribes to a custom event called from server
Unsubscribes all callbacks from this Event in this Class within this Package, or only the callback passed

This class doesn't have own static functions.

🦠 Functions

Inherited Entity Functions
Player inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
Calls a custom remote event directly on this entity to all Players
Calls a custom remote event directly on this entity to a specific Player
Calls a custom remote event directly on this entity
Destroys this Entity
of Gets a list of all values keys
Gets the class of this entity
Gets the universal network ID of this Entity (same on both client and server)
Gets a Value stored on this Entity at the given key
Recursively checks if this entity is inherited from a Class
Returns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
Sets a Value in this Entity
Subscribes to an Event on this specific entity
Subscribes to a custom event called from server on this specific entity
Unsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed
ReturnsNameDescription
Attaches the Player`s Camera to an Actor
Bans the player from the server
Redirects the player to another server
Return a URL which can be used through WebUI and Widgets to display the Player's Steam Avatar (64x64)
No description provided
No description provided
No description provided
VectorNo description provided
RotatorNo description provided
Character or No description provided
Gets this Player's dimension
No description provided
No description provided
No description provided
No description provided
No description provided
No description provided
No description provided
No description provided
Kicks the player from the server
Makes a Player to possess and control a Pawn
Resets the Camera to default state (Unspectate and Detaches)
Smoothly moves the Player's Camera Rotation
Sets the Player's Camera Arm Length (Spring Arm length)
Sets the Player's Camera FOV (if not possessing a Character)
Sets the Player's Camera Location (only works if not possessing any Character)
Sets the Player's Camera Rotation
Sets the Player's Camera Socket Offset (Spring Arm Offset)
Sets the Player's Camera Speed Settings (if not possessing a Character)
Sets this Player's dimension
Turns on camera fading at the given opacity
Sets the player's name
Sets the VOIP Channel of this Player (will only communicate with other players in the same channel)
Sets the VOIP Settings of this Player
Sets the VOIP Volume of this Player
Spectates other Player
Does a camera fade to/from a solid color
Stops camera fading.
Smoothly moves the Player's Camera Location (only works if not possessing any Character)
Release the Player from the Character

AttachCameraTo

Attaches the Player`s Camera to an Actor

my_player:AttachCameraTo(actor, socket_offset, blend_speed)
TypeParameterDefaultDescription
actor Required parameter No description provided
Vectorsocket_offset Required parameter No description provided
blend_speed Required parameter No description provided

Ban

Bans the player from the server

my_player:Ban(reason)
TypeParameterDefaultDescription
reason Required parameter No description provided

Connect

Redirects the player to another server

my_player:Connect(IP, password?)
TypeParameterDefaultDescription
IP Required parameter No description provided
password?Server password

GetAccountIconURL

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

— Returns .

local ret = my_player:GetAccountIconURL()

GetAccountID

— Returns .

local ret = my_player:GetAccountID()

GetAccountName

— Returns .

local ret = my_player:GetAccountName()

GetCameraArmLength

— Returns .

local ret = my_player:GetCameraArmLength(return_base?)
TypeParameterDefaultDescription
return_base?falseWhether to return the current (false) or base (true) value. The base is the same value set by SetCameraArmLength().

See also SetCameraArmLength.


GetCameraLocation

— Returns Vector.

local ret = my_player:GetCameraLocation()

See also SetCameraLocation.


GetCameraRotation

— Returns Rotator.

local ret = my_player:GetCameraRotation()

See also SetCameraRotation.


GetControlledCharacter

— Returns Character or .

local ret = my_player:GetControlledCharacter()

GetDimension

Gets this Player's dimension

— Returns .

local ret = my_player:GetDimension()

See also SetDimension, DimensionChange.


GetIP

— Returns .

local ret = my_player:GetIP()

GetName

— Returns .

local ret = my_player:GetName()

See also SetName.


GetPing

— Returns .

local ret = my_player:GetPing()

GetSteamID

— Returns .

local ret = my_player:GetSteamID()

GetVOIPChannel

— Returns .

local ret = my_player:GetVOIPChannel()

See also SetVOIPChannel.


GetVOIPSetting

— Returns .

local ret = my_player:GetVOIPSetting()

See also SetVOIPSetting.


IsHost

— Returns .

local ret = my_player:IsHost()

IsLocalPlayer

— Returns .

local ret = my_player:IsLocalPlayer()

Kick

Kicks the player from the server

my_player:Kick(reason)
TypeParameterDefaultDescription
reason Required parameter No description provided

Possess

Makes a Player to possess and control a Pawn

my_player:Possess(new_pawn, blend_time?, exp?)
TypeParameterDefaultDescription
new_pawn Required parameter No description provided
blend_time?0No description provided
exp?0No description provided

ResetCamera

Resets the Camera to default state (Unspectate and Detaches)

my_player:ResetCamera()

RotateCameraTo

Smoothly moves the Player's Camera Rotation

my_player:RotateCameraTo(rotation, time, exp?)
TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided
time Required parameter No description provided
exp?0Exponential used to smooth interp, use 0 for linear movement

SetCameraArmLength

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

my_player:SetCameraArmLength(length, force)
TypeParameterDefaultDescription
length Required parameter No description provided
force Required parameter Whether to bypass interpolation and set the target to its value directly

See also GetCameraArmLength.


SetCameraFOV

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

my_player:SetCameraFOV(fov?)
TypeParameterDefaultDescription
fov?90Value must be between 5 and 170. Pass empty to reset to default.

SetCameraLocation

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

my_player:SetCameraLocation(location)
TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided

See also GetCameraLocation.


SetCameraRotation

Sets the Player's Camera Rotation

my_player:SetCameraRotation(rotation)
TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided

See also GetCameraRotation.


SetCameraSocketOffset

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

my_player:SetCameraSocketOffset(socket_offset)
TypeParameterDefaultDescription
Vectorsocket_offset Required parameter No description provided

SetCameraSpeedSettings

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

my_player:SetCameraSpeedSettings(max_speed?, acceleration?, deceleration?, turning_boost?)
TypeParameterDefaultDescription
max_speed?1200Maximum velocity magnitude allowed
acceleration?4000Acceleration applied by input (rate of change of velocity)
deceleration?4000Deceleration applied when there is no input (rate of change of velocity)
turning_boost?8Setting 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.

SetDimension

Sets this Player's dimension

my_player:SetDimension(dimension)
TypeParameterDefaultDescription
dimension Required parameter No description provided

See also GetDimension, DimensionChange.


SetManualCameraFade

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)
TypeParameterDefaultDescription
in_fade_amount Required parameter Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
Colorcolor Required parameter No description provided
in_fade_audio Required parameter No description provided

SetName

Sets the player's name

my_player:SetName(player_name)
TypeParameterDefaultDescription
player_name Required parameter No description provided

See also GetName.


SetVOIPChannel

Sets the VOIP Channel of this Player (will only communicate with other players in the same channel)

my_player:SetVOIPChannel(channel)
TypeParameterDefaultDescription
channel Required parameter No description provided

See also GetVOIPChannel.


SetVOIPSetting

Sets the VOIP Settings of this Player

my_player:SetVOIPSetting(voip_setting)
TypeParameterDefaultDescription
voip_setting Required parameter No description provided

See also GetVOIPSetting.


SetVOIPVolume

Sets the VOIP Volume of this Player

my_player:SetVOIPVolume(volume)
TypeParameterDefaultDescription
volume Required parameter No description provided

Spectate

Spectates other Player

my_player:Spectate(player, blend_speed?)
TypeParameterDefaultDescription
Playerplayer Required parameter No description provided
blend_speed?0No description provided

StartCameraFade

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?)
TypeParameterDefaultDescription
from_alpha Required parameter Alpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
to_alpha Required parameter Alpha at which to finish the fade.
duration Required parameter How long the fade should take, in seconds.
Colorto_color Required parameter Color to fade to/from.
should_fade_audio?True to fade audio volume along with the alpha of the solid color.
hold_when_finished?True for fade to hold at the ToAlpha until explicitly stopped (e.g. with StopCameraFade)

StopCameraFade

Stops camera fading.

my_player:StopCameraFade()

TranslateCameraTo

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

my_player:TranslateCameraTo(location, time, exp?)
TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided
time Required parameter No description provided
exp?0Exponential used to smooth interp, use 0 for linear movement

UnPossess

Release the Player from the Character

my_player:UnPossess()

🚀 Events

Inherited Entity Events
Player inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/Entity
NameDescription
Triggered when a new Class is registered with the Inheriting System
Triggered when an Entity is destroyed
Triggered when an Entity is spawned/created
Triggered when an Entity has a value changed with :SetValue()
NameDescription
Triggered when a Player changes it's dimension
Trigerred when Player starts controlling a Character
Triggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
A Character was released from the Player
When a Player starts/ends using VOIP

DimensionChange

Triggered when a Player changes it's dimension
Player.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)
-- DimensionChange was called
end)
TypeArgumentDescription
PlayerselfNo description provided
old_dimensionNo description provided
new_dimensionNo description provided

See also SetDimension, GetDimension.


Possess

Trigerred when Player starts controlling a Character
Player.Subscribe("Possess", function(self, character)
-- Possess was called
end)
TypeArgumentDescription
PlayerselfNo description provided
CharactercharacterNo description provided

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)
TypeArgumentDescription
PlayerselfNo description provided

UnPossess

A Character was released from the Player
Player.Subscribe("UnPossess", function(self, character)
-- UnPossess was called
end)
TypeArgumentDescription
PlayerselfNo description provided
CharactercharacterNo description provided

See also GetControlledCharacter.


VOIP

When a Player starts/ends using VOIP

When '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)
Player.Subscribe("VOIP", function(self, is_talking)
-- VOIP was called
end)
TypeArgumentDescription
PlayerselfNo description provided
is_talkingNo description provided