Jump to content

Team Chat


ZeyadGTX

Recommended Posts

Posted

Hello guys i have script made by Nikolai96 he helped me with this script , the script make you in team chat (TEAM) this word changes to (CLAN) but the problem i want this (CLAN) with Red color and the other doesn't change i forgot that script because my pc was formated and i forgot every thing help pls , the problem is the whole text is with green iwant only (CLAN)

addEventHandler('onPlayerChat', getRootElement(), 
    function(msg, type) 
        if type == 2 then 
            cancelEvent() 
            local r, g, b = getPlayerNametagColor(source) 
            for placeNumber, playerData in ipairs(getPlayersInTeam(getPlayerTeam(source))) do 
                outputChatBox("#00FF00(CLAN)"..getPlayerName(source)..":#FFFFFF "..string.gsub(msg, "#%x%x%x%x%x%x", ""), playerData, r, g, b, true) 
            end 
        end 
    end 
) 

My nick in MTA is Spider

Posted

Try this:

addEventHandler('onPlayerChat', getRootElement(), 
    function(msg, type) 
        if type == 2 then 
            cancelEvent() 
            local playerTeam = getPlayerTeam(source) 
            if playerTeam then 
                local r, g, b = getTeamColor(playerTeam) 
                local hexColor = string.format("#%.2X%.2X%.2X", r, g, b) 
            else 
                return 
            end 
            for placeNumber, playerData in ipairs(getPlayersInTeam(playerTeam)) do 
                outputChatBox("#00FF00(CLAN)"..hexColor .. getPlayerName(source)..":#FFFFFF "..msg:gsub("#%x%x%x%x%x%x", ""), playerData, r, g, b, true) 
            end 
        end 
    end 
) 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
function RGBToHex(red, green, blue) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255)) then 
        return nil 
    end 
    return string.format("#%.2X%.2X%.2X", red, green, blue) 
end 
  
local function onplayerChat ( message, messageType ) 
    if ( messageType == 2 ) then --Team (Clan) chat 
        cancelEvent ( ) 
        local name = getPlayerName ( source ) 
        local red, green, blue = getPlayerNametagColor ( source ) 
        local hex = RGBToHex ( red, green, blue ) 
  
        local team = getPlayerTeam( source ) 
        if not team then 
            return outputChatBox( "You are not part of a team yet !", source, 200, 100, 0) 
        end 
  
        local members = getPlayersInTeam( team ) or {} 
        for _, player in ipairs(members) do 
            outputChatBox( "#FF0000(CLAN)" .. hex.." "..name .. ": #FFFFFF" .. message, player, 255, 255, 255, true ) 
        end 
        outputServerLog( "(TEAM): " .. name .. ": " .. message ) 
    end 
end 
addEventHandler ( "onPlayerChat", root, onplayerChat ) 
addCommandHandler("c", onplayerChat) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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