• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Bannishment system

Daisun OT

Best Server Ever
Joined
Sep 30, 2011
Messages
12
Reaction score
0
Location
Georgia, USA
Hey i need a ban system , this:http://otland.net/f81/ban-nick-days-comment-forgotten-server-0-4-a-139216/, doesnt work. And mine ban system only kick players and dont ban.

can any help me?!

This is my ban talkaction
Code:
-- How use:
-- /ban PLAYERNAME, NUMBERDAYS(?), actionId(?), reasonId(?), COMMENT

-- actionId
-- 0 -- Offensive Name
-- 1 -- Invalid Name Format
-- 2 -- Unsuitable Name
-- 3 -- Name Inciting Rule Violation
-- 4 -- Offensive Statement
-- 5 -- Spamming
-- 6 -- Illegal Advertising
-- 7 -- Off-Topic Public Statement
-- 8 -- Non-English Public Statement
-- 9 -- Inciting Rule Violation
-- 10 -- Bug Abuse
-- 11 -- Game Weakness Abuse
-- 12 -- Using Unofficial Software to Play
-- 13 -- Hacking
-- 14 -- Multi-Clienting
-- 15 -- Account Trading or Sharing
-- 16 -- Threatening Gamemaster
-- 17 -- Pretending to Have Influence on Rule Enforcement
-- 18 -- False Report to Gamemaster
-- 19 -- Destructive Behaviour
-- 20 -- Excessive Unjustified Player Killing

-- reasonId
-- 0 -- Notation
-- 1 -- Name Report
-- 2 -- Banishment
-- 3 -- Name Report + Banishment
-- 4 -- Banishment + Final Warning
-- 5 -- Name Report + Banishment + Final Warning
-- 6 -- Statement Report
-- 7 -- Deletion
-- 8 -- Name Look
-- 9 -- Name Lock + Banishment
-- 10 -- Name Lock + Banishment + Final Warning
-- 11 -- Name Lock + Banishment + Final Warning + IP Banishment

function onSay(cid, words, param)
   local parametres = string.explode(param, ",")
   if(parametres[1] ~= nil) then
      local accId = getAccountIdByName(parametres[1])
      if(accId > 0) then
         local reasonId = {
            [0] = {0}, [1] = {1}, [2] = {2}, [3] = {3}, [4] = {4}, [5] = {5},
            [6] = {6}, [7] = {7}, [8] = {8}, [9] = {9}, [10] = {10}, [11] = {11},
            [12] = {12}, [13] = {13}, [14] = {14}, [15] = {15}, [16] = {16}, [17] = {17},
            [18] = {18}, [19] = {19}, [20] = {20}
         }
         local actionId = {
            [0] = {0}, [1] = {1}, [2] = {2}, [3] = {3}, [4] = {4}, [5] = {5},
            [6] = {6}, [7] = {7}, [8] = {8}, [9] = {9}, [10] = {10}, [11] = {11}
         }
         local comment = ""

         if(parametres[2] == nil) then
            doPlayerSendCancel(cid, "You must enter ban days.")
            return true
         elseif(isNumber(parametres[2]) == false) then
            doPlayerSendCancel(cid, "Ban days use only numbers.")
            return true
         end
         if(parametres[3] ~= nil) then
            reasonId = parametres[3]
         end
         if(parametres[4] ~= nil) then
            actionId = parametres[4]
         end
         if(parametres[5] ~= nil) then
            comment = parametres[5]
         end

         doAddAccountBanishment(accId, getPlayerGUIDByName(parametres[1]), os.time() + (86400 * parametres[2]), reasonId, actionId, comment, getPlayerGUID(cid), '')
         local player = getPlayerByNameWildcard(parametres[1])
         if(isPlayer(player) == true) then
            doRemoveCreature(player)
         end
      else
         doPlayerSendCancel(cid, "Player with name " .. parametres[1] .. " doesn't exist.")
      end
   else
      doPlayerSendCancel(cid, "You must enter name.")
   end

   return true
end
 
That's why maybe you don't have correctly configured your bans table, run this query in PMA:

SQL:
CREATE TABLE `bans`
(
	`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
	`type` TINYINT(1) NOT NULL COMMENT '1 - ip banishment, 2 - namelock, 3 - account banishment, 4 - notation, 5 - deletion',
	`value` INT UNSIGNED NOT NULL COMMENT 'ip address (integer), player guid or account number',
	`param` INT UNSIGNED NOT NULL DEFAULT 4294967295 COMMENT 'used only for ip banishment mask (integer)',
	`active` TINYINT(1) NOT NULL DEFAULT TRUE,
	`expires` INT NOT NULL,
	`added` INT UNSIGNED NOT NULL,
	`admin_id` INT UNSIGNED NOT NULL DEFAULT 0,
	`comment` TEXT NOT NULL,
	`reason` INT UNSIGNED NOT NULL DEFAULT 0,
	`action` INT UNSIGNED NOT NULL DEFAULT 0,
	`statement` VARCHAR(255) NOT NULL DEFAULT '',
	PRIMARY KEY (`id`),
	KEY `type` (`type`, `value`),
	KEY `active` (`active`)
) ENGINE = InnoDB;

Look into this post, for me works perfect: http://otland.net/f81/ban-nick-time-comment-forgotten-server-0-3-4-a-36230/
 
data/creaturescripts/ban/action.lua
LUA:
local ACCESS = {
	[1] = { 8 },
	[2] = { 1, 2, 4, 5, 7, 9 },
	[3] = { 1, 2, 3, 4, 5, 6, 7, 9 }
}

function onChannelRequest(cid, channel, custom)
	unregisterCreatureEvent(cid, "Ban_Action")
	if(not custom or type(channel) ~= 'number') then
		doPlayerSendCancel(cid, "Invalid action.")
		return false
	end

	if(not isInArray(ACCESS[getPlayerAccess(cid)], channel)) then
		doPlayerSendCancel(cid, "You cannot do this action.")
		return false
	end

	local output = "Name:\n\nComment:\n"
	if(isInArray({1, 5}, channel)) then
		output = "Name:\n\n(Optional) Length:\n\nComment:\n"
	end

	doShowTextDialog(cid, 2599, output, true, 1024)
	doCreatureSetStorage(cid, "banConfig", table.serialize({
		type = (channel > 4 and 2 or 1),
		subType = channel
	}))

	registerCreatureEvent(cid, "Ban_Finish")
	return false
end

data/creaturescript/ban/finish.lua/
LUA:
local config = {
	banLength = getConfigValue('banLength'),
	finalBanLength = getConfigValue('finalBanLength'),
	ipBanLength = getConfigValue('ipBanLength'),
	notationsToBan = getConfigValue('notationsToBan'),
	warningsToFinalBan = getConfigValue('warningsToFinalBan'),
	warningsToDeletion = getConfigValue('warningsToDeletion')
}

function onTextEdit(cid, item, text)
	unregisterCreatureEvent(cid, "Ban_Finish")
	if(item.itemid ~= 2599) then
		return true
	end

	local data = table.unserialize(getCreatureStorage(cid, "banConfig"))
	if(not data.type) then
		return true
	end

	if(text:len() == 0) then
		return false
	end

	text = text:explode("\n")
	if(not data.subType or isInArray({1, 5}, data.subType)) then
		if(text[1] ~= "Name:" or text[3] ~= "(Optional) Length:" or text[5] ~= "Comment:") then
			doPlayerSendCancel(cid, "Invalid format.")
			return false
		end

		local size = table.maxn(text)
		if(size > 6) then
			data.comment = ""
			for i = 6, size do
				data.comment = data.comment .. text[i] .. "\n"
			end
		else
			data.comment = text[6]
		end

		if(text[4]:len() > 0) then
			data.length = loadstring("return " .. text[4])()
		end
	elseif(text[1] ~= "Name:" or text[3] ~= "Comment:") then
		doPlayerSendCancel(cid, "Invalid format.")
		return false
	else
		data.comment = text[4]
	end

	data.name = text[2]
	if(data.type == 1) then
		errors(false)
		local player = getPlayerGUIDByName(data.name, true)

		errors(true)
		if(not player) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(cid, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		local warnings, warning = getAccountWarnings(account), 1
		if(data.subType == 1) then
			if(not tonumber(data.length)) then
				data.length = os.time() + config.banLength
				if((warnings + 1) >= config.warningsToDeletion) then
					data.length = -1
				elseif((warnings + 1) >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end
			else
				data.length = os.time() + data.length
			end

			doAddAccountBanishment(account, player, data.length, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. (warnings + 1) .. ") has been banned.")
		elseif(data.subType == 2) then
			doAddAccountBanishment(account, player, config.finalBanLength, data.comment, getPlayerGUID(cid))
			if(warnings < config.warningsToFinalBan) then
				warning = config.warningsToFinalBan - warnings
			end

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. warning .. ") has been banned.")
		elseif(data.subType == 3) then
			doAddAccountBanishment(account, player, -1, data.comment, getPlayerGUID(cid))
			if(warnings < config.warningsToDeletion) then
				warning = config.warningsToDeletion - warnings
			end

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. warning .. ") has been deleted.")
		elseif(data.subType == 4) then
			local notations = getNotationsCount(account) + 1
			if(notations >= config.notationsToBan) then
				data.length = os.time() + config.banLength
				if((warnings + 1) >= config.warningsToDeletion) then
					data.length = -1
				elseif((warnings + 1) >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end

				doAddAccountBanishment(account, player, data.length, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. (warnings + 1) .. ") has been banned reaching notations limit.")
			else
				doAddNotation(account, player, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (account notations: " .. notations .. ") has been noted.")
				warning = 0
			end
		end

		if(warning > 0) then
			doAddAccountWarnings(account, warning)
			doRemoveNotations(account)

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		end
	elseif(data.type == 2) then
		errors(false)
		local player = getPlayerGUIDByName(data.name, true)

		errors(true)
		if(not player) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(account, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		data.subType = data.subType - 4
		if(data.subType == 1) then
			if(not tonumber(data.length)) then
				local warnings = getAccountWarnings(account) + 1
				data.length = os.time() + config.banLength
				if(warnings >= config.warningsToDeletion) then
					data.length = -1
				elseif(warnings >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end
			else
				data.length = os.time() + data.length
			end

			doAddPlayerBanishment(data.name, 3, data.length, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned.")

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		elseif(data.subType == 2) then
			doAddPlayerBanishment(data.name, 3, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been deleted.")
		elseif(data.subType == 3) then
			local warnings, notations = getAccountWarnings(account) + 1, getNotationsCount(account, player) + 1
			if(notations >= config.notationsToBan) then
				data.length = os.time() + config.banLength
				if(warnings >= config.warningsToDeletion) then
					data.length = -1
				elseif(warnings >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end

				doAddPlayerBanishment(account, 3, data.length, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned reaching notations limit.")

				local pid = getPlayerByGUID(player)
				if(pid) then
					doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
					doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
					addEvent(valid(doRemoveCreature), 1000, pid, true)
				end
			else
				doAddNotation(account, player, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (notations: " .. notations .. ") has been noted.")
			end
		elseif(data.subType == 4) then
			doAddPlayerBanishment(data.name, 1, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been reported.")
		elseif(data.subType == 5) then
			doAddPlayerBanishment(data.name, 2, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been namelocked.")

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		end
	elseif(data.type == 3) then
		local ip = getIpByName(data.name)
		if(not ip) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(account, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		if(not tonumber(data.length)) then
			data.length = config.ipBanLength
		end

		doAddIpBanishment(ip, 4294967295, os.time() + data.length, data.comment, getPlayerGUID(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned on IP: " .. doConvertIntegerToIp(ip) .. ".")

		local pid = getPlayerByGUID(player)
		if(pid) then
			doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
			doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
			addEvent(valid(doRemoveCreature), 1000, pid, true)
		end
	end

	return false
end

data/creaturescripts/ban/type.lua
LUA:
local config = {
	banLength = getConfigValue('banLength'),
	finalBanLength = getConfigValue('finalBanLength'),
	ipBanLength = getConfigValue('ipBanLength'),
	notationsToBan = getConfigValue('notationsToBan'),
	warningsToFinalBan = getConfigValue('warningsToFinalBan'),
	warningsToDeletion = getConfigValue('warningsToDeletion')
}

function onTextEdit(cid, item, text)
	unregisterCreatureEvent(cid, "Ban_Finish")
	if(item.itemid ~= 2599) then
		return true
	end

	local data = table.unserialize(getCreatureStorage(cid, "banConfig"))
	if(not data.type) then
		return true
	end

	if(text:len() == 0) then
		return false
	end

	text = text:explode("\n")
	if(not data.subType or isInArray({1, 5}, data.subType)) then
		if(text[1] ~= "Name:" or text[3] ~= "(Optional) Length:" or text[5] ~= "Comment:") then
			doPlayerSendCancel(cid, "Invalid format.")
			return false
		end

		local size = table.maxn(text)
		if(size > 6) then
			data.comment = ""
			for i = 6, size do
				data.comment = data.comment .. text[i] .. "\n"
			end
		else
			data.comment = text[6]
		end

		if(text[4]:len() > 0) then
			data.length = loadstring("return " .. text[4])()
		end
	elseif(text[1] ~= "Name:" or text[3] ~= "Comment:") then
		doPlayerSendCancel(cid, "Invalid format.")
		return false
	else
		data.comment = text[4]
	end

	data.name = text[2]
	if(data.type == 1) then
		errors(false)
		local player = getPlayerGUIDByName(data.name, true)

		errors(true)
		if(not player) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(cid, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		local warnings, warning = getAccountWarnings(account), 1
		if(data.subType == 1) then
			if(not tonumber(data.length)) then
				data.length = os.time() + config.banLength
				if((warnings + 1) >= config.warningsToDeletion) then
					data.length = -1
				elseif((warnings + 1) >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end
			else
				data.length = os.time() + data.length
			end

			doAddAccountBanishment(account, player, data.length, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. (warnings + 1) .. ") has been banned.")
		elseif(data.subType == 2) then
			doAddAccountBanishment(account, player, config.finalBanLength, data.comment, getPlayerGUID(cid))
			if(warnings < config.warningsToFinalBan) then
				warning = config.warningsToFinalBan - warnings
			end

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. warning .. ") has been banned.")
		elseif(data.subType == 3) then
			doAddAccountBanishment(account, player, -1, data.comment, getPlayerGUID(cid))
			if(warnings < config.warningsToDeletion) then
				warning = config.warningsToDeletion - warnings
			end

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. warning .. ") has been deleted.")
		elseif(data.subType == 4) then
			local notations = getNotationsCount(account) + 1
			if(notations >= config.notationsToBan) then
				data.length = os.time() + config.banLength
				if((warnings + 1) >= config.warningsToDeletion) then
					data.length = -1
				elseif((warnings + 1) >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end

				doAddAccountBanishment(account, player, data.length, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (warnings: " .. (warnings + 1) .. ") has been banned reaching notations limit.")
			else
				doAddNotation(account, player, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (account notations: " .. notations .. ") has been noted.")
				warning = 0
			end
		end

		if(warning > 0) then
			doAddAccountWarnings(account, warning)
			doRemoveNotations(account)

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		end
	elseif(data.type == 2) then
		errors(false)
		local player = getPlayerGUIDByName(data.name, true)

		errors(true)
		if(not player) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(account, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		data.subType = data.subType - 4
		if(data.subType == 1) then
			if(not tonumber(data.length)) then
				local warnings = getAccountWarnings(account) + 1
				data.length = os.time() + config.banLength
				if(warnings >= config.warningsToDeletion) then
					data.length = -1
				elseif(warnings >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end
			else
				data.length = os.time() + data.length
			end

			doAddPlayerBanishment(data.name, 3, data.length, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned.")

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		elseif(data.subType == 2) then
			doAddPlayerBanishment(data.name, 3, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been deleted.")
		elseif(data.subType == 3) then
			local warnings, notations = getAccountWarnings(account) + 1, getNotationsCount(account, player) + 1
			if(notations >= config.notationsToBan) then
				data.length = os.time() + config.banLength
				if(warnings >= config.warningsToDeletion) then
					data.length = -1
				elseif(warnings >= config.warningsToFinalBan) then
					data.length = os.time() + config.finalBanLength
				end

				doAddPlayerBanishment(account, 3, data.length, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned reaching notations limit.")

				local pid = getPlayerByGUID(player)
				if(pid) then
					doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
					doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
					addEvent(valid(doRemoveCreature), 1000, pid, true)
				end
			else
				doAddNotation(account, player, data.comment, getPlayerGUID(cid))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " (notations: " .. notations .. ") has been noted.")
			end
		elseif(data.subType == 4) then
			doAddPlayerBanishment(data.name, 1, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been reported.")
		elseif(data.subType == 5) then
			doAddPlayerBanishment(data.name, 2, -1, data.comment, getPlayerGUID(cid))
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been namelocked.")

			local pid = getPlayerByGUID(player)
			if(pid) then
				doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
				doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
				addEvent(valid(doRemoveCreature), 1000, pid, true)
			end
		end
	elseif(data.type == 3) then
		local ip = getIpByName(data.name)
		if(not ip) then
			doPlayerSendCancel(cid, "Player not found.")
			return false
		end

		local account = getAccountIdByName(data.name)
		if(account == 0 or getAccountFlagValue(account, PLAYERFLAG_CANNOTBEBANNED)) then
			doPlayerSendCancel(cid, "You cannot take action on this player.")
			return false
		end

		if(not tonumber(data.length)) then
			data.length = config.ipBanLength
		end

		doAddIpBanishment(ip, 4294967295, os.time() + data.length, data.comment, getPlayerGUID(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, getPlayerNameByGUID(player) .. " has been banned on IP: " .. doConvertIntegerToIp(ip) .. ".")

		local pid = getPlayerByGUID(player)
		if(pid) then
			doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "You have been banned.")
			doSendMagicEffect(getThingPosition(pid), CONST_ME_MAGIC_GREEN)
			addEvent(valid(doRemoveCreature), 1000, pid, true)
		end
	end

	return false
end

creaturescripts.xml
XML:
	<!-- Ban System -->
	<event type="channelrequest" name="Ban_Type" event="script" value="ban/type.lua"/>
	<event type="channelrequest" name="Ban_Action" event="script" value="ban/action.lua"/>
	<event type="textedit" name="Ban_Finish" event="script" value="ban/finish.lua"/>

now, go to, talkactions/scripts/ban.lua
LUA:
local TYPE_ACCESS = {
	[1] = { "Player" },
	[2] = { "Player" },
	[3] = { "Account", "Player" },
	[4] = { "Account", "Player" },
	[5] = { "Account", "Player", "IP" }
}

function onSay(cid, words, param, channel)
	unregisterCreatureEventType(cid, "channelrequest")
	unregisterCreatureEventType(cid, "textedit")

	doPlayerSendChannels(cid, TYPE_ACCESS[getPlayerAccess(cid)])
	registerCreatureEvent(cid, "Ban_Type")
	return true
end

talkactions.xml
XML:
<talkaction log="yes" group="3" words="/ban" event="script" value="ban.lua"/>
 
Back
Top