Jump to content

teamchat enable again


BorderLine

Recommended Posts

Hi everyone.

Well

to make less flood in my server, i make this

local chatRadius = 50 
  
function sendMessageToNearbyPlayers( message, messageType ) 
    if messageType == 0 then 
        local posX, posY, posZ = getElementPosition( source ) 
  
        local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
        local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
        destroyElement( chatSphere ) 
  
        for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
        local red, green, blue = getPlayerNametagColor(source) 
            outputChatBox( getPlayerName(source)..": #ffffff"..message, nearbyPlayer, red, green, blue, true ) 
        end 
    end 
end 
addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) 
  
  
function blockChatMessage() 
    cancelEvent() 
end 
addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) 

But the teamchat was removed.

If i speak with "Y"

dont show message

How i can put back again? im searched in forum and i readed the wiki but i dont know how do. If someone can helpme :)

thanks for your time

Link to comment

Your problem is the "blockChatMessage" function, it'll cancel all chat messages, no matters if is not a team message, you have to use cancelEvent on "sendMessageToNearbyPlayers" function.

local chatRadius = 50 
  
function sendMessageToNearbyPlayers ( message, messageType ) 
    if ( messageType == 0 ) then 
        local posX, posY, posZ = getElementPosition ( source ) 
  
        local chatSphere = createColSphere ( posX, posY, posZ, chatRadius ) 
        local nearbyPlayers = getElementsWithinColShape ( chatSphere, "player" ) 
        destroyElement ( chatSphere ) 
  
        for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
            local red, green, blue = getPlayerNametagColor ( source ) 
            outputChatBox( getPlayerName ( source )..": #ffffff".. message, nearbyPlayer, red, green, blue, true ) 
        end 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) 

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