Forum

> > CS2D > Scripts > Adding <reason> in HC kick command
Forums overviewCS2D overview Scripts overviewLog in to reply

English Adding <reason> in HC kick command

3 replies
To the start Previous 1 Next To the start

old Adding <reason> in HC kick command

Man Of Steel
User Off Offline

Quote
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

old Re: Adding <reason> in HC kick command

phalenkO
User Off Offline

Quote
@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.

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:
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

1
function string:split(sep)
I not made, I take at by my friend. My friend take at the enternet.

old Re: Adding <reason> in HC kick command

G3tWr3ck3d
User Off Offline

Quote
Inside file
1
hc/core/commands.lua

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

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

Inside
1
hc/modules/moderation.lua

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

Search for comment
1
-- Say commands
add the following 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 √
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview