Skip to content
KabanFriends edited this page Jan 11, 2024 · 15 revisions

A Player is an object that holds a ClassiCube player. It can be accessed from events or by using level.getPlayers() or level.getPlayer(name).

name : string

  • Name of the player. Uses the "true name", which does not contain + at the end even if the server is set to use classicube-account-plus.

x : number

  • X coordinate of the player in decimal.

y : number

  • Y coordinate of the player in decimal.

z : number

  • Z coordinate of the player in decimal.

px : number

  • "Precise" X coordinate used for /TP -precise. Coordinate in units with 1 block being 32 units.

py : number

  • "Precise" Y coordinate used for /TP -precise. Coordinate in units with 1 block being 32 units.

pz : number

  • "Precise" Z coordinate used for /TP -precise. Coordinate in units with 1 block being 32 units.

yaw : number

  • Yaw of the player in decimal.

pitch : number

  • Pitch of the player in decimal.

motd : string

  • The motd currently set for the player.

cef : boolean

mobile : boolean

  • A boolean value that is true if the player is logged in using mobile version of ClassiCube.

web : boolean

  • A boolean value that is true if the player is logged in using web browser version of ClassiCube.

model : string

  • Name of the model that the player is currently using.

heldBlock : number

  • ID of the block that the player is currently holding.

message(string: content)

  • Shows a chat message to the player.

cpeMessage(string: location, string: message)

  • Shows a CPE message to the player. Has a text lengths limit of 64 characters.
    Available values for location:
    • announce
    • bigAnnounce
    • smallAnnounce
    • top1
    • top2
    • top3
    • bottom1
    • bottom2
    • bottom3
    • chat

Reference image:

kill(string: message)

  • Kills the player and broadcasts a death message to everyone in the same level.

command(string: cmd)

  • Makes the player execute a command. Some commands are blocked to be used in this function.

tempBlock(number/string: block, number: x, number: y, number: z)

  • Displays a block at the specified coordinate to the player. This will not affect the level itself, and other players cannot see the block.
  • The block parameter can be either a number of the block ID, or a string of the block name.

tempChunk(number: x1, number: y1, number: z1, number: x2, number: y2, number: z2, number: x3, number: y3, number: z3, [boolean: toAll])

  • Copies a chunk of the world defined by first (xyz1) and second (xyz2) coordinates, then pastes it into the spot defined by the third (xyz3) coordinates.
  • The toAll boolean is an optional parameter. If true, the tempchunk changes are sent to all players in the same level.

freeze()

  • Makes the player unable to move or use hacks.

unfreeze()

  • Makes the player able to move, and use hacks if they are allowed on the level.

look(number: x, number: y, number: z)

  • Makes the player look at the specified coordinate.

setEnv(string: property, any: value)

  • Changes the environment property of the player.
  • Available property names and their values:
    • sky → Hex color (string)
    • skybox → Hex color (string)
    • cloud → Hex color (string)
    • fog → Hex color (string)
    • shadow → Hex color (string)
    • sun → Hex color (string)
    • weather → Weather type (string):
      • sun, rain, snow
    • maxFog → Fog distance (number)
    • expFog → Smooth fog (boolean)
    • cloudHeight → Cloud height (number)
    • cloudSpeed → Cloud Speed (number)

Examples:

player.setEnv("sky", "c0ffee")
player.setEnv("weather", "snow")
player.setEnv("maxFog", 69)

setMotd(string: motd)

  • Changes the MOTD of the player. Use /help motd to see a list of MOTD flags.

setMotd()

  • Resets the MOTD of the player to the default MOTD of the level.

setSpawn(number: x, number: y, number: z)

  • Sets the spawnpoint of the player to the specified coordinate.

addHotkey(string: input, string: key, string: modifiers...)

  • Adds a hotkey for the player. Pressing the key will make the player run the /input command with the specified input string. (Thus triggering the onPlayerInput event)
  • Hotkeys defined by the level script will automatically be removed when the player leaves the level.
  • See https://minecraft.fandom.com/el/wiki/Key_codes#Full_table for a list of key names.
  • Available modifier key names:
    • shift
    • ctrl
    • alt

Examples:

player.addHotkey("cat", "L") -- Runs "/input cat" when pressing L
player.addHotkey("hello chat", "F", "ctrl", "shift") -- Runs "/input hello chat" when pressing Ctrl + Shift + F

removeHotkey(string: key, string: modifiers...)

  • Removes a hotkey defined using addHotkey.

setReach(number: distance)

  • Temporarily changes the reach distance of the player. Using setMotd or leaving the level will reset the reach distance.
  • Default reach distance is 5 blocks.

setModel(string: model)

  • Changes the model of the player. Leaving the level will reset the model to the model that the player previously had.

launch(number: x, number: y, number: z, boolean: xAdd, boolean: yAdd, boolean: zAdd)

  • Sets the velocity of the player to the specified X, Y and Z values.
  • If the "add" boolean is true, the specified velocity component value will be added to the player's current velocity. (e.g. if xAdd is true, the value x will be added to the player's current x velocity)

setHotbar(number: slot, string/number: block)

  • Changes a slot of the player's hotbar to the specified block.
  • The block parameter can be either a number of the block ID, or a string of the block name.

teleport(number: x, number: y, number: z, [number: yaw, number: pitch])

  • Teleports the player to the specified coordinate. Unlike /TP command, this function accepts decimal numbers.
  • yaw and pitch values are optional. If these values are not specified, it will not keep the player's rotation.

playParticle(string: name, number: x, number: y, number: z, [number: originX, number: originY, number: originZ])

  • Plays a particle effect by given name. Particle effects must be reigstered before playing one. See Particle page for more information.
  • originX, originY, originZ are optional parametrs to determine from which the particles move away.
Clone this wiki locally