Partial Name?

I did a search, but was unable to find any info.

I’m looking for a bit of code that, if I were to give a few digit of a players name, it woud output the players full Nick. Which could then of couse be used for somehting else.

That’s probly confusing…essentially I am looking for help turning a partial name into the players full nick.

Any suggestions?

This should work, please note this returns the players name in a string, this does not return the player as an entity. If you need it returned as an entity say so and I will edit the code.

function FindPlayerbyName( n )
n = n:lower()

for k, v in pairs( player.GetAll( ) ) do      
    if v:Nick():lower():find( n, 1, true ) then    
        return v:Name()     
return NULL      



But I’m having trouble trying to implement it with this:

–Slay Player
function ASSChat_Kill( ply, text, toall )
if (string.sub(text, 1, 5) == “/kill”) then
ply:ConCommand(“ASS_KillPlayer”…string.sub(text, 6));
return “”;
hook.Add( “PlayerSay”, “ASSChat_Kill”, ASSChat_Kill );


Any suggestions?

There is no space between ‘ASS_KillPlayer’ and the player name, so it’ll try to run an unknown command. Additionally note that this is a backwards way of doing it. When a player sends a message to the server, you make them call a console command which again sends a message to the server, instead of simply running the command as soon as the server receives the chat message.

That’s sence no make. :science:


Spam much…

I have no idea how I would go about doing that…sorry I’m still just really new to lua.

I don’t think I can make it any simpler then this :
[lua]function FindPlayer(str)
for k,v in pairs(player.GetAll()) do
if string.find(v:Nick(),str) then
return v

It will return the player’s object which you can then do all sort of fun things with, including getting the name.


You make no sense.

Thank-you very much! =D

Prowler, from what people just gave you… to find people’s ID… then… you can… use this…