<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dev.playonset.com/index.php?action=history&amp;feed=atom&amp;title=GetPlayerFromPartialName</id>
	<title>GetPlayerFromPartialName - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dev.playonset.com/index.php?action=history&amp;feed=atom&amp;title=GetPlayerFromPartialName"/>
	<link rel="alternate" type="text/html" href="https://dev.playonset.com/index.php?title=GetPlayerFromPartialName&amp;action=history"/>
	<updated>2026-04-30T03:45:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://dev.playonset.com/index.php?title=GetPlayerFromPartialName&amp;diff=3260&amp;oldid=prev</id>
		<title>Wumbaloo: Create page</title>
		<link rel="alternate" type="text/html" href="https://dev.playonset.com/index.php?title=GetPlayerFromPartialName&amp;diff=3260&amp;oldid=prev"/>
		<updated>2019-12-16T21:38:34Z</updated>

		<summary type="html">&lt;p&gt;Create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Info|Lua Helper|Server|Wumbaloo}}&lt;br /&gt;
&lt;br /&gt;
{{FuncDescription|Get player from a partial name.}}&lt;br /&gt;
&lt;br /&gt;
{{FuncSyntax|GetPlayerFromPartialName(player)}}&lt;br /&gt;
&lt;br /&gt;
{{FuncParameters}}&lt;br /&gt;
{{FuncParam|player|The player identifier.}}&lt;br /&gt;
&lt;br /&gt;
{{FuncReturnValue|Returns the player identifier if found. Returns &amp;#039;&amp;#039;&amp;#039;nil&amp;#039;&amp;#039;&amp;#039; otherwise.}}&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Lua&amp;quot;&amp;gt;&lt;br /&gt;
function GetPlayerFromPartialName(name)&lt;br /&gt;
    local name = name and name:gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower() or nil&lt;br /&gt;
    if name then&lt;br /&gt;
        for _, player in ipairs(GetAllPlayers()) do&lt;br /&gt;
            local playerName = GetPlayerName(player):gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower()&lt;br /&gt;
            if playerName:find(name, 1, true) then&lt;br /&gt;
                return player&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;
&lt;br /&gt;
== Example Server ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Lua&amp;quot;&amp;gt;&lt;br /&gt;
function GetPlayerFromPartialName(name)&lt;br /&gt;
    local name = name and name:gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower() or nil&lt;br /&gt;
    if name then&lt;br /&gt;
        for _, player in ipairs(GetAllPlayers()) do&lt;br /&gt;
            local playerName = GetPlayerName(player):gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower()&lt;br /&gt;
            if playerName:find(name, 1, true) then&lt;br /&gt;
                return player&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
AddCommand(&amp;quot;findplayer&amp;quot;, function (player, _name)&lt;br /&gt;
	local otherPlayer = GetPlayerFromPartialName(_name) or &amp;quot;not found&amp;quot;&lt;br /&gt;
	AddPlayerChat(player, &amp;quot;Player &amp;quot; .. _name .. &amp;quot; is &amp;quot; .. tostring(otherPlayer))&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{RelatedFunctions}}&lt;br /&gt;
* [[GetAllPlayers]]&lt;br /&gt;
* [[GetPlayerName]]&lt;/div&gt;</summary>
		<author><name>Wumbaloo</name></author>
	</entry>
</feed>