English Adding <reason> in HC kick command

3 replies
Goto Page
To the start Previous 1 Next To the start
Up
Man Of Steel
User
Offline Off
Hello guys

I have a command !kick <id> <reason> in HC script,
I just want to add a lua code.
if i forget to type <id> or <reason>
Then a message show "Please enter a ID/Reason"
Example i type !kick <reason>
Then messahe show "Please enter ID"
Or i type !kick <id>
Then message show "Please enter a reason"

Spoiler >


Please help me :V
edited 5×, last 19.04.19 11:13:47 am
FRiendly boYy.
19.04.19 12:14:56 pm
Up
Goo
User
Online On
You're less likely to get help when you keep bumping your thread like that.
I almost wanted to help, almost.
30.04.19 10:52:36 pm
Up
phalenkO
User
Offline Off
@user Man Of Steel: If I understand it correctly you want the that code...
Its lua for example. If u ask me questions about the lua I give a few sample cod.

Code:
1
2
3
4
5
6
7
elseif komutlar == "!kick" and svadmin(id) then 
if not args[2] then msg2(id,"ID?") return 1 end
if not args[3] then msg2(id,"REASON?") return 1 end
if not player(tonumber(args[2]),"exists") then msg2(id,"PLAYER?") return 1 end
parse("kick "..args[2])
msg("sksksksksk") 
return 1


> komutlar&args:
Code:
1
2
3
4
5
6
7
8
9
10
11
function string:split(sep)
    local sep, fields = sep or ":", {}
    local pattern = string.format("([^%s]+)", sep)
    self:gsub(pattern, function(c) fields[#fields+1] = c end)
  return fields
end

if txt:sub(1,1) == "!" then
     local args = txt:split(" ")
     local komutlar = args[1] ---
          if komutlar == "any code" then


Code:
1
function string:split(sep)
I not made, I take at by my friend. My friend take at the enternet.
22.05.19 09:46:06 am
Up
G3tWr3ck3d
User
Offline Off
Inside file
Code:
1
hc/core/commands.lua


Search for code
Code:
1
arg = t:match("^%s*" .. hc.CMD_MARKER .. "[^%s]+%s+(.+)")

Add another optional argument
Code:
1
arg_optional = t:match("^%s*" .. hc.CMD_MARKER .. "[^%s]+%s+[^%s]+(.+)")


It should look like this:
Code:
1
2
arg = t:match("^%s*" .. hc.CMD_MARKER .. "[^%s]+%s+(.+)")
                    arg_optional = t:match("^%s*" .. hc.CMD_MARKER .. "[^%s]+%s+[^%s]+(.+)")


Inside
Code:
1
hc/modules/moderation.lua


Search for function
Code:
1
function hc.moderation.init()
and add
Code:
1
hc.add_say_command("kick", hc.moderation.kick_say_command, hc.MODERATOR1, "<id> <reason>", "Kick a player.")


Search for comment
Code:
1
-- Say commands
add the following code

Code:
1
2
3
4
5
6
7
8
9
function hc.moderation.kick_say_command(p, id)
     if hc.check_exists(p, id) then
          if arg_optional then
               hc.exec(p, 'kick ' .. id .. ' "' .. arg_optional)
          else
               hc.exec(p, "kick " .. id)
          end
     end
end


Should do the trick √
Mess with the best, die like the rest. ༼ つ ◕_◕ ༽つ
To the start Previous 1 Next To the start