mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2025-04-25 02:20:58 +00:00
added client commands from chat (issue #47)
This commit is contained in:
parent
1adeb63acf
commit
54ec0621ef
4 changed files with 47 additions and 7 deletions
|
@ -44,5 +44,5 @@ function commandAdminChat(clientId, cmdArguments)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
commands.addclient("adminchat", commandAdminChat, "~", "[^2message^7]")
|
commands.addclient("adminchat", commandAdminChat, "~", "[^2message^7]", true)
|
||||||
commands.addclient("ac", commandAdminChat, "~", "[^2message^7]")
|
commands.addclient("ac", commandAdminChat, "~", "[^2message^7]", true)
|
|
@ -35,5 +35,5 @@ function commandPersonalMessage(clientId, cmdArguments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
commands.addclient("pm", commandPersonalMessage, "", "")
|
commands.addclient("pm", commandPersonalMessage, "", "", true)
|
||||||
commands.addclient("m", commandPersonalMessage, "", "")
|
commands.addclient("m", commandPersonalMessage, "", "", true)
|
|
@ -42,4 +42,4 @@ function commandR(clientId, cmdArguments)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
commands.addclient("r", commandR, "", "[^2message^7]")
|
commands.addclient("r", commandR, "", "[^2message^7]", true)
|
|
@ -54,11 +54,12 @@ function commands.getadmin(command)
|
||||||
return admincmds
|
return admincmds
|
||||||
end
|
end
|
||||||
|
|
||||||
function commands.addclient(command, func, flag, syntax)
|
function commands.addclient(command, func, flag, syntax, chat)
|
||||||
clientcmds[command] = {
|
clientcmds[command] = {
|
||||||
["function"] = func,
|
["function"] = func,
|
||||||
["flag"] = flag,
|
["flag"] = flag,
|
||||||
["syntax"] = "^2!"..command..(syntax and " "..syntax or ""),
|
["syntax"] = "^7"..command..(syntax and " "..syntax or ""),
|
||||||
|
["chat"] = chat,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,6 +239,45 @@ function commands.onclientcommand(clientId, cmdText)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- client cmds
|
||||||
|
local clientCmd = nil
|
||||||
|
|
||||||
|
-- say and say_*
|
||||||
|
if (wolfCmd == "say" or wolfCmd == "say_team" or wolfCmd == "say_buddy") and string.find(et.trap_Argv(1), "/") == 1 then
|
||||||
|
cmdArguments = util.split(et.trap_Argv(1), " ")
|
||||||
|
|
||||||
|
-- say "/command param1 param2 paramN"
|
||||||
|
if #cmdArguments > 1 then
|
||||||
|
clientCmd = string.sub(cmdArguments[1], 2, string.len(cmdArguments[1]))
|
||||||
|
table.remove(cmdArguments, 1)
|
||||||
|
-- say /command param1 param2 paramN
|
||||||
|
else
|
||||||
|
clientCmd = string.sub(et.trap_Argv(1), 2, string.len(et.trap_Argv(1)))
|
||||||
|
|
||||||
|
for i = 2, et.trap_Argc() - 1 do
|
||||||
|
cmdArguments[(i - 1)] = et.trap_Argv(i)
|
||||||
|
end
|
||||||
|
if cmdArguments[1] == et.trap_Argv(1) then table.remove(cmdArguments, 1) end
|
||||||
|
end
|
||||||
|
-- !command
|
||||||
|
elseif string.find(wolfCmd, "!") == 1 then
|
||||||
|
clientCmd = string.sub(wolfCmd, 2, string.len(wolfCmd))
|
||||||
|
|
||||||
|
for i = 1, et.trap_Argc() - 1 do
|
||||||
|
cmdArguments[i] = et.trap_Argv(i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if clientCmd then
|
||||||
|
clientCmd = string.lower(clientCmd)
|
||||||
|
|
||||||
|
if clientcmds[clientCmd] and clientcmds[clientCmd]["function"] and clientcmds[clientCmd]["chat"] then
|
||||||
|
if clientcmds[clientCmd]["flag"] == "" or et.G_shrubbot_permission(clientId, clientcmds[clientCmd]["flag"]) == 1 then
|
||||||
|
return clientcmds[clientCmd]["function"](clientId, cmdArguments) and 1 or 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- shrub cmds
|
-- shrub cmds
|
||||||
local shrubCmd = nil
|
local shrubCmd = nil
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue