diff --git a/luascripts/commands/client/ac.lua b/luascripts/commands/client/ac.lua index 333599b..47e5a3b 100644 --- a/luascripts/commands/client/ac.lua +++ b/luascripts/commands/client/ac.lua @@ -44,5 +44,5 @@ function commandAdminChat(clientId, cmdArguments) return true end -commands.addclient("adminchat", commandAdminChat, "~", "[^2message^7]") -commands.addclient("ac", commandAdminChat, "~", "[^2message^7]") \ No newline at end of file +commands.addclient("adminchat", commandAdminChat, "~", "[^2message^7]", true) +commands.addclient("ac", commandAdminChat, "~", "[^2message^7]", true) \ No newline at end of file diff --git a/luascripts/commands/client/pm.lua b/luascripts/commands/client/pm.lua index c222fc2..bdc7571 100644 --- a/luascripts/commands/client/pm.lua +++ b/luascripts/commands/client/pm.lua @@ -35,5 +35,5 @@ function commandPersonalMessage(clientId, cmdArguments) end end end -commands.addclient("pm", commandPersonalMessage, "", "") -commands.addclient("m", commandPersonalMessage, "", "") \ No newline at end of file +commands.addclient("pm", commandPersonalMessage, "", "", true) +commands.addclient("m", commandPersonalMessage, "", "", true) \ No newline at end of file diff --git a/luascripts/commands/client/r.lua b/luascripts/commands/client/r.lua index b2f179f..bca2a42 100644 --- a/luascripts/commands/client/r.lua +++ b/luascripts/commands/client/r.lua @@ -42,4 +42,4 @@ function commandR(clientId, cmdArguments) return true end -commands.addclient("r", commandR, "", "[^2message^7]") \ No newline at end of file +commands.addclient("r", commandR, "", "[^2message^7]", true) \ No newline at end of file diff --git a/luascripts/commands/commands.lua b/luascripts/commands/commands.lua index 471740a..17a596a 100644 --- a/luascripts/commands/commands.lua +++ b/luascripts/commands/commands.lua @@ -54,11 +54,12 @@ function commands.getadmin(command) return admincmds end -function commands.addclient(command, func, flag, syntax) +function commands.addclient(command, func, flag, syntax, chat) clientcmds[command] = { ["function"] = func, ["flag"] = flag, - ["syntax"] = "^2!"..command..(syntax and " "..syntax or ""), + ["syntax"] = "^7"..command..(syntax and " "..syntax or ""), + ["chat"] = chat, } end @@ -238,6 +239,45 @@ function commands.onclientcommand(clientId, cmdText) 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 local shrubCmd = nil