Jump to content

double chat messages


5150

Recommended Posts

yeah yeah i know this post has probably been posted about 42 million times, but none of the posts give a straight forward answer... so i have admin tags, and i get double messages on the admin messages. i want to combine playercolors and my admin script into one resource if possible, but honestly all i want is to have tags while my players have colors. heres the admin tag script, and playercolors

Playercolors

local lowerBound,upperBound = unpack(get"color_range") 
g_Root = getRootElement () 
g_ResourceRoot = getResourceRootElement ( getThisResource () ) 
  
addEventHandler ( "onResourceStart", g_ResourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            processPlayer ( player ) 
        end 
    end 
) 
  
function processPlayer ( player ) 
    player = player or source 
    local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) 
    setPlayerNametagColor(player, r, g, b) 
end 
addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) 
  
  
addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
        if type == 0 then 
            cancelEvent() 
            local r, g, b = getPlayerColor(source) 
            local name = getPlayerName(source) 
            local msg = msg:gsub('#%x%x%x%x%x%x', '') 
            outputChatBox( name.. ': #FFFFFF' .. msg, g_Root, r, g, b, true) 
            outputServerLog( "CHAT: " .. name .. ": " .. msg ) 
        end 
    end 
) 
  
getPlayerColor = getPlayerNametagColor 
getPlayerColour = getPlayerNametagColor 

admin tags

function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
if (msgtype == 0) then 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
     cancelEvent(true) 
        outputChatBox("#990000|OWNER| #999999" .. name .. ":#f7fc00 " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #990000~|OWNER|~ " .. name .. ": " .. text) 
        
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
     cancelEvent(true) 
        outputChatBox("#000000~SuperModerator~ #66FF00" .. name ..":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00a2fc~SuperModerator~" .. name .. ": " .. text) 
       
       
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
     cancelEvent(true) 
        outputChatBox("#3366ff~Moderator~ #00ff00" .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT:  #00ff00~Moderator~ " .. name .. ": " .. text) 
  
         
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Trainee")) then 
     cancelEvent(true) 
        outputChatBox(" #FFFF00~Trainee~ " .. name .. ":#FFFFFF " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #FFFF00~Vip~" .. name .. ": " .. text) 
  
         
 elseif isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
     cancelEvent(true) 
        outputChatBox(" #00a2fc~|OWNER|~ " .. name .. ":#f7fc00 " .. text, root, 255, 255, 255, true) 
        outputServerLog("CHAT: #00a2fc~|OWNER|~" .. name .. ": " .. text) 
        end 
         
         
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  

Link to comment

actually i don't get what you really want but maybe this will work with you

function chatbox(text, msgtype) 
local root = getRootElement() 
local account = getAccountName(getPlayerAccount(source)) 
local name = getPlayerName(source) 
local color = string.format("#%02X%02X%02X", getPlayerNametagColor(source)) 
if (msgtype == 0) then 
cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
        outputChatBox("#990000|OWNER| "..color.."" .. name .. ":#f7fc00 " .. text, root, 255,255,255, true) 
        outputServerLog("CHAT: #990000~|OWNER|~ " .. name .. ": " .. text) 
        
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then 
      
        outputChatBox("#000000~SuperModerator~ "..color.."" .. name ..":#FFFFFF " .. text, root, 255,255,255, true) 
        outputServerLog("CHAT: #00a2fc~SuperModerator~" .. name .. ": " .. text) 
      
      
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then 
      
        outputChatBox("#3366ff~Moderator~ "..color.."" .. name .. ":#FFFFFF " .. text, root, 255,255,255, true) 
        outputServerLog("CHAT:  #00ff00~Moderator~ " .. name .. ": " .. text) 
  
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Trainee")) then 
      
        outputChatBox(" #FFFF00~Trainee~ "..color.."" .. name .. ":#FFFFFF " .. text, root, 255,255,255, true) 
        outputServerLog("CHAT: #FFFF00~Vip~" .. name .. ": " .. text) 
  
        
 elseif isObjectInACLGroup("user." .. account, aclGetGroup("Console")) then 
      
        outputChatBox(" #00a2fc~|OWNER|~ "..color.."" .. name .. ":#f7fc00 " .. text, root, 255,255,255, true) 
        outputServerLog("CHAT: #00a2fc~|OWNER|~" .. name .. ": " .. text) 
        end 
        
        
elseif (msgtype == 2) then 
  
end 
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
  

Link to comment

yes. my player colors works fine, but basically the script puts my name with a tag, (so like |OWNER| [PMG]DeathWatch5150[L]: TEXTTEXTTEXT) but as a separate output. so it will be:

Admin tag output:

Playercolors output:

because the admin tags creates a new output.

if i delete playercolors, only staff can see their messages (because of tags), but if i keep it, staff has 2 messages

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...