GetPlayerFromPartialName

From Multi Theft Auto: Wiki
Revision as of 08:11, 30 December 2011 by TAPL (talk | contribs) (Created page with "==Syntax== <syntaxhighlight lang="lua"> player getPlayerFromNamePart ( string Name ) </syntaxhighlight> ===Required Arguments=== * '''Name''': A string containing the name part of the player you want to ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Syntax

player getPlayerFromNamePart ( string Name )

Required Arguments

  • Name: A string containing the name part of the player you want to reference

Returns

Returns: if the Name part is exist then returns a player, false otherwise.


Code

function getPlayerFromNamePart(Name)
local player = getPlayerFromName(Name)
     if (player) then return player end
          for i,player in ipairs (getElementsByType ("player")) do
          if (string.find(getPlayerName(player),Name)) then
          return player end
     end
end