• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Change prefix on this world chat

Status
Not open for further replies.

savenx

Enthusiast
Hello.. I changed the command of this World chat to .chat... But when i type .chat ingame it says: There is no such command...

How i can fix it? I kknow its a lua script, but it works on my friend server..



When i change back to #w it works.. I want to change to .chat because players here preffer it.. Thanks


THE SCRIPT:
Code:
local ChatPrefix = "#chat";
local WorldChannelName = "WORLD";
local CooldownTimer = 3; -- 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] = "C79C6E|TInterface\\icons\\INV_Sword_27.png:20|t", -- Warrior
    [2] = "F58CBA|TInterface\\icons\\INV_Hammer_01.png:20|t", -- Paladin
    [3] = "ABD473|TInterface\\icons\\INV_Weapon_Bow_07.png:20|t", -- Hunter
    [4] = "FFF569|TInterface\\icons\\INV_ThrowingKnife_04.png:20|t", -- Rogue
    [5] = "FFFFFF|TInterface\\icons\\INV_Staff_30.png:20|t", -- Priest
    [6] = "C41F3B|TInterface\\icons\\Spell_Deathknight_ClassIcon.png:20|t", -- Death Knight
    [7] = "0070DE|TInterface\\icons\\inv_jewelry_talisman_04.png:20|t", -- Shaman
    [8] = "69CCF0|TInterface\\icons\\INV_Staff_13.png:20|t", -- Mage
    [9] = "9482C9|TInterface\\ICONS/Spell_Nature_FaerieFire.png:20|t", -- Warlock
    [11] = "FF7d0A|TInterface\\icons\\Ability_Druid_Maul.png:20|t" -- Druid
};
 
local Rank = {
    [0] = "7DFF00[", -- Player
   [1] = "E700B1[MOD|cff7DFF00] [|cffE700B1", -- Moderator
   [2] = "E7A200[GM|cff7DFF00] [|cffE7A200", -- Game Master
   [3] = "E7A200[ADMIN|cff7DFF00] [|cffE7A200", -- Admin
   [4] = "E7A200[OWNER|cff7DFF00] [|cffE7A200", -- 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) then
            local s = string.format("|cFFFF0000Voce precisa esperar %i segundo(s) para falar no chat!|r", math.floor(r));
            player:SendAreaTriggerMessage(s);
        else
            RCD[player:GetGUIDLow()] = os.clock() + CooldownTimer;
            local t = table.concat({"|cff000000 [", WorldChannelName, "] |cff", Rank[player:GetGMRank()] or Rank[0], "|Hplayer:", player:GetName(), "|h", player:GetName(), "|h|r|cff7DFF00]: |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);
 

Rochet2

Moderator / Eluna Dev
the script uses #chat as command
not .chat

Using .chat would require using the player event 42
For example:
Code:
RegisterPlayerEvent(42, function(_, player, cmd)
    local a = cmd:match("chat (.+)")
    if a then
        print(a)
    end
end)
 
Last edited:

Rochet2

Moderator / Eluna Dev
He uses #chat
or he uses .chat with the hook I already suggested
or he uses arcemu
or he has modified the system to work with . instead of # in C++
 

savenx

Enthusiast
The script hes using is this one o paste here, but i changed to "#chat" to get it working on my server.. Its eluna too.. How i can modify the system?
 

slp13at420

Mad Scientist
Code:
RegisterPlayerEvent(42, function(_, player, cmd)
    local a = cmd:match("chat (.+)")
    if a then
        print(a)
    end
end)

just like Rochet2 said above:

just change:
Code:
RegisterPlayerEvent(18, ChatSystem);

to:
Code:
RegisterPlayerEvent(42, ChatSystem);

then change:
Code:
local ChatPrefix = "#chat";
to:
Code:
local ChatPrefix = "chat";

you don't need to add the `.` to "chat" since its event IS (42) the command event and already expects `.` .
But the player will still need to type `.chat` to use it :D

hope this helps you :D
 
Last edited:

Foereaper

Founder
Lol, I should probably update my original world chat script to use the world chat hook. Seems like all the world chat scripts I see are partially or fully based off of my old script so :p
 

savenx

Enthusiast
just like Rochet2 said above:

just change:
Code:
RegisterPlayerEvent(18, ChatSystem);

to:
Code:
RegisterPlayerEvent(42, ChatSystem);

then change:
Code:
local ChatPrefix = "#chat";
to:
Code:
local ChatPrefix = "chat";

you don't need to add the `.` to "chat" since its event IS (42) the command event and already expects `.` .
But the player will still need to type `.chat` to use it :D

hope this helps you :D

Thanks everyone and specially you spl! I got it working! Thank you so much!
 
Status
Not open for further replies.
Top