# Player Management

Derive from Actor

Before using player API, please create player management object. The methods as follows:

local Player = class.Player.new()

The specific function name and description are as follows:

Serial number Function name Description
1 getAttr(...) Player attribute setting
2 setAttr(...) Obtain Player attribute
3 getHostUin(...) Obtain uin of host
4 isMainPlayer(...) Whether it is local player
5 getMainPlayerUin(...) Get the local player's uin
6 getGameResults(...) Get result of the game
7 setGameResults(...) Set result of the game
8 getGameScore(...) Get score of the game
9 setGameScore(...) Set score of the game
10 getGameRanking(...) Get the rank of player
11 setGameRanking(...) Set the rank of player
12 gainItems(...) Add items for players
13 teleportHome(...) Transfer to spawn point
14 getCurToolID(...) Get the item id currently held by the player
15 getNickname(...) Get the player's name
16 removeBackpackItem(...) Remove items in backpack
17 getDieTimes(...) Get the number of deaths
18 getLeftLifeNum(...) Get the number of remaining lives left
19 setTeam(...) Set player team
20 getTeam(...) Obtain player team
21 getFoodLevel(...) Get the current satiety
22 setFoodLevel(...) Set satiety of player
23 getCurShotcut(...) Get the current shortcut bar
24 onCurToolUsed(...) Set the consumption of item held by player
25 setSkillCD(...) Set CD
26 reviveToPos(...) Respawn player at designated point
27 setRevivePoint(...) Change the respawn point
28 mountActor(...) Player rides the mount 1.1+
29 playAct(...) Player play the cartoon
30 notifyGameInfo2Self(...) Display texts in popup window
31 useItem(...) Make player use current item
32 rotateCamera(...) Rotate player's lens
33 changeViewMode(...) Change angle mode of player
34 setActionAttrState(...) Set attribute status of player behavior
35 checkActionAttrState(...) Obtain status of player special attribute
36 setPosition(...) Set the location of player
37 getAimPos(...) Get the crosshair location of player
38 setItemAttAction(...) Set the setting attribute of player item 1.1+
39 playMusic(...) Play background music to players 1.3+
40 stopMusic(...) Stop background music to players 1.3+

# getAttr

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Player attribute setting
  • The specific use cases are as follows:
local result = Player:getAttr(objid, attrtype)

# setAttr

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain Player attribute
  • The specific use cases are as follows:
local result = Player:setAttr(objid, attrtype, val)

# getHostUin

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: Obtain uin of host
  • The specific use cases are as follows:
local result = Player:getHostUin()

# isMainPlayer

  • Parameters and types:
  • Return value and types:
    • ErrorCode.OK is that local player is local player
  • The main role of this method: Whether it is local player
  • The specific use cases are as follows:
local result = Player:isMainPlayer(objid)

# getMainPlayerUin

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: Get the local player's uin
  • The specific use cases are as follows:
local result = Player:getMainPlayerUin()

# getGameResults

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get result of the game
  • The specific use cases are as follows:
local result = Player:getGameResults(objid)

# setGameResults

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set result of the game
  • The specific use cases are as follows:
local result = Player:setGameResults(objid, result)

# getGameScore

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get score of the game
  • The specific use cases are as follows:
local result = Player:getGameScore(objid)

# setGameScore

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set score of the game
  • The specific use cases are as follows:
local result = Player:setGameScore(objid, score)

# getGameRanking

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the rank of player
  • The specific use cases are as follows:
local result = Player:getGameRanking(objid)

# setGameRanking

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the rank of player
  • The specific use cases are as follows:
local result = Player:setGameRanking(objid, rank)

# gainItems

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add items for players
  • The specific use cases are as follows:
local result = Player:gainItems(objid, itemid, num, prioritytype)

# teleportHome

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Transfer to spawn point
  • The specific use cases are as follows:
local result = Player:teleportHome(objid)

# getCurToolID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the item id currently held by the player
  • The specific use cases are as follows:
local result = Player:getCurToolID(objid)

# getNickname

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the player's name
  • The specific use cases are as follows:
local result = Player:getNickname(objid)

# removeBackpackItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove items in backpack
  • The specific use cases are as follows:
local result = Player:removeBackpackItem(objid, itemid, num)

# getDieTimes

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the number of deaths
  • The specific use cases are as follows:
local result = Player:getDieTimes(objid)

# getLeftLifeNum

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the number of remaining lives left
  • The specific use cases are as follows:
local result = Player:getLeftLifeNum(objid)

# setTeam

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set player team
  • The specific use cases are as follows:
local result = Player:setTeam(objid, teamid)

# getTeam

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain player team
  • The specific use cases are as follows:
local result = Player:getTeam(objid)

# getFoodLevel

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current satiety
  • The specific use cases are as follows:
local result = Player:getFoodLevel(objid)

# setFoodLevel

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set satiety of player
  • The specific use cases are as follows:
local result = Player:setFoodLevel(objid, foodLevel)

# getCurShotcut

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current shortcut bar
  • The specific use cases are as follows:
local result = Player:getCurShotcut(objid)

# onCurToolUsed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the consumption of item held by player
  • The specific use cases are as follows:
local result = Player:onCurToolUsed(objid, num)

# setSkillCD

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set CD
  • The specific use cases are as follows:
local result = Player:setSkillCD(objid, itemid, cd)

# reviveToPos

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Respawn player at designated point
  • The specific use cases are as follows:
local result = Player:reviveToPos(objid, x, y, z)

# setRevivePoint

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Change the respawn point
  • The specific use cases are as follows:
local result = Player:setRevivePoint(objid, x, y, z)

# mountActor 1.1+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Player rides the mount
  • The specific use cases are as follows:
local result = Player:mountActor(playerid, objid, posindex)

# playAct

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Player play the cartoon
  • The specific use cases are as follows:
local result = Player:playAct(objid, actid)

# notifyGameInfo2Self

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Display texts in popup window
  • The specific use cases are as follows:
local result = Player:notifyGameInfo2Self(objid, info)

# useItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Make player use current item
  • The specific use cases are as follows:
local result = Player:useItem(objid, itemid, status, onshift)

# rotateCamera

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Rotate player's lens
  • The specific use cases are as follows:
local result = Player:rotateCamera(objid, yaw, pitch)

# changeViewMode

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Change angle mode of player
  • The specific use cases are as follows:
local result = Player:changeViewMode(objid, viewmode, islock)

# setActionAttrState

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set attribute status of player behavior
  • The specific use cases are as follows:
local result = Player:setActionAttrState(objid, actionattr, switch)

# checkActionAttrState

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain status of player special attribute
  • The specific use cases are as follows:
local result = Player:checkActionAttrState(objid, actionattr)

# setPosition

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the location of player
  • The specific use cases are as follows:
local result = Player:setPosition(objid, x, y, z)

# getAimPos

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the crosshair location of player
  • The specific use cases are as follows:
local result = Player:getAimPos(objid)

# setItemAttAction 1.1+

local result = Player:setItemAttAction(objid, itemid, attrtype, switch)

# playMusic 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Play background music to players
  • The specific use cases are as follows:
local result = Player:playMusic(objid, musicId, volume, pitch, isLoop)

# stopMusic 1.3+

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Stop background music to players
  • The specific use cases are as follows:
local result = Player:stopMusic(objid)
Last Update: 11/22/2019, 2:31:59 PM