# Team Management

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

local Team = class.Team.new()

The specific function name and description are as follows:

Serial number Function name Description
1 getNumTeam(...) The number of current team
2 getTeamPlayerNum(...) Obtain the number of players in designate team
3 getTeamPlayers(...) Get the designate player team
4 randomTeamPlayer(...) Random Player
5 getTeamCreatures(...) Obtain creature in designate team(like getTeamPlayers)
6 setTeamScore(...) Score of team
7 getTeamScore(...) Get the team score
8 addTeamScore(...) Increase the team score
9 setTeamResults(...) Result of team
10 getTeamResults(...) Get the current win-los of team
11 setTeamPlayersResults(...) Set the win-los of player team
12 setTeamDieTimes(...) Number of team deaths
13 getTeamDieTimes(...) Get the total deaths of team
14 addTeamDieTimes(...) Increase the total deaths of team
15 changePlayerTeam(...) Change player's team

# getNumTeam

  • Parameters and types:nil
  • Return value and types:
  • The main role of this method: The number of current team
  • The specific use cases are as follows:
--Get the number of teams
local result,num=Team:getNumTeam()
--Show in chat box
Chat:sendSystemMsg("The current number of teams is:"..num)

# getTeamPlayerNum

  • Parameters and types:
    • teamid:numberTeam ID, default all
    • alive:numberWhether survive, default all
  • Return value and types:
  • The main role of this method: Obtain the number of players in designate team
  • The specific use cases are as follows:
--Get the number of players in the first team
--The first parameter is the team id
--The second parameter:0 is the number of dead players in the current team 1 is alive 2 is all
local result,num=Team:getTeamPlayerNum(1,2)
--Show in chat box
Chat:sendSystemMsg("The total number of players in the first team is:"..num)

# getTeamPlayers

  • Parameters and types:
    • teamid:numberTeam ID, default all
    • alive:numberWhether survive, default all
  • Return value and types:
  • The main role of this method: Get the designate player team
  • The specific use cases are as follows:
--Get the number and list of players in the first team
--The first parameter is the team id
--The second parameter:0 is the number of dead players in the current team 1 is alive 2 is all
local result,num,array=Team:getTeamPlayers(1,2)
--Display number in chat box
Chat:sendSystemMsg("The total number of players in the first team is:"..num)
for i,a in ipairs(array) do
	--Display the list in the chat box
	Chat:sendSystemMsg("No."..i..":"..a)
end

# randomTeamPlayer

  • Parameters and types:
    • teamid:numberTeam ID, default all
    • alive:numberWhether survive, default all
  • Return value and types:
  • The main role of this method: Random Player
  • The specific use cases are as follows:
--randomly select a player from the team
--The first parameter is the team id
--The second parameter:0 is the number of dead players in the current team 1 is alive 2 is all
local result,uin=Team:randomTeamPlayer(1,2)
--Show in chat box
Chat:sendSystemMsg("A player was randomly selected from the first team:"..uin)

# getTeamCreatures

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain creature in designate team(like getTeamPlayers)
  • The specific use cases are as follows:
--Get the list of creatures belonging to the first team,the parameter is the team id
local result,array=Team:getTeamCreatures(1)
if #array==0 then--If there is no creature
	--Show in chat box
	Chat:sendSystemMsg("No animals or monsters belong to the first team")
else--if there is a creature
	for i,a in ipairs(array) do
		--Display the list of creatures in the chat box
		Chat:sendSystemMsg("The creature id belonging to the first team,"..i..":"..a)
	end
end

# setTeamScore

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Score of team
  • The specific use cases are as follows:
--Set the score of the designated team
--The first parameter is the team id
--The second parameter is the score to be set
Team:setTeamScore(1,10)
--Show in chat box
Chat:sendSystemMsg("The score of the first team is set to 10")

# getTeamScore

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the team score
  • The specific use cases are as follows:
--Get the team's score,the parameter is the team id
local result,score=Team:getTeamScore(1)
--Show in chat box
Chat:sendSystemMsg("The first team's game score is".. score)

# addTeamScore

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase the team score
  • The specific use cases are as follows:
--Add points to the designated team
--The first parameter is the team id
--The second parameter is the game score to be increased
Team:addTeamScore(1,10)
--Show in chat box
Chat:sendSystemMsg("The score of the first team was increased by 10")

# setTeamResults

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Result of team
  • The specific use cases are as follows:
--Every time the player makes an animated expression,let the designated team win or lose
--This function is executed when the player makes an animated expression
local function Player_PlayAction(event)
	--Let team 1 win
	--The first parameter is the team id
	--The second parameter is:1 wins 2 loses
	Team:setTeamResults(1,1)
	--Show in chat box
	Chat:sendSystemMsg("Team 1 Wins")
end
--Register an animated expression listener,execute the above function when the event occurs
ScriptSupportEvent:registerEvent([=[Player.PlayAction]=],Player_PlayAction)

# getTeamResults

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the current win-los of team
  • The specific use cases are as follows:
--Get whether the team wins,the parameter is the team id
local result,teamresult=Team:getTeamResults(1)
--Show in chat box
Chat:sendSystemMsg("The current winning status of team 1 is(1:winning 2:losing):".. teamresult)

# setTeamPlayersResults

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the win-los of player team
  • The specific use cases are as follows:
local result = Team:setTeamPlayersResults(teamid, result)

# setTeamDieTimes

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Number of team deaths
  • The specific use cases are as follows:
--Set the number of deaths of team players,the first parameter is the team id,the second parameter is the number of deaths
Team:setTeamDieTimes(1,10)
--Show in chat box
Chat:sendSystemMsg("The number of player deaths of team 1 is set to 10")

# getTeamDieTimes

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the total deaths of team
  • The specific use cases are as follows:
--Get the total number of deaths of team 1,the parameter is the team id
local result,times=Team:getTeamDieTimes(1)
--Show in chat box
Chat:sendSystemMsg("The total number of deaths of team 1 is:"..times)

# addTeamDieTimes

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase the total deaths of team
  • The specific use cases are as follows:
--Increase the number of team deaths,the parameter is the team id
Team:addTeamDieTimes(1)
--Show in chat box
Chat:sendSystemMsg("The number of deaths of team 1 is increased by 1(that is,the total life of team 1 is reduced by 1)")

# changePlayerTeam

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Change player's team
  • The specific use cases are as follows:
--Set designated players to designated teams
--The first parameter is the player id or player mini number,0 is the homeowner
--The second parameter is the team id to move to
Team:changePlayerTeam(0,2)
--Show in chat box
Chat:sendSystemMsg("Homeowner is set to Team 2")
Last Update: 6/11/2020, 9:30:46 PM