OnPlayerTeamChange

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

BETA: NEW FEATURE (BUILD: 1.6.0 r22447)
This event is triggered whenever a player's team changes.

Additionally, this event is triggered for all players on a team when that team is destroyed.

Parameters

team oldTeam, team newTeam
  • oldTeam: An team representing the previous team of the player. If there is no old team, this is nil.
  • newTeam: An team representing the new team of the player. If there is no new team, this is nil.

Source

The source of this event is the player whose team was changed.

Cancel effect

If this event is canceled, then the player's team change will be prevented.

Example

This example prints the name of the new team of a player whenever the player's team changes.

addEventHandler("onPlayerTeamChange", root, function(oldTeam, newTeam)
    local playerName = getPlayerName(source)

    if isElement(newTeam) then 
        outputChatBox(playerName.."'s team changed. New team name: "..getTeamName(newTeam))
    else
        outputChatBox(playerName.." is no longer in a team.")
    end 
end)

See Also

Player events


Event functions