Jump to content

Teamchat shows on globalchat (messageType == 2)


~Air

Recommended Posts

Posted

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) 

Posted

And the problem is...?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yeah, I noticed that, but he's not even stating what is the problem with his code.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Oh, my bad, I didn't read that part, still, it would be good if he put it on the actual topic aswell.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Sorry, that I didn't write it in the topic :S

So the problem is if you press Y (messageType == 2) everyone can read this message if he isn't in a team or in an another team.

Posted

Well, that's obvious, isn't it? do you see any team-related function in that code?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 
  

Posted
for _, team in ipairs ( getPlayersInTeam ( team ) ) do 
                outputChatBox("(TEAM): " ..getPlayerName(source)..": "..color..""..message, root, 255, 255, 255, true ) 
                end 

You must change 'root' to 'team'.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

?

Posted

You don't have to change event handler.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 
  
  

Posted

That's because "team" is nil outside that 'if' statement.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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