Jump to content

Teamchat shows on globalchat (messageType == 2)


~Air

Recommended Posts

Hey guys,

I am back with an another problem but I don't know what's false, there is no error.

Here is the code:

-- Teamchat

local function playerChat(message, messageType) 
    if messageType == 2 then  
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
             if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                local color = getAccountData(acc,"chatc") 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) 
            else 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) 
            end 
        else 
            outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) 
        end 
        outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
    end 
end 
addEventHandler("onPlayerChat", root, playerChat) 

Link to comment

Here is my new code:

it's still the same problem: everyone can see it.

local function playerChat(message, messageType) 
    if messageType == 2 then  
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
             if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                local color = getAccountData(acc,"chatc") 
                local team = getPlayerTeam ( source ) 
                if ( not team ) then 
                    return 
                end 
                 for _, team in ipairs ( getPlayersInTeam ( team ) ) do 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) 
                end 
            else 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) 
            end 
        else 
            outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, 255, 255, 255, true ) 
        end 
        outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
    end 
 end 
addEventHandler("onPlayerChat", root, playerChat) 
  

Link to comment

for _, team in ipairs ( getPlayersInTeam ( team ) ) do

outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true )

end

--> to:

for _, team in ipairs ( getPlayersInTeam ( team ) ) do

outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, team, 255, 255, 255, true )

end

?

Link to comment

That's my script, but I can see it anyway.

local function teamChat(message, messageType) 
    if messageType == 2 then 
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
             if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                local color = getAccountData(acc,"chatc") 
                local team = getPlayerTeam ( source ) 
                if ( not team ) then 
                    return 
                end 
                 for _, team in ipairs ( getPlayersInTeam ( team ) ) do 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, team, 255, 255, 255, true ) 
                end 
            else 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": #FFFFFF"..message, team, 255, 255, 255, true ) 
            end 
        else 
            outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, team, 255, 255, 255, true ) 
        end 
        outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
    end 
 end 
addEventHandler("onPlayerChat", root, teamChat) 
  
  

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