Jump to content

Text Radius Help.


v0nz

Recommended Posts

-- define our chat radius 
  
local chatRadius = 20 --units 
  
-- define a handler that will distribute the message to all nearby players 
function sendMessageToNearbyPlayers( message, messageType ) 
    -- we will only send normal chat messages, action and team types will be ignored 
    if messageType == 0 then 
        -- get the chatting player's position 
        local posX, posY, posZ = getElementPosition( source ) 
         
        -- create a sphere of the specified radius in that position 
        local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
        -- get a table all player elements inside it 
        local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
        -- and destroy the sphere, since we're done with it 
        destroyElement( chatSphere ) 
         
        -- deliver the message to each player in that table 
        for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
            outputChatBox( message, nearbyPlayer ) 
        end 
    end 
end 
-- attach our new chat handler to onPlayerChat 
addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) 
  
-- define another handler function that cancels the event so that the message won't be delivered through the  
function blockChatMessage() 
    cancelEvent() 
end 
-- attach it as a handler to onPlayerChat 
  
  
addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) 

I am trying to make it... A name: "Chat"

I was looking at outputChatBox( message, nearbyPlayer ). Adding getClientName: does not work.

Link to post

You just pasted an example straight from the wiki entry for the onPlayerChat() event... It should work just fine. What are you trying to do to modify it??? And that example is for server-side code, so make sure you're running it that way.

Link to post
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...