Command !kick <id> <reason>
i want, if i use this command on myself, then show Msg
" You can not kick yourself"
and if i type !kick <id> and <reason> missing then show msg
"reason must be entered"
i hope anybody will make it for me.
 
  CS2D
 CS2D  Scripts
 
Scripts  Command !kick
 Command !kick Command !kick
 Command !kick 
  1
 1  
 
Roles = {
	[1] = 'Admin',
}
Permissions = {
	['kick']			= 1
}
addhook('say', 'SayHook')
function SayHook(id, text)
	return SayHookCommands(id, text) or 0
end
function SayHookCommands(id, text)
	text = text:lower()
	if string.sub(text, #text-1,#text) == '@C' then
		text = string.sub(text, 1, #text-2)
	end
	if text:sub(1,1) == '!' then
		print(GetGN(id)..' used the command: '..text)
		command = text:sub(2):split(' ')
		local arg = ToTable(text)
		arg[1] = arg[1]:sub(2)
		if arg[1] == 'kick' then
			if --[[PLACE LEVEL OF PLAYER'S STAFF LEVEL HERE]] >= Permissions[arg[1]] then
				if ValidArgument(arg[2]) and PlayerExists(tonumber(arg[2])) then
					arg[3] = FixArgument(text, 3)
					if not ValidArgument(arg[3]) then
						arg[3] = 'No reason stated.'
					end
					parse('kick "'..tonumber(arg[2])..'" "'..arg[3]..'"')
				else
					ReturnError(id, 4)
				end
			else
				ReturnError(id, 2, Permissions[arg[1]])
			end
		else
			ReturnError(id, 1)
			return 1
		end
	end
	return 0
end
function ReturnError(id, error, level)
	local text = ""
	if error == 1 then
		text = "Unknown command."
	elseif error == 2 then
		text = "A staff level of '"..Roles[level].."' is required to use this command."
	elseif error == 3 then
		text = "Invalid command arguments."
	elseif error == 4 then
		text = "The given argument either does not exist or it is invalid."
	elseif error == 5 then
		text = "You may not use this command on yourself."
	elseif error == 6 then
		text = "You may not use this command in this area."
	elseif error == 7 then
		text = "The player stated is already dead."
	else
		text = "Unknown exception has occured."
	end
	HUDMsg(id, text, "error")
end
function FixArgument(text, num)
	local arg = ""
	for k, v in ipairs(text:split(' ')) do
		if k >= num then
			arg = arg..' '..v
		end
	end
	return arg
end
function ValidArgument(arg)
	if arg and arg ~= "" then
		return true
	end
	return false
end
function ToTable(t, match)
	local cmd = {}
	if not match then match = "[^%s]+" end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end 
	return cmd 
end
Roles = {
     [1] = 'Admin',
}
Permissions = {
     ['kick']               = 1
}
addhook('say', 'SayHook')
function SayHook(id, text)
     return SayHookCommands(id, text) or 0
end
function SayHookCommands(id, text)
     text = text:lower()
     if string.sub(text, #text-1,#text) == '@C' then
          text = string.sub(text, 1, #text-2)
     end
     if text:sub(1,1) == '!' then
          print(GetGN(id)..' used the command: '..text)
          command = text:sub(2):split(' ')
          local arg = ToTable(text)
          arg[1] = arg[1]:sub(2)
          if arg[1] == 'kick' then
               if --[[PLACE LEVEL OF PLAYER'S STAFF LEVEL HERE]] >= Permissions[arg[1]] then
                    if ValidArgument(arg[2]) and PlayerExists(tonumber(arg[2])) then
                         arg[3] = FixArgument(text, 3)
                         if not ValidArgument(arg[3]) then
                              arg[3] = 'No reason stated.'
                         end
                         parse('kick "'..tonumber(arg[2])..'" "'..arg[3]..'"')
                    else
                         ReturnError(id, 4)
                    end
               else
                    ReturnError(id, 2, Permissions[arg[1]])
               end
          else
               ReturnError(id, 1)
               return 1
          end
     end
     return 0
end
function ReturnError(id, error, level)
     local text = ""
     if error == 1 then
          text = "Unknown command."
     elseif error == 2 then
          text = "A staff level of '"..Roles[level].."' is required to use this command."
     elseif error == 3 then
          text = "Invalid command arguments."
     elseif error == 4 then
          text = "The given argument either does not exist or it is invalid."
     elseif error == 5 then
          text = "You may not use this command on yourself."
     elseif error == 6 then
          text = "You may not use this command in this area."
     elseif error == 7 then
          text = "The player stated is already dead."
     else
          text = "Unknown exception has occured."
     end
     HUDMsg(id, text, "error")
end
function FixArgument(text, num)
     local arg = ""
     for k, v in ipairs(text:split(' ')) do
          if k >= num then
               arg = arg..' '..v
          end
     end
     return arg
end
function ValidArgument(arg)
     if arg and arg ~= "" then
          return true
     end
     return false
end
function ToTable(t, match)
     local cmd = {}
     if not match then match = "[^%s]+" end
     for word in string.gmatch(t, match) do
          table.insert(cmd, word)
     end 
     return cmd 
end
 
   
  1
 1  
 