GetTeamName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Reverted edits by Al7arthy (talk) to last revision by MarioKart)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Server client function}}
__NOTOC__
__NOTOC__
This function is used to get a team's name.
This function gets the team name of a team object.


==Syntax==
==Syntax==
Line 6: Line 7:
string getTeamName ( team theTeam )
string getTeamName ( team theTeam )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[team]]:getName|name|setTeamName}}
===Required Arguments===
===Required Arguments===
*'''theTeam:''' The team you want to retrieve the name of.
*'''theTeam:''' The team you want to retrieve the name of.


===Returns===
===Returns===
Returns a string representing the teams name if the team was valid, 'false' otherwise.
Returns a string representing the team's name if the team object was valid, ''false'' otherwise.


==Example==
==Example==
This example gets the current team of a player, then prints its name to the chatbox.
This example gets the current team of a player, then prints its name to the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function whatTeamAmIOn ( source )
function whatTeamAmIOn (source)
  -- Get the player's team (source is the player who entered the command)
    -- Get the player's team (source is the player who entered the command)
  team = getPlayerTeam ( source )
    local playerTeam = getPlayerTeam(source)
    
    
  if ( team ) then -- if he was on a team
    if (playerTeam) then -- if he was on a team
    outputChatBox ( getClientName ( source ).." is on team: "..getTeamName ( team ) )
        outputChatBox(getPlayerName(source).." is on team: "..getTeamName(playerTeam))
  else
    else
    outputChatBox ( getClientName ( source ).." isn't on a team" )
        outputChatBox(getPlayerName(source).. " isn't on a team")
  end
    end
end
end


-- Add console command to find your team when 'whatTeamAmIOn' is typed.
-- Add console command to find your team when 'whatTeamAmIOn' is typed.
addCommandHandler ( "whatTeamAmIOn", whatTeamAmIOn )
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Team_functions}}
{{Team_functions}}

Latest revision as of 14:44, 13 July 2019

This function gets the team name of a team object.

Syntax

string getTeamName ( team theTeam )

OOP Syntax Help! I don't understand this!

Method: team:getName(...)
Variable: .name
Counterpart: setTeamName


Required Arguments

  • theTeam: The team you want to retrieve the name of.

Returns

Returns a string representing the team's name if the team object was valid, false otherwise.

Example

This example gets the current team of a player, then prints its name to the chatbox.

function whatTeamAmIOn (source)
    -- Get the player's team (source is the player who entered the command)
    local playerTeam = getPlayerTeam(source)
  
    if (playerTeam) then -- if he was on a team
        outputChatBox(getPlayerName(source).." is on team: "..getTeamName(playerTeam))
    else
        outputChatBox(getPlayerName(source).. " isn't on a team")
    end
end

-- Add console command to find your team when 'whatTeamAmIOn' is typed.
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)

See Also