I wrote a small code that can be connected to chat, the problem is that if I start the resource there will be a double chat, how can I solve this so that there is only one chat
local radius = 10
addEventHandler("onPlayerChat", root,
function (message, messageType)
if (messageType == 0) then
local x, y, z = getElementPosition(source)
for i, player in ipairs(getElementsByType("player")) do
local x1, y1, z1 = getElementPosition(player)
local name = getPlayerName(source)
if getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) <= radius then
outputChatBox("#cccccc" .. name .. " #ffffff mondja: #cccccc"..message , root, 0, 0, 0, true)
end
end
end
end
)