<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/GetPlayerNameFromID?action=history&amp;feed=atom</id>
	<title>GetPlayerNameFromID - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/GetPlayerNameFromID?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerNameFromID&amp;action=history"/>
	<updated>2026-05-14T17:48:16Z</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=GetPlayerNameFromID&amp;diff=74489&amp;oldid=prev</id>
		<title>Hydra: Created page with &quot;{{Useful Function}} __NOTOC__ This function will get the player name using the ID element data.  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt;bool getPlayerNameFromID(number theID, element theElement)&lt;/syntaxhighlight&gt;  ===Required Arguments=== * '''theID''': The id number. * '''theElement''': The player element.  ==Code== &lt;section name=&quot;Clientside script&quot; class=&quot;client&quot; show=&quot;true&quot;&gt; &lt;syntaxhighlight lang=&quot;lua&quot;&gt; function getPlayerNameFromID(theID, theElement)    if isElement(t...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerNameFromID&amp;diff=74489&amp;oldid=prev"/>
		<updated>2022-04-28T16:20:32Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function will get the player name using the ID element data.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool getPlayerNameFromID(number theID, element theElement)&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * &amp;#039;&amp;#039;&amp;#039;theID&amp;#039;&amp;#039;&amp;#039;: The id number. * &amp;#039;&amp;#039;&amp;#039;theElement&amp;#039;&amp;#039;&amp;#039;: The player element.  ==Code== &amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; function getPlayerNameFromID(theID, theElement)    if isElement(t...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function will get the player name using the ID element data.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool getPlayerNameFromID(number theID, element theElement)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theID''': The id number.&lt;br /&gt;
* '''theElement''': The player element.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPlayerNameFromID(theID, theElement)&lt;br /&gt;
   if isElement(theElement) and getElementType(theElement) == &amp;quot;player&amp;quot; and tonumber(theID) then&lt;br /&gt;
      for k, v in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
          if getElementData(v, &amp;quot;ID&amp;quot;) == getElementData(theElement, &amp;quot;ID&amp;quot;) then&lt;br /&gt;
             return getPlayerName(v)&lt;br /&gt;
          else&lt;br /&gt;
             iprint(&amp;quot;Player not found&amp;quot;)&lt;br /&gt;
          end&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
'''The example will show you how to get the player name using getPlayerNameFromID'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function SetIDOnJoin()&lt;br /&gt;
   setElementData(source, &amp;quot;ID&amp;quot;, math.random(1, 500))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, SetIDOnJoin)&lt;br /&gt;
&lt;br /&gt;
function getMyID(thePlayer, theCommand)&lt;br /&gt;
   iprint(getPlayerNameFromID(getElementData(thePlayer, &amp;quot;ID&amp;quot;), thePlayer))&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;tid&amp;quot;, getMyID)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
&lt;br /&gt;
'''by Hydra45'''&lt;br /&gt;
'''Discord: Hydra45#6859'''&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Hydra</name></author>
	</entry>
</feed>