ClassicUO Logo

#Class: Player

Player.Player

This class references the current player whilst in-game and is accessible on the global scope as the player variable.

Example

A simple script which yells out when the player health is below a threshold

while(true) {
 if(player.hits < 50) {
   player.say('I need healing!');
 }
 sleep(500);
}

#Hierarchy

#Methods

#serialFrom

Static serialFrom(value): number

#Parameters

Name Type
value any

#Returns

number

#Inherited from

Mobile.serialFrom


#say

say(message, hue?): void

Sends a chat message as your player, with an optional hue for the message.

Example

player.say('Hello there!');

#Parameters

Name Type
message string
hue? number

#Returns

void


#cast

cast(spell): void

Casts a spell

Example

player.cast(Spells.Agility);
target.wait();
target.entity(player);

#Parameters

Name Type
spell string | Spells

#Returns

void


#castTo

castTo(spell, serial, timeout?): void

Casts a spell and automatically targets the given serial on the next target

Example

player.castTo(Spells.Heal, player);

#Parameters

Name Type
spell string | Spells
serial SerialOrEntity
timeout? number

#Returns

void


#useSkill

useSkill(skill, target?, timeout?): void

Uses a skill

Example

Use skill without a target

player.useSkill(Skills.Meditation);

@example Use skill and target yourself
```ts
player.useSkill(Skills.Anatomy);

#Parameters

Name Type
skill Skills
target? SerialOrEntity
timeout? number

#Returns

void


#equip

equip(serial): null

Attempts to equip an item if possible

Example

const axe = client.findType(0x0F49); // Axe graphic ID
player.equip(axe);

#Parameters

Name Type
serial SerialOrEntity

#Returns

null


#attack

attack(serial): null

Attacks a mobile

Example

player.attack(target.lastSerial);

#Parameters

Name Type
serial SerialOrEntity

#Returns

null


#fly

fly(): null

Attempt to fly... if you can.

Example

player.fly();

#Returns

null


#land

land(): null

Turn off flying and land

Example

player.land();

#Returns

null


#use

use(serial): null

Attempts to use an object if possible

Example

const dagger = client.findType(0x0F52); // Dagger graphic ID
player.use(dagger);

#Parameters

Name Type
serial SerialOrEntity

#Returns

null


#click

click(serial): null

Simulates clicking an object

Example

player.click(player);

#Parameters

Name Type
serial SerialOrEntity

#Returns

null


#useType

useType(graphic, hue?, sourceSerial?, range?): null

Attempts to use an object of a certain type

Example

player.useType(0x0F52);

#Parameters

Name Type
graphic number
hue? number
sourceSerial? SerialOrEntity
range? number

#Returns

null


#moveItem

moveItem(serial, container, x?, y?, z?, amount?): boolean

Attempts to move an object between containers

Example

if(player.equippedItems.robe) {
  player.moveItem(player.equippedItems.robe, player.backpack);
}

#Parameters

Name Type
serial SerialOrEntity
container number
x? number
y? number
z? number
amount? number

#Returns

boolean


#moveItemOnGroundOffset

moveItemOnGroundOffset(serial, x?, y?, z?, amount?): boolean

Attempts to move an object around on the ground using an offset

Example

const targetInfo = target.queryTarget();
if(targetInfo) {
  player.moveItemOnGroundOffset(targetInfo, 1, 0, 0); // Move item to the east
}

#Parameters

Name Type
serial SerialOrEntity
x? number
y? number
z? number
amount? number

#Returns

boolean


#moveType

moveType(graphic, src, dest, x?, y?, z?, hue?, amount?, range?): boolean

Attempts to move an object of a certain type between containers

Example

player.moveType(0x0F52, player.backpack, bag);

#Parameters

Name Type
graphic number
src SerialOrEntity
dest SerialOrEntity
x? number
y? number
z? number
hue? number
amount? number
range? number

#Returns

boolean


#moveTypeOnGroundOffset

moveTypeOnGroundOffset(graphic, src, x?, y?, z?, hue?, amount?, range?): null

Attempts to move an object of a certain type onto the ground

Example

player.moveType(0x0F52, player.backpack); // Move item to the east

#Parameters

Name Type
graphic number
src SerialOrEntity
x? number
y? number
z? number
hue? number
amount? number
range? number

#Returns

null


#setAbility

setAbility(primary, active): null

Toggle ability on/off

Example

player.setAbility(true, false); // Turn primary ability off
player.setAbility(false, true); // Turn secondary ability on

#Parameters

Name Type
primary boolean
active boolean

#Returns

null


#walk

walk(direction): boolean

Walk/turn a single step in a direction

Example

player.walk(Directors.North);

#Parameters

Name Type
direction Directions

#Returns

boolean

True if character can walk


#run

run(direction): boolean

Run/turn a single step in a direction

Example

player.run(Directions.South);

#Parameters

Name Type
direction Directions

#Returns

boolean

True if character can run


#setSkillLock

setSkillLock(skill, lock): null

Set the status of a skill lock

Example

player.setSkillLock(Skills.Anatomy, SkillLock.Down);

#Parameters

Name Type
skill Skills
lock SkillLock

#Returns

null


#hasBuffDebuff

hasBuffDebuff(buffID): boolean

#Parameters

Name Type
buffID BuffDebuffs

#Returns

boolean

#Accessors

#graphic

get graphic(): number

Gets the graphic id of the entity. Returns 0 if entity is no longer on screen.

Example

console.log(player.graphic); // e.g. 400

#Returns

number

#Inherited from

Mobile.graphic


#x

get x(): number

Gets the current X coordinate of the entity. Returns 0 if entity is no longer on screen.

Example

const entity = client.findObject(player); // Replace with any other entity serial
console.log(entity.x)

#Returns

number

#Inherited from

Mobile.x


#y

get y(): number

Gets the current Y coordinate of the entity. Returns 0 if entity is no longer on screen.

Example

const entity = client.findObject(player);
console.log(entity.y)

#Returns

number

#Inherited from

Mobile.y


#z

get z(): number

Gets the current Z coordinate of the entity. Returns 0 if entity is no longer on screen.

Example

const entity = client.findObject(player);
console.log(entity.z)

#Returns

number

#Inherited from

Mobile.z


#name

get name(): string

Gets the name of the entity. Returns an empty string if not known to the client yet.

Example

const entity = client.findObject(player.equippedItems.robe);
if(entity) {
 console.log(entity.name);
}

#Returns

string

#Inherited from

Mobile.name


#hue

get hue(): number

Gets the hue/color of the entity. Returns 0 if entity is no longer on screen.

Example

const entity = client.findObject(player.equippedItems.robe);
if(entity) {
 console.log(entity.name);
}

#Returns

number

#Inherited from

Mobile.hue


#hits

get hits(): number

Gets the hits of the entity. Returns 0 if the client does not know (e.g. item.hits) or the entity is no longer on screen.

Example

const entity = client.findObject(0x991);
if(entity) {
 console.log(entity.hits);
}

#Returns

number

#Inherited from

Mobile.hits


#maxHits

get maxHits(): number

Gets the maxHits of the entity. Returns 0 if the client does not know (e.g. item.maxHits) or the entity is no longer on screen.

Example

const entity = client.findObject(0x991);
if(entity) {
 console.log(entity.maxHits);
}

#Returns

number

#Inherited from

Mobile.maxHits


#direction

get direction(): number

Gets the direction of the entity as a number, if it has one. Returns 0 if the client does not know (e.g. item.maxHits) or the entity is no longer on screen.

Compare using the Directions enum.

Example

const entity = client.findObject(0x991);
if(entity) {
  if(entity.direction === Directions.North) {
    console.log(`${entity.name} is facing North`);
  }
  else {
    console.log(Directions[entity.direction]); // Prints the directions name, e.g. East
  }
}

#Returns

number

#Inherited from

Mobile.direction


#isHidden

get isHidden(): boolean

#Returns

boolean

#Inherited from

Mobile.isHidden


#stamina

get stamina(): number

#Returns

number

#Inherited from

Mobile.stamina


#maxStamina

get maxStamina(): number

#Returns

number

#Inherited from

Mobile.maxStamina


#mana

get mana(): number

#Returns

number

#Inherited from

Mobile.mana


#maxMana

get maxMana(): number

#Returns

number

#Inherited from

Mobile.maxMana


#isPoisoned

get isPoisoned(): boolean

#Returns

boolean

#Inherited from

Mobile.isPoisoned


#isYellowHits

get isYellowHits(): boolean

#Returns

boolean

#Inherited from

Mobile.isYellowHits


#isFemale

get isFemale(): boolean

#Returns

boolean

#Inherited from

Mobile.isFemale


#notoriety

get notoriety(): Notorieties

#Returns

Notorieties

#Inherited from

Mobile.notoriety


#inWarMode

get inWarMode(): boolean

#Returns

boolean

#Inherited from

Mobile.inWarMode


#isParalyzed

get isParalyzed(): boolean

#Returns

boolean

#Inherited from

Mobile.isParalyzed


#isDead

get isDead(): boolean

#Returns

boolean

#Inherited from

Mobile.isDead


#equippedItems

get equippedItems(): Object

#Returns

Object

Name Type
shirt? Item
pants? Item
shoes? Item
legs? Item
torso? Item
ring? Item
talisman? Item
bracelet? Item
face? Item
arms? Item
gloves? Item
skirt? Item
tunic? Item
robe? Item
necklace? Item
hair? Item
waist? Item
beard? Item
earrings? Item
oneHanded? Item
helmet? Item
twoHanded? Item
cloak? Item
mount? Item

#Inherited from

Mobile.equippedItems


#serial

get serial(): number

#Returns

number

#Overrides

Mobile.serial


#coldResistance

get coldResistance(): number

#Returns

number


#damageIncrease

get damageIncrease(): number

#Returns

number


#damageMax

get damageMax(): number

#Returns

number


#damageMin

get damageMin(): number

#Returns

number


#defenseChanceIncrease

get defenseChanceIncrease(): number

#Returns

number


#dexterity

get dexterity(): number

#Returns

number


#energyResistance

get energyResistance(): number

#Returns

number


#fasterCasting

get fasterCasting(): number

#Returns

number


#fasterCastRecovery

get fasterCastRecovery(): number

#Returns

number


#fireResistance

get fireResistance(): number

#Returns

number


#followers

get followers(): number

#Returns

number


#maxFollowers

get maxFollowers(): number

#Returns

number


#gold

get gold(): number

#Returns

number


#hitChanceIncrease

get hitChanceIncrease(): number

#Returns

number


#intelligence

get intelligence(): number

#Returns

number


#lowerManaCost

get lowerManaCost(): number

#Returns

number


#lowerReagentCost

get lowerReagentCost(): number

#Returns

number


#luck

get luck(): number

#Returns

number


#maxColdResistence

get maxColdResistence(): number

#Returns

number


#maxDefenseChanceIncrease

get maxDefenseChanceIncrease(): number

#Returns

number


#maxEnergyResistence

get maxEnergyResistence(): number

#Returns

number


#maxFireResistence

get maxFireResistence(): number

#Returns

number


#maxPhysicResistence

get maxPhysicResistence(): number

#Returns

number


#maxPoisonResistence

get maxPoisonResistence(): number

#Returns

number


#physicalResistance

get physicalResistance(): number

#Returns

number


#poisonResistance

get poisonResistance(): number

#Returns

number


#spellDamageIncrease

get spellDamageIncrease(): number

#Returns

number


#statsCap

get statsCap(): number

#Returns

number


#strength

get strength(): number

#Returns

number


#swingSpeedIncrease

get swingSpeedIncrease(): number

#Returns

number


#tithingPoints

get tithingPoints(): number

#Returns

number


#weight

get weight(): number

#Returns

number


#weightMax

get weightMax(): number

#Returns

number


#primaryAbility

get primaryAbility(): Abilities

#Returns

Abilities


#secondaryAbility

get secondaryAbility(): Abilities

#Returns

Abilities


#hunger

get hunger(): number

#Returns

number


#shortTermMurders

get shortTermMurders(): number

#Returns

number


#longTermMurders

get longTermMurders(): number

#Returns

number


#healBonus

get healBonus(): number

#Returns

number


#magicImmunity

get magicImmunity(): number

#Returns

number


#magicReflect

get magicReflect(): number

#Returns

number


#physicalProtection

get physicalProtection(): number

#Returns

number


#poisonProtection

get poisonProtection(): number

#Returns

number


#fireProtection

get fireProtection(): number

#Returns

number


#waterProtection

get waterProtection(): number

#Returns

number


#airProtection

get airProtection(): number

#Returns

number


#earthProtection

get earthProtection(): number

#Returns

number


#necroProtection

get necroProtection(): number

#Returns

number


#backpack

get backpack(): undefined | Item

#Returns

undefined | Item