Jump to content

Getting player name from part.


zixxonx

Recommended Posts

Hi, i want to do command like this.

!yo [part of the other player nick]

Then it'll bring up

(My nick): Yo, (player)

for example: if name of the player is: VeryBigFoot5776 and i type !yo verybig it'll show

(My Nick): Yo, VeryBigFoot5776

I already coded everything what i need, just dont know how to get player full name from just part.

Link to comment
function getPlayerNameFromNamePart(name) 
    if name then  
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return getPlayerName(player)  
            end 
        end 
    end 
    return false 
end 

local fullname = getPlayerNameFromNamePart("name part") 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...