2013-08-06 00:39:06 +02:00
local CHANNEL_HELP = 7
2014-01-16 08:45:26 -03:00
local muted = Condition ( CONDITION_CHANNELMUTEDTICKS , CONDITIONID_DEFAULT )
muted : setParameter ( CONDITION_PARAM_SUBID , CHANNEL_HELP )
muted : setParameter ( CONDITION_PARAM_TICKS , 3600000 )
2013-08-06 00:39:06 +02:00
2014-01-16 21:09:12 -03:00
function onSpeak ( player , type , message )
2014-01-16 08:45:26 -03:00
if player : getCondition ( CONDITION_CHANNELMUTEDTICKS , CONDITIONID_DEFAULT , CHANNEL_HELP ) then
player : sendCancelMessage ( " You are muted from the Help channel for using it inappropriately. " )
2013-08-06 00:39:06 +02:00
return false
end
2022-04-02 15:42:56 -03:00
local playerAccountType = player : getAccountType ( )
2013-08-06 00:39:06 +02:00
if playerAccountType >= ACCOUNT_TYPE_TUTOR then
if string.sub ( message , 1 , 6 ) == " !mute " then
local targetName = string.sub ( message , 7 )
2014-01-16 08:45:26 -03:00
local target = Player ( targetName )
2017-12-17 18:03:57 -02:00
if target then
2014-01-16 08:45:26 -03:00
if playerAccountType > target : getAccountType ( ) then
if not target : getCondition ( CONDITION_CHANNELMUTEDTICKS , CONDITIONID_DEFAULT , CHANNEL_HELP ) then
target : addCondition ( muted )
sendChannelMessage ( CHANNEL_HELP , TALKTYPE_CHANNEL_R1 , target : getName ( ) .. " has been muted by " .. player : getName ( ) .. " for using Help Channel inappropriately. " )
2013-08-06 06:22:14 +02:00
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( " That player is already muted. " )
2013-08-06 06:22:14 +02:00
end
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( " You are not authorized to mute that player. " )
2013-08-06 06:22:14 +02:00
end
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE )
2013-08-06 00:39:06 +02:00
end
2013-08-06 03:56:14 +02:00
return false
2013-08-06 00:39:06 +02:00
elseif string.sub ( message , 1 , 8 ) == " !unmute " then
local targetName = string.sub ( message , 9 )
2014-01-16 08:45:26 -03:00
local target = Player ( targetName )
2017-12-17 18:03:57 -02:00
if target then
2014-01-16 08:45:26 -03:00
if playerAccountType > target : getAccountType ( ) then
if target : getCondition ( CONDITION_CHANNELMUTEDTICKS , CONDITIONID_DEFAULT , CHANNEL_HELP ) then
target : removeCondition ( CONDITION_CHANNELMUTEDTICKS , CONDITIONID_DEFAULT , CHANNEL_HELP )
sendChannelMessage ( CHANNEL_HELP , TALKTYPE_CHANNEL_R1 , target : getName ( ) .. " has been unmuted by " .. player : getName ( ) .. " . " )
2013-08-06 06:22:14 +02:00
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( " That player is not muted. " )
2013-08-06 06:22:14 +02:00
end
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( " You are not authorized to unmute that player. " )
2013-08-06 06:22:14 +02:00
end
else
2014-01-16 08:45:26 -03:00
player : sendCancelMessage ( RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE )
2013-08-06 00:39:06 +02:00
end
2013-08-06 03:56:14 +02:00
return false
2013-08-06 00:39:06 +02:00
end
end
2013-08-06 06:22:14 +02:00
if type == TALKTYPE_CHANNEL_Y then
2017-12-19 20:47:29 -02:00
if playerAccountType >= ACCOUNT_TYPE_TUTOR or player : hasFlag ( PlayerFlag_TalkOrangeHelpChannel ) then
2013-08-06 06:22:14 +02:00
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
2017-12-19 20:47:29 -02:00
if playerAccountType < ACCOUNT_TYPE_TUTOR and not player : hasFlag ( PlayerFlag_TalkOrangeHelpChannel ) then
2013-08-06 06:22:14 +02:00
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
2017-12-19 20:47:29 -02:00
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not player : hasFlag ( PlayerFlag_CanTalkRedChannel ) then
if playerAccountType >= ACCOUNT_TYPE_TUTOR or player : hasFlag ( PlayerFlag_TalkOrangeHelpChannel ) then
2013-08-06 06:22:14 +02:00
type = TALKTYPE_CHANNEL_O
else
type = TALKTYPE_CHANNEL_Y
end
end
end
return type
2013-08-06 00:39:06 +02:00
end