I have made two admin commands, but they don't seem to be working correctly. Whenever I use the gmodadmin_say, it just sends everyone the text: "[ADMIN] <Name>: gmodadmin_say". With the slay command, it doesn't like how I have the args set up, and it just returns nothing at all. Here is the code and thanks in advance. (Also, sorry, but for some reason, the [lua][/lua] tags aren't working):
[code]function AllTalk(ply, command, arguments)
if ply:IsAdmin() then
local Nick = ply:Nick()
if ((args) == nil) then
ply:ChatPrint("Syntax: \"gmodadmin_say Hello. How is everyone?\"")
else
for _, v in pairs(player.GetAll()) do
v:ChatPrint("\[ADMIN\] " .. Nick .. ": " .. arguments)
end
end
else
ply:ChatPrint("You are not an admin.")
end
end
concommand.Add("gmodadmin_say", AllTalk)
function Slay(ply, command, args)
if ply:IsAdmin() then
local SlayedArg = args[1]
for _, v in pairs(player.GetAll()) do
if(string.find(string.lower(v:Nick()), string.lower(SlayedArg)) == 1) then
local Target = v
if Target != 1 then
ply:ChatPrint("This player cannot be found.")
else
Target:KillSilent()
for _, v in pairs(player.GetAll()) do
v:ChatPrint(ply:Nick() .. " slayed ".. Target:Nick() .. ".")
end
end
end
end
else
ply:ChatPrint("You are not an admin.")
end
end
concommand.Add("gmodadmin_slay", Slay)[/code]
[code]
function AllTalk(ply, command, args)
if( not ply:IsAdmin() ) then return end
if( args[1] == nil ) then
ply:ChatPrint("Syntax: \"gmodadmin_say Hello. How is everyone?\"")
return;
end
for _, v in pairs(player.GetAll()) do
v:ChatPrint("\[ADMIN\] " .. Nick .. ": " .. args[1])
end
end
concommand.Add("gmodadmin_say", AllTalk)
function Slay(ply, command, args)
if( not ply:IsAdmin() ) then return end
for _, v in pairs(player.GetAll()) do
if(string.find(string.lower(v:Nick()), string.lower(args[1])) == 1) then
if v != 1 then
ply:ChatPrint("This player cannot be found.")
else
v:KillSilent()
for m, n in pairs(player.GetAll()) do
n:ChatPrint(ply:Nick() .. " slayed ".. n:Nick() .. ".")
end
end
end
end
end
concommand.Add("gmodadmin_slay", Slay)
[/code]
Try that.
[QUOTE=H0rsey;25380214][code]
function AllTalk(ply, command, args)
if( not ply:IsAdmin() ) then return end
if( args[1] == nil ) then
ply:ChatPrint("Syntax: \"gmodadmin_say Hello. How is everyone?\"")
return;
end
for _, v in pairs(player.GetAll()) do
v:ChatPrint("\[ADMIN\] " .. Nick .. ": " .. args[1])
end
end
concommand.Add("gmodadmin_say", AllTalk)
function Slay(ply, command, args)
if( not ply:IsAdmin() ) then return end
for _, v in pairs(player.GetAll()) do
if(string.find(string.lower(v:Nick()), string.lower(args[1])) == 1) then
if v != 1 then
ply:ChatPrint("This player cannot be found.")
else
v:KillSilent()
for m, n in pairs(player.GetAll()) do
n:ChatPrint(ply:Nick() .. " slayed ".. n:Nick() .. ".")
end
end
end
end
end
concommand.Add("gmodadmin_slay", Slay)
[/code]
Try that.[/QUOTE]
There are a few problems with this code, try this instead:
[code]function AllTalk(ply, command, args)
if ply:IsAdmin() then
local Nick = ply:Nick()
if not args[1] then
ply:ChatPrint("Syntax: \"gmodadmin_say Hello. How is everyone?\"")
else
for _, v in ipairs(player.GetAll()) do
v:ChatPrint("\[ADMIN\] " .. Nick .. ": " .. table.concat(args, " "))
end
end
else
ply:ChatPrint("You are not an admin.")
end
end
concommand.Add("gmodadmin_say", AllTalk)
function Slay(ply, command, args)
if ply:IsAdmin() then
if args[1] then
for _, v in ipairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), string.lower(args[1])) then
v:KillSilent()
for _, p in ipairs(player.GetAll()) do
p:ChatPrint(ply:Nick() .. " slayed ".. v:Nick() .. ".")
end
end
end
else
ply:ChatPrint("Syntax: \"gmodadmin_slay Name\"")
end
else
ply:ChatPrint("You are not an admin.")
end
end
concommand.Add("gmodadmin_slay", Slay)[/code]
Thanks, MakeR. It worked perfectly. Is there a way to also make sure slay won't be used on multiple people, and it would say something like, "Please be more specific"?
Sorry, you need to Log In to post a reply to this thread.