GetPlayerTeam: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 10: Line 10:
===Required Arguments===
===Required Arguments===
*'''thePlayer''': The [[player]] whose team you want to find out.
*'''thePlayer''': The [[player]] whose team you want to find out.
===Returns===
Returns a ''team'' element representing the team the player is on.


==Example==
==Example==

Revision as of 16:08, 26 August 2007

This function gets the current team a player is on.

Syntax

team getPlayerTeam ( player thePlayer )

Required Arguments

  • thePlayer: The player whose team you want to find out.

Returns

Returns a team element representing the team the player is on.

Example

Click to collapse [-]
Server

This example finds the team a player is on, and then changes its name.

function teamName ( source, key, newTeamName )
    local playerTeam = getPlayerTeam ( source )          -- get the player's team
    if ( playerTeam ) then                               -- if he's on a team
        local oldTeamName = getTeamName ( playerTeam )   -- get the team's current name
        setTeamName ( playerTeam, newTeamName )          -- change its name
        outputChatBox ( "Changed " .. getClientName ( source ).."'s team name from " .. oldTeamName .. " to " .. newTeamName )
    else
        outputChatBox ( getClientName ( source ) .. " isn't on a team" )
    end
end
addCommandHandler ( "teamname", teamName )

See Also