Table of Contents

Players Class

Class For Players Interface

Return To Previous Page


How to Write Event

 ScriptSupportEvent:registerEvent([[EventName]],callbackFunctionName) 

Example

function BuffAdded(event)
  local playerid , buffid , bufflvl = event.eventobjid , event.buffid , event.bufflvl
end
 
ScriptSupportEvent:registerEvent([[Player.AddBuff]],BuffAdded) 

Eventlist

EventName Parameters Description
Game.AnyPlayer.Defeat eventobjid: number, shortix,x,y,z Any Players Defeat
Game.AnyPlayer.EnterGame eventobjid: number, shortix,x,y,z Any Players Enter Game
Game.AnyPlayer.LeaveGame eventobjid: number, shortix,x,y,z Any Players Leave Game
Game.AnyPlayer.Victory eventobjid: number, shortix,x,y,z Any Players Win game
Player.AddBuff eventobjid: number, buffid: number, bufflvl: number The player gets a status effect
Player.AddItem eventobjid: number, itemid: number, itemnum: number The player gets an item
Player.AreaIn eventobjid: number, areaid: number Player enters an area
Player.AreaOut eventobjid: number, areaid: number Player leaves an area
Player.AttackHit eventobjid: number, targetactorid: number Player hits a target
Player.Attack eventobjid: number, shortix: number, x: number, y: number, z: number Player performs an attack
Player.BackPackChange eventobjid: number, itemid: number, itemnum: number, itemix: number Backpack Slot Changes
Player.BeHurt eventobjid: number, hurtlv: number Player takes damage
Player.ChangeAttr eventobjid: number, shortix: number, playerattr: number, playerattrval: number, x: number, y: number, z: number Player attribute changes
Player.ClickActor eventobjid: number, toobjid : number, targetactorid: number Player clicks on a bio (actor)
Player.ClickBlock eventobjid: number, blockid: number, x: number, y: number, z: number Player clicks on a block
Player.Collide eventobjid: number, toobjid: number Player collides with another player/mob
Player.ConsumeItem eventobjid: number, itemid: number, itemnum: number Player consumes an item
Player.DamageActor eventobjid: number, toobjid: number, targetactorid: number, hurtlv: number Player inflicts damage to a target
Player.DefeatActor eventobjid: number, toobjid: number, targetactorid: number Player defeats a target
Player.Die eventobjid: number, shortix: number, x: number, y: number, z: number Player dies
Player.DiscardItem eventobjid: number, itemid: number, itemnum: number, toobjid: number Player discards an item
Player.DismountActor eventobjid: number, targetactorid: number Player dismounts from an actor
Player.EquipChange eventobjid: number, itemid: number, itemnum: number, itemix: number Equipment column changes
Player.EquipOff eventobjid: number, itemid: number, itemnum: number, itemix: number Player takes off equipment
Player.EquipOn eventobjid: number, itemid: number, itemnum: number, itemix: number Player equips an item
Player.InputContent eventobjid: number, content: string Player inputs a string
Player.InputKeyDown eventobjid: number, vkey: number Player presses a key
Player.InputKeyOnPress eventobjid: number, vkey: number Player long-presses a key
Player.InputKeyUp eventobjid: number, vkey: number Player releases a key
Player.LevelModelUpgrade eventobjid: number Player's level changes
Player.MotionStateChange eventobjid: number, playermotion: number Player's motion state changes
Player.MountActor eventobjid: number, targetactorid: number Player mounts on an actor
Player.MoveOneBlockSize eventobjid: number, shortix: number, x: number, y: number, z: number Player moves one block size
Player.NewInputContent eventobjid: number, content: string Player types from the chat box
Player.PickUpItem eventobjid: number, toobjid: number, itemid: number, itemnum: number Player picks up an item
Player.PlayAction eventobjid: number, act: number Player performs an emote/action
Player.RemoveBuff eventobjid: number, buffid: number, bufflvl: number The player loses a specified status effect
Player.Revive eventobjid: number, shortix: number, x: number, y: number, z: number Player revives
Player.SelectShortcut eventobjid: number, itemid: number, itemnum: number Shortcut bar selection
Player.ShortcutChange eventobjid: number, itemid: number, itemnum: number, itemix: number Quick Bar Changes
Player.UseGiftPack eventobjid: number, itemid: number, itemnum: number Player uses a gift pack
Player.UseItem eventobjid: number, itemid: number, itemnum: number, itemix: number Player uses an item

Api List

Class:apiName Return Description
Player:getAttr(objid: number, attrtype: number) ErrorCode.OK, value: number Player attribute acquisition
Player:setAttr(objid: number, attrtype: number, val: number) ErrorCode.OK Player attribute setting
Player:getHostUin() ErrorCode.OK, uin: number Get the owner uin
Player:isMainPlayer(objid: number) ErrorCode.OK, isMainPlayer: bool Check if the player is the local player
Player:getMainPlayerUin() ErrorCode.OK, uin: number Get the uin of the local player
Player:getGameResults(objid: number) ErrorCode.OK, value: number Get the player's game result
Player:setGameResults(objid: number, result: any) ErrorCode.OK Set the player's game result
Player:getGameScore(objid: number) ErrorCode.OK, value: number Get the player's game score
Player:setGameScore(objid: number, score: number) ErrorCode.OK Set the player's game score
Player:getGameRanking(objid: number) ErrorCode.OK, rank: number Get the player's ranking
Player:setGameRanking(objid: number, rank: number) ErrorCode.OK Set the player's ranking
Player:gainItems(objid: number, itemid: number, num: number, prioritytype: number) ErrorCode.OK Add props to the player
Player:teleportHome(objid: number) ErrorCode.OK Teleport to the birth point
Player:getCurToolID(objid: number) ErrorCode.OK, ret: numbers Get the item id currently held by the player
Player:getNickname(objid: number) ErrorCode.OK, name: string Get the player's nickname
Player:removeBackpackItem(objid: number, itemid: number, num: number) ErrorCode.OK Remove the items in the backpack
Player:getDieTimes(objid: number) ErrorCode.OK, value: number Get the number of player deaths
Player:getLeftLifeNum(objid: number) ErrorCode.OK, value: number Get the number of lives left by the player
Player:setTeam(objid: number, teamid: number) ErrorCode.OK Set the player's team
Player:getTeam(objid: number) ErrorCode.OK, value: number Get the player's team
Player:getFoodLevel(objid: number) ErrorCode.OK, value: number Get the player's current satiety
Player:setFoodLevel(objid: number, foodLevel: number) ErrorCode.OK Set the player's satiety
Player:getCurShotcut(objid: number) ErrorCode.OK, scutIdx: number Get the index of the currently used shortcut bar key
Player:onCurToolUsed(objid: number, num: number) ErrorCode.OK Set the consumption of props held by the current player
Player:setSkillCD(objid: number, itemid: number, cd: number) ErrorCode.OK Set the cooldown for a skill
Player:reviveToPos(objid: number, x: number, y: number, z: number) ErrorCode.OK Revive the player to the specified point
Player:setRevivePoint(objid: number, x: number, y: number, z: number) ErrorCode.OK Change the position of the player's resurrection point
Player:mountActor(playerid: number, objid: number, posindex: number) ErrorCode.OK The player rides on the mount
Player:playAct(objid: number, actid: number) ErrorCode.OK The player plays the animation
Player:notifyGameInfo2Self(objid: number, info: string) ErrorCode.OK Display the bay window text to the player
Player:useItem(objid: number, itemid: number, status: number, onshift: boolean) ErrorCode.OK Enable the player to use the current props
Player:rotateCamera(objid: number, yaw: number, pitch: number) ErrorCode.OK Rotate the player's camera
Player:changeViewMode(objid: number, viewmode: VIEWPORTTYPEnumber, islock: boolean) ErrorCode.OK Change the player's perspective mode
Player:setActionAttrState(objid: number, actionattr: PLAYERATTR_ENABLEnumber, switch: boolean) ErrorCode.OK Set the player's behavior attribute status
Player:checkActionAttrState(objid: number, actionattr: PLAYERATTR_ENABLEnumber) ErrorCode.OK Get the status of the player's special attributes
Player:isEquipByResID(objid: number, resid: number) ErrorCode.OK Check if the player is equipped with a piece of equipment
Player:setPosition(objid: number, x: number, y: number, z: number) ErrorCode.OK Set the player's position
Player:getAimPos(objid: number) ErrorCode.OK, aimPos: table{x, y, z} Get the position of the player's crosshair
Player:setItemAttAction(objid: number, itemid: number, attrtype: PLAYERATTR_ITEMnumber, switch: boolean) ErrorCode.OK Set the player's props attributes: discard, drop
Player:playMusic(objid: number, musicId: number, volume: number, pitch: number, isLoop: bool) ErrorCode.OK Play background music to the player
Player:stopMusic(objid: number) ErrorCode.OK Stop playing the player's background music
Player:setGameWin(objid: number) ErrorCode.OK Make the player win the game
Player:openDevStore(objid: number) ErrorCode.OK Open the developer store
Player:getPropsType(objid: number) ErrorCode.OK, value: number Get the type of props held by the player
Player:setCheckBoxScale(objid: number, range: number) ErrorCode.OK Set the radius of the detection of falling objects
Player:openBoxByPos(objid: number, x: number, y: number, z: number) ErrorCode.OK Open the operable box at the specified position
Player:forceOpenBoxUI(objid: number, itemid: number) ErrorCode.OK Forcibly open operable blocks such as toolboxes
Player:openDevGoodsBuyDialog(objid: number, devGoodsId: number, customDesc: string) ErrorCode.OK Open the pop-up window of the developer store product
Player:changePlayerMoveType(objid: number, moveType: number) ErrorCode.OK Change the way the player moves
Player:setImmuneType(objid: number, immunetype: number, isadd: bool) ErrorCode.OK Set the player immune damage type
Player:shakeCamera(objid: number, duration: number, power: number) ErrorCode.OK Shake the player camera
Player:stopShakeCamera(objid: number) ErrorCode.OK Stop shaking the player camera
Player:playQQMusic(objid: number, musicId: number, volume: number, isLoop: boolean) ErrorCode.OK The player plays QQ music
Player:operateQQMusic(operate: number, objid: number) ErrorCode.OK Pause/resume/stop the player's QQ music
Player:OpenAppraiseView(objid: number) ErrorCode.OK Open the evaluation interface (can only be triggered after playing the game for more than 3 minutes. Ten-minute CD after the trigger)
Player:OpenCollectionView(objid: number) ErrorCode.OK Open the collection interface (can only be triggered after playing the game for more than 3 minutes. Ten-minute CD after the trigger)
Player:IsMiniVip(objid: number) ErrorCode.OK Determine whether it is a mini member
Player:SendFriendApply(playerid: number, playerid2: number) ErrorCode.OK Send a friend request
Player:HasFriend(playerid: number, playerid2: number) ErrorCode.OK Determine whether playerid has friends playerid2
Player:PlayActInHand(playerid: number, animid: number, playmode: number) ErrorCode.OK The player holds the miniature props to play the animation
Player:openDevStoreNew(objid: number) ErrorCode.OK The player opens the developer store (only available to developers)
Player:OpenBuiltinRank(objid: number, id: number) ErrorCode.OK Open the built-in leaderboard
Player:HideBuiltinRank(objid: number) ErrorCode.OK Hide the built-in leaderboard
Player:openDevGoodsBuyDetailedDialog(objid: number, devGoodsId: number) ErrorCode.OK Open the product details page of the developer store
Player:setMobileVibrate(playerid: number, time: number, amplitude: number) ErrorCode.OK The player's mobile phone vibrates
Player:SetCameraPosTransformBy(playerid: number, vec: table, animid: number, time: number) ErrorCode.OK The player's camera changes relative position
Player:SetCameraPosTransformTo(playerid: number, vec: table, animid: number, time: number) ErrorCode.OK The player camera changes to the position
Player:SetCameraRotTransformBy(playerid: number, vec: table, animid: number, time: number) ErrorCode.OK The relative angle of the player's camera rotation
Player:SetCameraRotTransformTo(playerid: number, vec: table, animid: number, time: number) ErrorCode.OK The player camera is rotated to the angle
Player:SetCameraFovTransformBy(playerid: number, value: number, animid: number, time: number) ErrorCode.OK The relative value of the Fov transformation of the player camera
Player:SetCameraFovTransformTo(playerid: number, value: number, animid: number, time: number) ErrorCode.OK The player camera Fov is transformed to the value
Player:SetCameraAttrState(playerid: number, attr: number, enable: boolean) ErrorCode.OK Set the player's camera settings switch
Player:SetCameraRotMode(playerid: number, attr: number) ErrorCode.OK Set the player's camera rotation mode
Player:SetCameraMountObj(playerid: number, objid: number) ErrorCode.OK Set the player's camera to mount to the object
Player:SetCameraMountPos(playerid: number, pos: table) ErrorCode.OK Set the player's camera to mount to the position
Player:ResetCameraAttr(playerid: number) ErrorCode.OK Reset the player camera

Player constants

Player Attributes

Name Value Description
PLAYERATTR.MAX_HP 1 Max health point
PLAYERATTR.CUR_HP 2 Current health point
PLAYERATTR.HP_RECOVER 3 Health point recovery
PLAYERATTR.LIFE_NUM 4 Number of life
PLAYERATTR.MAX_HUNGER 5 Max hunger point
PLAYERATTR.CUR_HUNGER 6 Current hunger point
PLAYERATTR.MAX_OXYGEN 7 Max oxygen point
PLAYERATTR.CUR_OXYGEN 8 Current oxygen point
PLAYERATTR.RECOVER_OXYGEN 9 Speed of oxygen recovery
PLAYERATTR.WALK_SPEED 10 Walking speed
PLAYERATTR.RUN_SPEED 11 Running speed
PLAYERATTR.SNEAK_SPEED 12 Sneaking speed
PLAYERATTR.SWIN_SPEED 13 Swimming speed
PLAYERATTR.JUMP_POWER 14 Jumping force
PLAYERATTR.DODGE 16 Dodge rate
PLAYERATTR.ATK_MELEE 17 Melee attack
PLAYERATTR.ATK_REMOTE 18 Ranged attack
PLAYERATTR.DEF_MELEE 19 Melee defense
PLAYERATTR.DEF_REMOTE 20 Ranged defense
PLAYERATTR.DIMENSION 21 Model Size
PLAYERATTR.SCORE 22 Score
PLAYERATTR.LEVEL 23 Star Level
PLAYERATTR.CUR_LEVEL 27 Current level
PLAYERATTR.CUR_STRENGTH 28 Current stamina
PLAYERATTR.MAX_STRENGTH 29 Maximum stamina
PLAYERATTR.STRENGTH_RECOVER 30 Stamina recovery rate
PLAYERATTR.CUR_LEVELEXP 26 Current experience points

Player Attributes Setup

Name Value Description
PLAYERATTR.ENABLE_MOVE 1 Can move
PLAYERATTR.ENABLE_PLACEBLOCK 2 Can place blocks
PLAYERATTR.ENABLE_OPERATEBLOCK 4 Can use blocks
PLAYERATTR.ENABLE_DESTROYBLOCK 8 Can break blocks
PLAYERATTR.ENABLE_USEITEM 16 Can use items
PLAYERATTR.ENABLE_ATTACK 32 Can attack
PLAYERATTR.ENABLE_BEATTACKED 64 Can be attacked
PLAYERATTR.ENABLE_BEKILLED 128 Can be killed
PLAYERATTR.ENABLE_PICKUP 256 Can pick up items
PLAYERATTR.ENABLE_DEATHDROPITEM 512 Drop items when die
PLAYERATTR.ENABLE_VEHICLEAUTOFORWARD 1024 Vehicle Automatic Pilot
PLAYERATTR.ENABLE_DISCARDITEM 2048 Can discard items

Player Items Setup

Name Value Description
PLAYERATTR.ITEM_DISABLE_THROW 1 Cannot discard items
PLAYERATTR.ENABLE_PLACEBLOCK 2 Cannot drop items

Player Motions

Name Value Description
PLAYERMOTION.STATIC 0 Stay still
PLAYERMOTION.WALK 1 Walk
PLAYERMOTION.RUN 2 Run
PLAYERMOTION.JUMP 4 Jump
PLAYERMOTION.JUMP_TWICE 8 Double jump
PLAYERMOTION.SNEAK 16 Sneak
PLAYERMOTION.FALL_GROUND 32 Fall to ground