local commands = {
["kick"] = function(arg)
local name,txt = arg:match("([%w_]+)%s?(.*)") -- wieder pattern action :D
for k,v in pairs(player.GetAll()) do -- alle player
if v:Name():lower():find(name) then -- die mit dem argument was gemeinsam haben
v:Kick(txt ~= "" and txt or "The admin does not like you!") -- werden gekickt!
end
end
end,
["hp"] = function(arg)
local name,hp = arg:match("([%w_]+)%s?(.*)") -- wieder pattern action :D
for k,v in pairs(player.GetAll()) do -- alle player
if v:Name():lower():find(name) then -- die mit dem argument was gemeinsam haben
v:SetHealth(hp ~= "" and hp or 100) -- kriegen entweder die angegebenen oder 100 hp
end
end
end,
}
function ChatCommand(ply,text)
if text:sub(1,1) == "/" then -- wir haben den richtigen anfang!
local cmd,arg = text:sub(2):match("([%w_]+)%s(.+)") -- zeit fuer pattern action :)
if commands[cmd] then -- falls die funktion (kick,hp,...) existiert
commands[cmd](arg) -- ruft man sie mit dem argument auf
return "" -- und returned nichts, damit nichts im chat steht
end
end
end
hook.Add("PlayerSay","Record commands",ChatCommand)