local ChatPrefix = ",w";
local WorldChannelName = "World Channel";
local CooldownTimer = 1; -- Cooldown in seconds. Set to 0 for no CD obviously.
local Class = { -- Class colors :) Prettier and easier than the elseif crap :) THESE ARE HEX COLORS!
[1] = "FEC1C0", -- Warrior
[2] = "FEC1C0", -- Paladin
[3] = "FEC1C0", -- Hunter
[4] = "FEC1C0", -- Rogue
[5] = "FEC1C0", -- Priest
[6] = "FEC1C0", -- Death Knight
[7] = "FEC1C0", -- Shaman
[8] = "FEC1C0", -- Mage
[9] = "FEC1C0", -- Warlock
[11] = "FEC1C0" -- Druid
};
local Rank = {
[0] = "FEC1C0", -- Player
[1] = "005aff", -- Moderator
[2] = "005aff", -- Game Master
[3] = "005aff", -- Admin
[4] = "FEC1C0" -- Console
};
-- Do not edit below unless you know what you're doing :)
if (ChatPrefix:sub(-1) ~= " ") then
ChatPrefix = ChatPrefix.." ";
end
local RCD = {};
function ChatSystem(event, player, msg, _, lang)
if (RCD[player:GetGUIDLow()] == nil) then
RCD[player:GetGUIDLow()] = 0;
end
if (msg:sub(1, ChatPrefix:len()) == ChatPrefix) then
local r = RCD[player:GetGUIDLow()] - os.clock();
if (0 < r and player:GetGMRank() == 0) then
local s = string.format("|cFFFF0000You must wait %i second(s) before sending another chat message!|r", math.floor(r));
player:SendAreaTriggerMessage(s);
else
RCD[player:GetGUIDLow()] = os.clock() + CooldownTimer;
local t = table.concat({"|cffFEC1C0[", WorldChannelName, "] [|r|cff", Rank[player:GetGMRank()] or Rank[0], "|Hplayer:", player:GetName(), "|h", player:GetName(), "|h|r|cffFEC1C0]: |r|cff", Class[player:GetClass()], msg:sub(ChatPrefix:len()+1), "|r"});
SendWorldMessage(t);
end
return false;
end
end
RegisterPlayerEvent(18, ChatSystem);
RegisterPlayerEvent(4, function(_, player) RCD[player:GetGUIDLow()] = 0; end);