Jump to content

Double Messages


ZeyadGTX

Recommended Posts

Hello I made small script which adds [ Admin ] [ Warden ] etc.. but the problem that if you made /start playercolors you can see double messages and i would like players having colors not to be white so i must /start playercolors

But i have double messages

Playercolors Script

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 
) 
  
addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
        if type == 1 then 
            cancelEvent() 
            local r, g, b = getPlayerColor(source) 
            local name = getPlayerName(source) 
            local msg = msg:gsub('#%x%x%x%x%x%x', '') 
             
        end 
    end 
) 
  
  
getPlayerColor = getPlayerNametagColor 
getPlayerColour = getPlayerNametagColor 
  

My Admin Tag Script

addEventHandler ( "onPlayerChat", root, 
function ( msg, type ) 
    if isObjectInACLGroup  ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Console" ) ) and type == 0 then 
        cancelEvent ( ) 
        local r, g, b = getPlayerNametagColor(source) 
        outputChatBox ( "#006400[ Owner ] " .. getPlayerName ( source ) .. ":#FFFFFF " .. msg, getRootElement(), r, g, b, true ) 
  
  
    elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Moderator" ) ) and type == 0 then    
        cancelEvent ( ) 
        local r, g, b = getPlayerNametagColor(source) 
        outputChatBox ( "#0064FF[ Warden ] " .. getPlayerName ( source ) .." :#FFFFFF " .. msg, getRootElement(), r, g, b, true ) 
  
  
  
  
elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "V.I.P" ) ) and type == 0 then    
        cancelEvent ( ) 
        local r, g, b = getPlayerNametagColor(source) 
        outputChatBox ( "#000000[ V.I.P ]#FF9600 " .. getPlayerName ( source ) .." :#FFFFFF " .. msg, getRootElement(), r, g, b, true ) 
     
  
  
    elseif isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "Everyone" ) ) and type == 0 then    
        cancelEvent ( ) 
        local r, g, b = getPlayerNametagColor(source) 
        outputChatBox ( "#00FF00[ Player ] " .. getPlayerName ( source ) .. " :#ffffff " .. msg, getRootElement(), r, g, b, true ) 
        end 
    end 
) 
  

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...