Jump to content

Localchat.


Rat32

Recommended Posts

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 ) 
  
  
addEventHandler ( "onPlayerChat", getRootElement(), 
function ( message, messageType ) 
    if messageType == 1 then 
        cancelEvent() 
    end 
end) 

Why this doesn't work? Sends a double message, does not close the event.

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