onPlayerTeamChange | Multi Theft Auto: Wiki Skip to content

onPlayerTeamChange

Client-side
Server-side
Shared

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

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

Canceling

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

Code Examples

server

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