Public feed #887671

Untitled

public text v1 · immutable
Raw Edit
·published 2008-02-01 14:41 UTC
rendered paste body
function sendMessageToNearbyPlayers( message, messageType )

    local chatRadius = 20 --units

    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 )
        local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" )
        destroyElement( chatSphere )
        
        for index, nearbyPlayer in ipairs( nearbyPlayers ) do
            outputChatBox( getPlayerName(source) .. ": " .. message, nearbyPlayer )
        end
    end
end