unfortunately your hex code will fail coloring anything as long as you don't allow color code to be used in outputChatBox's arguments (it's disabled by default). you also forget to add cancelEvent(), in the current form you would see everything on the chat twice.
chatRadius = 25 -- Units
function sendMessageToNearbyPlayers( message, messageType )
if messageType == 1 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
-- PUT COLOR IN HEX format, example red = #FF0000
outputChatBox ( "#FF0000" .. getPlayerName ( source ) .. " says: " .. message, nearbyPlayer,255,255,255,true )
end
cancelEvent()
end
end
addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers )
besides, i guess he wants to have different players having different colors.
for your use i'd suggest screwing the colshape and just use getDistanceBetweenPoints3D for each player (getElementsByType("player")) element and the player who sent it, for the colors you could just use getPlayerNametagColor or get/setElementData
of course you can keep it the way you currently do it and just use getPlayerNametagColor or get/setElementData and the color argument in outputChatBox
in both cases you should use the color code to color the text after the players name in some neutral color