<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Esmail9900</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Esmail9900"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Esmail9900"/>
	<updated>2026-04-21T14:18:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerTeamChange&amp;diff=79388</id>
		<title>OnPlayerTeamChange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerTeamChange&amp;diff=79388"/>
		<updated>2024-05-24T06:10:20Z</updated>

		<summary type="html">&lt;p&gt;Esmail9900: /* Player events */&lt;/p&gt;
&lt;hr /&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>