SetTeamName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
This function is used to set a team's name.
This function is used to set a team's name.


Line 12: Line 13:


===Returns===
===Returns===
Returns 'true' if the team was valid and the name was changed, 'false' otherwise.
Returns ''true'' if the team was valid and the name was changed, ''false'' otherwise.


==Example==
==Example==
This example gets the current team of a player, then changes its name.
This example gets the current team of a player, then changes its name.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "changeMyTeamName", "changeMyTeamName" )
function changeMyTeamName ( source, key, newName )
function changeMyTeamNam ( source, key, newName )
    playerteam = getPlayerTeam ( source )           -- get the player's team
  team = getPlayerTeam ( source ) -- get the player's team
    if ( playerteam ) then                           -- if he was on a team
  if ( team ) then -- if he was on a team
        oldName = getTeamName ( playerteam )         -- get the teams current name
    oldName = getTeamName ( team ) -- get the teams current name
        setTeamName ( playerteam, newName )         -- change the teams name to blue
    setTeamName ( team, newName ) -- change the teams name to blue
        outputChatBox ( "Changed " .. getClientName ( source ) .. "'s team name from " .. oldName .. " to " .. newName )
    outputChatBox ( "Changed ".. getClientName ( source ).."'s team name from "..oldName.." to "..newName )
    end
  end
end
end
addCommandHandler ( "changeteamname", changeMyTeamName )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 21:25, 15 August 2007

This function is used to set a team's name.

Syntax

bool setTeamName ( team theTeam, string newName )

Required Arguments

  • theTeam: The team you want to change the name of.
  • newName: A string representing the name you want the team to be called.

Returns

Returns true if the team was valid and the name was changed, false otherwise.

Example

This example gets the current team of a player, then changes its name.

function changeMyTeamName ( source, key, newName )
    playerteam = getPlayerTeam ( source )            -- get the player's team
    if ( playerteam ) then                           -- if he was on a team
        oldName = getTeamName ( playerteam )         -- get the teams current name
        setTeamName ( playerteam, newName )          -- change the teams name to blue
        outputChatBox ( "Changed " .. getClientName ( source ) .. "'s team name from " .. oldName .. " to " .. newName )
    end
end
addCommandHandler ( "changeteamname", changeMyTeamName )

See Also