skeldjs
    Preparing search index...

    Class PlayerControl<RoomType>

    Represents a player object for interacting with the game and other players.

    See PlayerControlEvents for events to listen to.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    components: NetworkedObject<RoomType, any>[]
    dirtyBit: number = 0

    The dirty state of this component.

    flags: number

    Flags for this object, see SpawnFlag.

    guardianProtector?: Player<RoomType>

    The player (i.e. a guardian angel) who has protected this player, if the player is being protected..

    isNew: boolean

    Whether the player was just spawned, or was spawned before joining.

    netId: number

    The net ID of this component.

    ownerId: number

    The ID of the owner of this component.

    player: Player<RoomType>

    The player that this component belongs to.

    playerId: number

    The player ID of the player.

    protectedByGuardian: boolean

    Whether or not this player has been protected bya guardian angel.

    room: RoomType

    The room that this component belongs to.

    shapeshiftTarget?: Player<RoomType>

    The player that this player has shapeshifted as, if any.

    spawnType: SpawnType

    The type of object that this component belongs to.

    Accessors

    Methods

    • Request for the host to check a name for this player and append numbers if it's taken.

      Parameters

      • name: string

        The name to request.

      Returns Promise<void>

    • Mark one of this player's tasks as completed.

      Parameters

      • taskIdx: number

        The index of the task to complete. Note: this is not the task ID but instead the index of the player's task, as in its position in the PlayerInfo.taskStates array.

        Emits a player.completetask event.

      Returns void

      client.me.control.completeTask(0);
      
    • Type Parameters

      • EventName extends
            | "component.spawn"
            | "component.despawn"
            | "player.checkcolor"
            | "player.checkmurder"
            | "player.checkname"
            | "player.checkprotect"
            | "player.completetask"
            | "player.die"
            | "player.usemovingplatform"
            | "player.murder"
            | "player.protect"
            | "player.removeprotection"
            | "player.reportbody"
            | "player.revertshapeshift"
            | "player.chat"
            | "player.quickchat"
            | "player.setcolor"
            | "player.sethat"
            | "player.setlevel"
            | "player.setname"
            | "player.setnameplate"
            | "player.setpet"
            | "player.setrole"
            | "player.setskin"
            | "player.setstartcounter"
            | "player.setvisor"
            | "player.shapeshift"
            | "player.startmeeting"
            | "player.syncsettings"

      Parameters

      Returns void

    • Type Parameters

      Parameters

      • event: string
      • listener: Listener<K>

      Returns void

    • Type Parameters

      • EventName extends
            | "component.spawn"
            | "component.despawn"
            | "player.checkcolor"
            | "player.checkmurder"
            | "player.checkname"
            | "player.checkprotect"
            | "player.completetask"
            | "player.die"
            | "player.usemovingplatform"
            | "player.murder"
            | "player.protect"
            | "player.removeprotection"
            | "player.reportbody"
            | "player.revertshapeshift"
            | "player.chat"
            | "player.quickchat"
            | "player.setcolor"
            | "player.sethat"
            | "player.setlevel"
            | "player.setname"
            | "player.setnameplate"
            | "player.setpet"
            | "player.setrole"
            | "player.setskin"
            | "player.setstartcounter"
            | "player.setvisor"
            | "player.shapeshift"
            | "player.startmeeting"
            | "player.syncsettings"

      Parameters

      Returns () => void

    • Type Parameters

      Parameters

      • event: string
      • listener: Listener<K>

      Returns () => void

    • Type Parameters

      • EventName extends
            | "component.spawn"
            | "component.despawn"
            | "player.checkcolor"
            | "player.checkmurder"
            | "player.checkname"
            | "player.checkprotect"
            | "player.completetask"
            | "player.die"
            | "player.usemovingplatform"
            | "player.murder"
            | "player.protect"
            | "player.removeprotection"
            | "player.reportbody"
            | "player.revertshapeshift"
            | "player.chat"
            | "player.quickchat"
            | "player.setcolor"
            | "player.sethat"
            | "player.setlevel"
            | "player.setname"
            | "player.setnameplate"
            | "player.setpet"
            | "player.setrole"
            | "player.setskin"
            | "player.setstartcounter"
            | "player.setvisor"
            | "player.shapeshift"
            | "player.startmeeting"
            | "player.syncsettings"

      Parameters

      Returns () => void

    • Type Parameters

      Parameters

      • event: string
      • listener: Listener<K>

      Returns () => void

    • Remove this player's protection from a guardian angel, if they have one.

      Emits a player.removeprotection event. This is not networked, so other players will not see this update.

      Parameters

      • timeout: boolean = false

        Whether or not this is because of a timeout.

      Returns Promise<void>

    • Change the counter at the bottom of the screen while in the lobby, usually counting down from 5 to 1. This is a host-only operation on official servers.

      Emits a player.setstartcounter event.

      Parameters

      • counter: number

        The counter to set to.

      Returns Promise<void>

    • Murder another a player. This operation can only be called if the player is the impostor on official servers.

      Due to technical limitations, this operation cannot be canceled or reverted without advanced "breaking game", therefore it is out of scope of a single .revert() function on the event emitted.

      Emits a player.murder event.

      Parameters

      Returns Promise<void>

    • Type Parameters

      • EventName extends
            | "component.spawn"
            | "component.despawn"
            | "player.checkcolor"
            | "player.checkmurder"
            | "player.checkname"
            | "player.checkprotect"
            | "player.completetask"
            | "player.die"
            | "player.usemovingplatform"
            | "player.murder"
            | "player.protect"
            | "player.removeprotection"
            | "player.reportbody"
            | "player.revertshapeshift"
            | "player.chat"
            | "player.quickchat"
            | "player.setcolor"
            | "player.sethat"
            | "player.setlevel"
            | "player.setname"
            | "player.setnameplate"
            | "player.setpet"
            | "player.setrole"
            | "player.setskin"
            | "player.setstartcounter"
            | "player.setvisor"
            | "player.shapeshift"
            | "player.startmeeting"
            | "player.syncsettings"

      Parameters

      Returns Promise<PlayerControlEvents<RoomType>[EventName]>

    • Parameters

      • event: string

      Returns Promise<BasicEvent>

    • Type Parameters

      • EventName extends
            | "component.spawn"
            | "component.despawn"
            | "player.checkcolor"
            | "player.checkmurder"
            | "player.checkname"
            | "player.checkprotect"
            | "player.completetask"
            | "player.die"
            | "player.usemovingplatform"
            | "player.murder"
            | "player.protect"
            | "player.removeprotection"
            | "player.reportbody"
            | "player.revertshapeshift"
            | "player.chat"
            | "player.quickchat"
            | "player.setcolor"
            | "player.sethat"
            | "player.setlevel"
            | "player.setname"
            | "player.setnameplate"
            | "player.setpet"
            | "player.setrole"
            | "player.setskin"
            | "player.setstartcounter"
            | "player.setvisor"
            | "player.shapeshift"
            | "player.startmeeting"
            | "player.syncsettings"

      Parameters

      Returns Promise<PlayerControlEvents<RoomType>[EventName]>

    • Type Parameters

      Parameters

      • event: string
      • filter: (ev: K) => boolean | Promise<boolean>

      Returns Promise<BasicEvent>