Skip to content

Commit

Permalink
fix: chat channels message based on player group
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 17, 2023
1 parent adb72e1 commit 08dcdf4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions data/chatchannels/scripts/advertising-rook.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function canJoin(player)
return player:getVocation():getId() == VOCATION_NONE or player:getAccountType() >= ACCOUNT_TYPE_SENIORTUTOR
return player:getVocation():getId() == VOCATION_NONE or player:getGroup():getId() >= GROUP_TYPE_SENIORTUTOR
end

local CHANNEL_ADVERTISING_ROOK = 6
Expand All @@ -9,7 +9,7 @@ muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_ADVERTISING_ROOK)
muted:setParameter(CONDITION_PARAM_TICKS, 120000)

function onSpeak(player, type, message)
if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
if player:getGroup():getId() >= GROUP_TYPE_GAMEMASTER then
if type == TALKTYPE_CHANNEL_Y then
return TALKTYPE_CHANNEL_O
end
Expand All @@ -28,7 +28,7 @@ function onSpeak(player, type, message)
player:addCondition(muted)

if type == TALKTYPE_CHANNEL_O then
if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
if player:getGroup():getId() < GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
Expand Down
6 changes: 3 additions & 3 deletions data/chatchannels/scripts/advertising.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function canJoin(player)
return player:getVocation():getId() ~= VOCATION_NONE or player:getAccountType() >= ACCOUNT_TYPE_SENIORTUTOR
return player:getVocation():getId() ~= VOCATION_NONE or player:getGroup():getId() >= GROUP_TYPE_SENIORTUTOR
end

local CHANNEL_ADVERTISING = 5
Expand All @@ -9,7 +9,7 @@ muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_ADVERTISING)
muted:setParameter(CONDITION_PARAM_TICKS, 120000)

function onSpeak(player, type, message)
if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
if player:getGroup():getId() >= GROUP_TYPE_GAMEMASTER then
if type == TALKTYPE_CHANNEL_Y then
return TALKTYPE_CHANNEL_O
end
Expand All @@ -28,7 +28,7 @@ function onSpeak(player, type, message)
player:addCondition(muted)

if type == TALKTYPE_CHANNEL_O then
if player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
if player:getGroup():getId() < GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
Expand Down
8 changes: 4 additions & 4 deletions data/chatchannels/scripts/english_chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ function onSpeak(player, type, message)
return false
end

local playerAccountType = player:getAccountType()
local playerGroupType = player:getGroup():getId()
if type == TALKTYPE_CHANNEL_Y then
if playerAccountType >= ACCOUNT_TYPE_GAMEMASTER then
if playerGroupType >= GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER then
if playerGroupType < GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
if playerGroupType < GROUP_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
type = TALKTYPE_CHANNEL_Y
end
end
Expand Down
18 changes: 9 additions & 9 deletions data/chatchannels/scripts/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_HELP)
muted:setParameter(CONDITION_PARAM_TICKS, 3600000)

function onSpeak(player, type, message)
local playerAccountType = player:getAccountType()
if player:getLevel() == 1 and playerAccountType == ACCOUNT_TYPE_NORMAL then
local playerGroupType = player:getGroup():getId()
if player:getLevel() == 1 and playerGroupType == GROUP_TYPE_NORMAL then
player:sendCancelMessage("You may not speak into channels as long as you are on level 1.")
return false
end
Expand All @@ -17,12 +17,12 @@ function onSpeak(player, type, message)
return false
end

if playerAccountType >= ACCOUNT_TYPE_TUTOR then
if playerGroupType >= GROUP_TYPE_TUTOR then
if string.sub(message, 1, 6) == "!mute " then
local targetName = string.sub(message, 7)
local target = Player(targetName)
if target then
if playerAccountType > target:getAccountType() then
if playerGroupType > target:getAccountType() then
if not target:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP) then
target:addCondition(muted)
target:setStorageValue(storage, os.time() + 180)
Expand All @@ -41,7 +41,7 @@ function onSpeak(player, type, message)
local targetName = string.sub(message, 9)
local target = Player(targetName)
if target then
if playerAccountType > target:getAccountType() then
if playerGroupType > target:getAccountType() then
if target:getStorageValue(storage) > os.time() then
target:removeCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP)
sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, target:getName() .. " has been unmuted.")
Expand All @@ -60,16 +60,16 @@ function onSpeak(player, type, message)
end

if type == TALKTYPE_CHANNEL_Y then
if playerAccountType >= ACCOUNT_TYPE_TUTOR or player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
if playerGroupType >= GROUP_TYPE_TUTOR or player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
if playerAccountType < ACCOUNT_TYPE_TUTOR and not player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
if playerGroupType < GROUP_TYPE_TUTOR and not player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
if playerAccountType >= ACCOUNT_TYPE_TUTOR or player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
if playerGroupType < GROUP_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
if playerGroupType >= GROUP_TYPE_TUTOR or player:hasFlag(PlayerFlag_TalkOrangeHelpChannel) then
type = TALKTYPE_CHANNEL_O
else
type = TALKTYPE_CHANNEL_Y
Expand Down
10 changes: 5 additions & 5 deletions data/chatchannels/scripts/tutor.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function canJoin(player)
return player:getAccountType() >= ACCOUNT_TYPE_TUTOR
return player:getGroup():getId() >= GROUP_TYPE_TUTOR
end

function onSpeak(player, type, message)
local playerAccountType = player:getAccountType()
local playerGroupType = player:getGroup():getId()
if type == TALKTYPE_CHANNEL_Y then
if playerAccountType >= ACCOUNT_TYPE_SENIORTUTOR then
if playerGroupType >= GROUP_TYPE_SENIORTUTOR then
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
if playerAccountType < ACCOUNT_TYPE_SENIORTUTOR then
if playerGroupType < GROUP_TYPE_SENIORTUTOR then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
if playerGroupType < GROUP_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
type = TALKTYPE_CHANNEL_Y
end
end
Expand Down
10 changes: 5 additions & 5 deletions data/chatchannels/scripts/world_chat.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
function onSpeak(player, type, message)
local playerAccountType = player:getAccountType()
if player:getLevel() == 1 and playerAccountType < ACCOUNT_TYPE_GAMEMASTER then
local playerGroupType = player:getGroup():getId()
if player:getLevel() == 1 and playerGroupType < GROUP_TYPE_GAMEMASTER then
player:sendCancelMessage("You may not speak into channels as long as you are on level 1.")
return false
end

if type == TALKTYPE_CHANNEL_Y then
if playerAccountType >= ACCOUNT_TYPE_GAMEMASTER then
if playerGroupType >= GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_O
end
elseif type == TALKTYPE_CHANNEL_O then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER then
if playerGroupType < GROUP_TYPE_GAMEMASTER then
type = TALKTYPE_CHANNEL_Y
end
elseif type == TALKTYPE_CHANNEL_R1 then
if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
if playerGroupType < GROUP_TYPE_GAMEMASTER and not player:hasFlag(PlayerFlag_CanTalkRedChannel) then
type = TALKTYPE_CHANNEL_Y
end
end
Expand Down

0 comments on commit 08dcdf4

Please sign in to comment.