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

👩‍💻 Player

info

🟥 Authority: You cannot spawn or Destroy Players.

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

Usage

-- Spawns and possess a Character when a Player joins the server
Player.Subscribe("Spawn", function(player)
local new_char = Character()
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)

Functions

ReturnsNameDescription
BanBans the player from the server
ConnectRedirects the player to another server
KickKicks the player from the server
PossessBind the Player to a Character
SetCameraLocationSets the Player’s Camera Location
SetCameraRotationSets the Player’s Camera Rotation
SetCameraSocketOffsetSets the Player’s Camera Socket Offset
SetCameraArmLengthSets the Player’s Camera Arm Length
AttachCameraToAttaches the Player’s Camera to an Actor
ResetCameraResets the Player’s Camera to the default state
SpectateSpectates another Player
SetNameSets the player’s name
Definir ValorSets a value in this entity, which can be accessed by any package
SetVOIPChannelSets the VOIP Channel of this Player
SetVOIPSettingSets the VOIP Settings of this Player
SetVOIPVolumeSets the VOIP Volume of this Player
UnPossessRelease the Player from the Character
stringGetSteamIDGets the Steam account ID
stringGetAccountIDGets the nanos account ID
stringGetAccountNameGets the nanos account name
VectorGetCameraLocationGets the Player’s Camera Location
RotatorGetCameraRotationGets the Player’s Camera Rotation
CharacterGetControlledCharacterReturns the character of the player
numberGetIDGets the network ID of this entity
stringGetIPGets the IP of this Player
stringGetNameReturns the player’s name
numberGetPingReturns the ping of a player
stringGetTypeReturns the type of this Actor
numberGetVOIPChannelReturns the VOIP Channel of this Player
anyvalorDeGetValueGets a value given a key
booleanIsHostReturns if this Player started the server from New Game
booleanIsLocalPlayerReturns if this is the LocalPlayer
booleanIsValidReturns if this entity is valid (i.e. wasn’t destroyed and points to a valid entity)
VOIPSettingGetVOIPSettingReturns this Player VOIP Setting
functionSubscribeSubscribes for an Event
UnsubscribeUnsubscribes from all subscribed Events in this Entity and in this Package

Events

NameDescription
DestroyTriggered when Player disconnects from the server
PossessA Player was bound to a Character
SpawnTriggered when Player connects to the server
ReadyTriggered when Player is ready (the client fully joined, loaded the map and all entities and is ready to play)
UnPossessA Character was released from the Player
VOIPWhen a Player starts/ends using VOIP

Functions Detailed

Ban

Bans the player from the server

my_player:Ban(reason)
TypeParameterDescription
stringreason

Connect

Redirects the player to another server

my_player:Connect(IP, password = "")
TypeParameterDefault ValueDescription
stringIPIP do Servidor
stringSenha""Senha do servidor

Kick

Kicks the player from the server

my_player:Kick(reason)
TypeParameterDescription
stringreason

Possess

Makes a Player to possess and control a Character

my_player:Possess(new_character, blend_time, exp)
TypeParameterDescription
Characternew_character
numberblend_time0
numberexp0

SetCameraLocation

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

my_player:SetCameraLocation(location)
TypeParameterDefaultDescription
Vectorlocation

SetCameraRotation

Sets the Player's Camera Rotation

my_player:SetCameraRotation(rotation)
TypeParameterDefaultDescription
Rotatorrotation

TranslateCameraTo

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

my_player:TranslateCameraTo(location, time, exp)
TypeParameterDefaultDescription
Vectorlocation
numbertimeTime to interp from current camera location to target location
numberexp0Exponential used to smooth interp, use 0 for linear movement

RotateCameraTo

Smoothly moves the Player's Camera Rotation

my_player:RotateCameraTo(rotation, time, exp)
TypeParameterDefaultDescription
Rotatorrotation
numbertimeTime to interp from current camera rotation to target rotation
numberexp0Exponential used to smooth interp, use 0 for linear movement

SetCameraSocketOffset

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

my_player:SetCameraSocketOffset(socket_offset)
TypeParameterDefaultDescription
Vectorsocket_offset

SetCameraArmLength

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

my_player:SetCameraArmLength(length)
TypeParameterDefaultDescription
numberlength

AttachCameraTo

Attaches the Player`s Camera to an Actor

my_player:AttachCameraTo(actor, socket_offset, blend_speed)
TypeParameterDefaultDescription
Base Actoractor
Vectorsocket_offset
numberblend_speed

ResetCamera

Resets the Camera to default state (Unspectate and Detaches)

my_player:ResetCamera()

Spectate

Spectates other Player

my_player:Spectate(player, blend_speed)
TypeParameterDefaultDescription
Playerplayer
numberblend_speed

SetName

Sets the player's name

my_player:SetName(new_name)
TypeParameterDescription
stringnew_name

SetValue

Sets a value in this entity, which can be accessed by any package (optionally sync on clients if called from server)

Please refer to Entity Values for more information

my_player:SetValue(key, value, sync_on_clients)
TypeParameterDefault ValueDescription
stringkeyKey
anyvalueValue
booleansync_on_clientsfalseServer side parameter, if enabled will sync this value through all clients

SetVOIPChannel

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

my_player:SetVOIPChannel(channel)
TypeParameterDescription
numberchannel

SetVOIPSetting

Sets the VOIP Settings of this Player

my_player:SetVOIPSetting(setting)
TypeParameterDescription
VOIPSettingsetting

SetVOIPVolume

Sets the VOIP Volume of this Player

my_player:SetVOIPSetting(volume)
TypeParameterDescription
numbervolume

UnPossess

Release the Player from the :ref:Character

my_player:UnPossess()

GetSteamID

Gets the Steam account ID

Returns string

my_player:GetSteamID()

GetAccountID

Gets the nanos account ID

Returns string

my_player:GetAccountID()

GetAccountName

Gets the nanos account name

Returns string

my_player:GetAccountName()

GetCameraLocation

Gets the Player's Camera Location

Returns Vector

my_player:GetCameraLocation()

GetCameraRotation

Gets the Player's Camera Rotation

Returns Rotator

my_player:GetCameraRotation()

GetControlledCharacter

Returns the character of the player. If the player has not yet been assigned a character, nil is returned

Returns Character or nil

my_player:GetControlledCharacter()

GetID

Gets the network ID of this entity (same in both client and server)

Returns number

my_player:GetID()

GetIP

Gets the IP of this Player

Returns string

my_player:GetIP()

GetName

Returns the player's name

Returns string

my_player:GetName()

GetPing

Returns the ping of a player

Returns number

my_player:GetPing()

GetType

Returns the type of this Actor

Returns string

my_player:GetType()

GetVOIPChannel

Returns the VOIP Channel of this Player

Returns VOIPChannel

my_player:GetVOIPChannel()

GetValue

Gets a value given a key. Please refer to Entity Values for more information

Returns any

my_player:GetValue(key, fallback)
TypeParameterDefault ValueDescription
stringkeyKey
anyfallbackFallback Value if key doesn't exist

IsHost

Returns if this Player started the server from New Game menu

Returns boolean

my_player:IsHost()

IsLocalPlayer

Returns if this is the LocalPlayer

Returns boolean

my_player:IsLocalPlayer()

IsValid

Returns if this entity is valid (i.e. wasn't destroyed and points to a valid entity)

Returns boolean

my_player:IsValid()

GetVOIPSetting

Returns this Player VOIP Setting

Returns VOIPSetting

my_player:GetVOIPSetting()

Subscribe

Subscribes for an Event

Returns the function callback itself

my_player:Subscribe(event_name, callback)
TypeParameterDefault ValueDescription
stringevent_name
functionfunction

Unsubscribe

Unsubscribes from all subscribed Events in this Entity and in this Package, optionally passing the function to unsubscribe only that callback

my_player:Unsubscribe(event_name, callback)
TypeParameterDefault ValueDescription
stringevent_name
functionfunctionnil

Events Detailed

Destroy

Triggered when Player disconnects from the server

Player.Subscribe("Destroy", function(self)

end)
TypeParameterDescription
Playerself

Possess

A Player is now controlling a Character

Player.Subscribe("Possess", function(self, character)

end)
TypeParameterDescription
Playerself
Charactercharacter

Spawn

Triggered when Player connects to the server

Player.Subscribe("Spawn", function(self)

end)
TypeParameterDescription
Playerself

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)

end)
TypeParameterDescription
Playerself

UnPossess

A Character was released from the Player

Player.Subscribe("UnPossess", function(self, character)

end)
TypeParameterDescription
Playerself
Charactercharacter

VOIP

When a Player starts/ends using VOIP

Player.Subscribe("VOIP", function(self, is_talking)

end)
TypeParameterDescription
Playerself
booleanis_talking