A player, as seen from the client.

Two different numbers identify a player and mixing them up is the single most common source of "it works for me but not for anyone else":

  • player index (index) — a small, client-local slot number. Valid only on the machine that read it, and reused when players leave.
  • server ID (serverId) — assigned by the server, identical on every machine. This is the one to send in events and store in state bags.
for (player in Player.all()) {
    if (player.ped.distanceToEntity(LocalPlayer.ped()) < 20) {
        trace('${player.name} is nearby');
    }
}

Static methods

staticall():Array<Player>

Every player this client currently knows about.

That is not everyone on the server: clients only ever see players within streaming range plus a few extras. For a server-wide list, ask the server.

staticfromServerId(serverId:Int):Player

Resolves a server ID to a local Player, or null if that player isn't currently known to this client (out of scope, or gone).

staticinlinelocal():Player

The player this client is controlling.

Constructor

new(index:Int)

Variables

read onlycoords:Vector3

finalindex:Int

The client-local player index. Meaningless on any other machine.

read onlyisActive:Bool

Whether the player is connected and streamed in on this client.

read onlyisDead:Bool

read onlyname:String

read onlyped:Ped

The character this player controls.

read onlyserverId:Int

The server-assigned ID — safe to send over the network.

read onlystate:StateBag

The player's replicated state bag, keyed by server ID.

read onlywantedLevel:Int

Methods

toString():String