Specifying players with commands?

Hey,

Im just wondering how would i use commands with specifying players.
For example, if i an going to ban someone using ULX, i would type
!ban {player} {time} {reason}
How do the player, time and reason arguments get processed?

Thanks!

A naive way to do it would be lua patterns:



hook.Add("PlayerSay","my_shitty_ban",function(sender,text,_)
    --Only admins can ban
    if not sender:IsAdmin() then return end
    --Get the arguments out of the text
    local _,_,playername,time,reason = text:find("!shitban (%w+) (%d+) (.+)$")
    --Find the player with the same name
    for k,v in pairs(player.GetAll()) do
        if v:Name() == playername then
            --And ban them
            v:Ban(time)
        end
    end
end


This code has some serious flaws (like not being able to specify players with a space, then numbers in their name).

Thanks, that helped alot