local CHANNEL_HELP = 7
local ticks = {3600000, 120000}
local types = {'mute', 'exhausted'}
local muted = {}
for i = 1, #ticks do
muted[types[i]] = Condition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT)
muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_HELP + i)
muted:setParameter(CONDITION_PARAM_TICKS, ticks[i])
end
local level = 8
local commands = { "!mute", "!unmute" }
function onSpeak(player, type, message)
local playerAccountType = player:getAccountType()
if player:getLevel() < level or playerAccountType == ACCOUNT_TYPE_NORMAL then
player:sendCancelMessage("You may not speak into channels as long as you are lower than level ".. level ..".")
return false
end
for k = 1, #ticks do
if player:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + k)then
player:sendCancelMessage("You are muted from the Help channel for using it inappropriately.")
return false
end
end
if playerAccountType >= ACCOUNT_TYPE_TUTOR then
if string.sub(message, 1, #commands[1]) == commands[1] then
local targetName = string.sub(message, #commands[1] + 1)
local target = Player(targetName)
if target ~= nil then
if playerAccountType > target:getAccountType() then
if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) then
target:addCondition(muted[types[1]])
sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been muted by " .. player:getName() .. " for using Help Channel inappropriately.")
else
if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
player:addCondition(muted[types[2]])
player:sendCancelMessage("That player is already muted, but now is exhausted.")
else
player:sendCancelMessage("That player is already muted and exhausted.")
end
end
else
player:sendCancelMessage("You are not authorized to mute that player.")
end
else
player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
end
return false
elseif string.sub(message, 1, #commands[2]) == #commands[2] then
local targetName = string.sub(message, #commands[2] + 1)
local target = Player(targetName)
if target ~= nil then
if playerAccountType > target:getAccountType() then
if target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 1) or target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + 2) then
for x = 1, #ticks do
target:removeCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP + x)
end
sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, targetName .. " has been unmuted by " .. player:getName() .. ".")
else
player:sendCancelMessage("That player is not muted.")
end
else
player:sendCancelMessage("You are not authorized to unmute that player.")
end
else
player:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
end
return false
end
end
if type == TALKTYPE_CHANNEL_Y then
if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
if playerAccountType < ACCOUNT_TYPE_TUTOR and not getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not getPlayerFlagValue(player, PlayerFlag_CanTalkRedChannel) then
if playerAccountType >= ACCOUNT_TYPE_TUTOR or getPlayerFlagValue(player, PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_O
else
type = TALKTYPE_CHANNEL_Y
end
end
end
return type
end