Skip to content

Instantly share code, notes, and snippets.

@MattJeanes
Created March 1, 2014 02:49
Show Gist options
  • Save MattJeanes/9284339 to your computer and use it in GitHub Desktop.
Save MattJeanes/9284339 to your computer and use it in GitHub Desktop.
Adds a chat command to kick a player, only works if you're admin or super admin.
hook.Add("PlayerSay", "kick", function(ply,text)
if ply:IsAdmin() or ply:IsSuperAdmin() then
local t=string.Explode(" ", text)
if t and t[1] and t[1]:lower()=="!kick" then
if t[2] and string.len(t[2])>0 then
local n=t[2]
local pl={}
for k,v in pairs(player.GetAll()) do
if string.find(v:Nick():lower(), n:lower()) then
table.insert(pl,v)
end
end
if #pl==1 then
ply:ChatPrint("Kicked "..pl[1]:Nick()..".")
pl[1]:Kick("Kicked!")
elseif #pl==0 then
ply:ChatPrint("Warning: Search for '"..n.."' yielded no results.")
else
ply:ChatPrint("Warning: Search for '"..n.."' yielded multiple results.")
end
else
ply:ChatPrint("Warning: No name specified.")
end
return ""
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment