How would I get the player entity with his name or partial name as a string? -- Something like Expression 2's findPlayerByName()
player:Name() or :Nick() ?
I'm not sure what your wanting here...
I'm trying to get the player entity by inputting his name.
? Do you mean your trying to get a player name from an ent?
Loop through all the players (player.GetAll()) and use string.find to see if their name contains the imputed value.
Return the player entity if there is a match.
[lua]local function FindPlayerByName(name)
for _,v in ipairs(player.GetAll()) do
if string.match(v:Name(),name) then return v end
end
end[/lua]
I always use that.
Thanks for the help.
Sorry, you need to Log In to post a reply to this thread.