Add chat colors to player names

This commit is contained in:
rubenwardy 2017-10-05 23:50:59 +01:00
parent 14452ddcd4
commit e05950d087

View File

@ -276,11 +276,13 @@ minetest.register_chatcommand("t", {
if team then if team then
minetest.log("action", tname .. "<" .. name .. "> ** ".. param .. " **") minetest.log("action", tname .. "<" .. name .. "> ** ".. param .. " **")
if minetest.global_exists("chatplus") then if minetest.global_exists("chatplus") then
chatplus.log(tname .. "<" .. name .. "> ** ".. param .. " **") chatplus.log("<" .. name .. "> ** ".. param .. " **")
end end
local color, colorHex = ctf_colors.get_color(name, ctf.player(name))
for username, to in pairs(team.players) do for username, to in pairs(team.players) do
minetest.chat_send_player(username, minetest.chat_send_player(username,
tname .. "<" .. name .. "> ** " .. param .. " **") minetest.colorize("#" .. colorHex:sub(3, 8), "<" .. name .. "> ** " .. param .. " **"))
end end
if minetest.global_exists("irc") and irc.feature_mod_channel then if minetest.global_exists("irc") and irc.feature_mod_channel then
irc:say(irc.config.channel, tname .. "<" .. name .. "> ** " .. param .. " **", true) irc:say(irc.config.channel, tname .. "<" .. name .. "> ** " .. param .. " **", true)
@ -299,6 +301,11 @@ if minetest.global_exists("chatplus") then
chatplus.log(tname .. "<" .. from .. "> " .. msg) chatplus.log(tname .. "<" .. from .. "> " .. msg)
end end
function chatplus.send_message_to_sender(from, msg)
local color, colorHex = ctf_colors.get_color(from, ctf.player(from))
minetest.chat_send_player(from, minetest.colorize("#" .. colorHex:sub(3, 8), "<" .. from .. "> ") .. msg)
end
chatplus.register_handler(function(from, to, msg) chatplus.register_handler(function(from, to, msg)
if not ctf.setting("chat.team_channel") then if not ctf.setting("chat.team_channel") then
-- Send to global -- Send to global
@ -306,9 +313,11 @@ if minetest.global_exists("chatplus") then
end end
if ctf.setting("chat.default") ~= "team" then if ctf.setting("chat.default") ~= "team" then
if ctf.player(from).team then local team_name = ctf.player(from).team
minetest.chat_send_player(to, ctf.player(from).team .. if team_name then
"<" .. from .. "> " .. msg) local color, colorHex = ctf_colors.get_color(from, ctf.player(from))
minetest.chat_send_player(to,
minetest.colorize("#" .. colorHex:sub(3, 8), "<" .. from .. "> ") .. msg)
return false return false
else else
return nil return nil