BasePlayer
Defined in: server/api.d.ts:7322
Framework-owned base handle for a connected player, extended by each game or mod.
Extends
Section titled “Extends”ServerEntity
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BasePlayer(
id):BasePlayer
Defined in: server/api.d.ts:7327
Creates a wrapper for an existing connected player with this ID; it does not connect or spawn a player.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”BasePlayer
Methods
Section titled “Methods”emit()
Section titled “emit()”emit(
eventName,payloadJson?):void
Defined in: server/api.d.ts:7410
Emits a named script event to this player’s client connection. Throws when the name is over 1 KiB or the payload over 1 MiB.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Client event name.
payloadJson?
Section titled “payloadJson?”string
Optional JSON payload forwarded verbatim to the owning client, at most 1 MiB.
Returns
Section titled “Returns”void
getIP()
Section titled “getIP()”getIP():
string
Defined in: server/api.d.ts:7416
Returns this player’s current remote network address.
Returns
Section titled “Returns”string
Address string, or an empty string when the player or peer is unavailable.
getNametagColor()
Section titled “getNametagColor()”getNametagColor():
number
Defined in: server/api.d.ts:7397
Reads this player’s nametag color.
Returns
Section titled “Returns”number
Packed 0xAARRGGBB color; opaque white when untinted.
getNametagText()
Section titled “getNametagText()”getNametagText():
string
Defined in: server/api.d.ts:7391
Reads this player’s nametag text override.
Returns
Section titled “Returns”string
The override, or an empty string when the player’s own name is drawn.
isNametagHealthVisible()
Section titled “isNametagHealthVisible()”isNametagHealthVisible():
boolean
Defined in: server/api.d.ts:7385
Checks whether the health bar under this player’s nametag is shown.
Returns
Section titled “Returns”boolean
True unless the health bar was hidden; false also when this game has no nametags.
isNametagVisible()
Section titled “isNametagVisible()”isNametagVisible():
boolean
Defined in: server/api.d.ts:7379
Checks whether this player’s nametag is shown to other players.
Returns
Section titled “Returns”boolean
True unless the nametag was hidden; false also when this game has no nametags.
kick()
Section titled “kick()”kick(
reason?):void
Defined in: server/api.d.ts:7403
Disconnects this player from the server.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”string
Optional reason shown to the disconnected player; omitting it uses the generic kicked reason.
Returns
Section titled “Returns”void
setNametagColor()
Section titled “setNametagColor()”setNametagColor(
color):void
Defined in: server/api.d.ts:7440
Tints the text on this player’s nametag.
Parameters
Section titled “Parameters”number
Packed 0xAARRGGBB color.
Returns
Section titled “Returns”void
setNametagHealthVisible()
Section titled “setNametagHealthVisible()”setNametagHealthVisible(
visible):void
Defined in: server/api.d.ts:7428
Shows or hides the health bar under this player’s nametag, leaving the name itself alone.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to show the health bar under this player’s name, false to hide it.
Returns
Section titled “Returns”void
setNametagText()
Section titled “setNametagText()”setNametagText(
text?):void
Defined in: server/api.d.ts:7434
Overrides the text drawn on this player’s nametag.
Parameters
Section titled “Parameters”string
Text to show instead of the player’s name, cut to 64 bytes; empty or omitted restores the name.
Returns
Section titled “Returns”void
setNametagVisible()
Section titled “setNametagVisible()”setNametagVisible(
visible):void
Defined in: server/api.d.ts:7422
Shows or hides the name over this player’s head for every other player. The health bar has its own switch, and each player can still hide all nametags locally.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to show this player’s nametag to everyone, false to hide it.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: shared.d.ts:80
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: shared.d.ts:82
Restricts replication to one player’s connection, within the usual range and visibility checks; null lifts it.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:7373
Formats this player handle for logging and debugging.
Returns
Section titled “Returns”string
Text containing the player’s network entity ID.
Properties
Section titled “Properties”accountId
Section titled “accountId”
readonlyaccountId:string
Defined in: server/api.d.ts:7332
The account this player proved when they connected: 32 hex characters, the same on every server and in every session, that no other client can claim. Key saved data, ownership, bans and permissions on it. It stands for a key the player’s client keeps on their computer, so a player who loses that file starts a new account. Empty once the player has left.
discordId
Section titled “discordId”
readonlydiscordId:string
Defined in: server/api.d.ts:7347
Discord identifier, or an empty string when unavailable. Reported by the player’s client and not verified: a modified client can send anyone’s. Show it or log it; never key ownership, bans or permissions on it, which is what accountId is for. Discord ids are public.
discordName
Section titled “discordName”
readonlydiscordName:string
Defined in: server/api.d.ts:7352
Discord username, or an empty string when unavailable. Reported by the player’s client and not verified: a modified client can send anyone’s. Show it or log it; never key ownership, bans or permissions on it, which is what accountId is for.
epicId
Section titled “epicId”
readonlyepicId:string
Defined in: server/api.d.ts:7342
Epic Games account identifier, or an empty string when unavailable. Reported by the player’s client and not verified: a modified client can send anyone’s. Show it or log it; never key ownership, bans or permissions on it, which is what accountId is for.
hardwareId
Section titled “hardwareId”
readonlyhardwareId:string
Defined in: server/api.d.ts:7357
Framework hardware identifier, or an empty string when unavailable. Reported by the player’s client and not verified: a modified client can send anyone’s. Show it or log it; never key ownership, bans or permissions on it, which is what accountId is for.
readonlyid:number
Defined in: shared.d.ts:65
Network id, stable for the entity’s lifetime.
readonlyip:string
Defined in: server/api.d.ts:7367
Current remote network address, or an empty string when unavailable.
readonlyping:number
Defined in: server/api.d.ts:7362
Current round-trip latency in milliseconds, or -1 when unavailable.
position
Section titled “position”position:
Vector3
Defined in: shared.d.ts:67
World position. Read, call set(...), then assign back.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: shared.d.ts:69
Reads as a quaternion; assignments also accept Euler angles in degrees.
readonlystate:StateBag
Defined in: shared.d.ts:71
This entity’s key/value state: the server writes it, and every client that can see the entity receives it. See StateBag.
steamId
Section titled “steamId”
readonlysteamId:string
Defined in: server/api.d.ts:7337
Steam identifier, or an empty string when unavailable. Reported by the player’s client and not verified: a modified client can send anyone’s. Show it or log it; never key ownership, bans or permissions on it, which is what accountId is for.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: shared.d.ts:73
The virtual world this entity replicates in. Read-only: change it with setVirtualWorld on the server.