<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/OnPlayerTeamChange?action=history&amp;feed=atom</id>
	<title>OnPlayerTeamChange - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/OnPlayerTeamChange?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerTeamChange&amp;action=history"/>
	<updated>2026-04-30T05:11:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerTeamChange&amp;diff=79388&amp;oldid=prev</id>
		<title>Esmail9900: /* Player events */</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerTeamChange&amp;diff=79388&amp;oldid=prev"/>
		<updated>2024-05-24T06:10:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Player events&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server event}}&lt;br /&gt;
{{Added feature/item|1.6.1|1.6.0|22447|This event is triggered whenever a player's team changes.}}&lt;br /&gt;
Additionally, this event is triggered for all players on a team when that team is destroyed.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
team oldTeam, team newTeam&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''oldTeam''': An [[team]] representing the previous team of the player. If there is no old team, this is nil.&lt;br /&gt;
*'''newTeam''': An [[team]] representing the new team of the player. If there is no new team, this is nil.&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] whose team was changed.&lt;br /&gt;
&lt;br /&gt;
==Cancel effect==&lt;br /&gt;
If this event is [[Event system#Canceling|canceled]], then the player's team change will be prevented.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example prints the name of the new team of a player whenever the player's team changes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerTeamChange&amp;quot;, root, function(oldTeam, newTeam)&lt;br /&gt;
    local playerName = getPlayerName(source)&lt;br /&gt;
&lt;br /&gt;
    if isElement(newTeam) then &lt;br /&gt;
        outputChatBox(playerName..&amp;quot;'s team changed. New team name: &amp;quot;..getTeamName(newTeam))&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(playerName..&amp;quot; is no longer in a team.&amp;quot;)&lt;br /&gt;
    end &lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;/div&gt;</summary>
		<author><name>Esmail9900</name></author>
	</entry>
</feed>