Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local antiSpam = {}
- local antiSpamTime = 1000
- function isPlayerInRangeOfPoint(player,x,y,z,range)
- local px,py,pz=getElementPosition(player)
- return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range
- end
- function clearAntiSpam(player)
- destroyElement(antiSpam[player])
- end
- function main(message, messageType)
- if (message == "") or (message == " ") then return true end
- local plrTable = {}
- local pX, pY, pZ = getElementPosition(source)
- local sourceNick = getPlayerName(source)
- for i, v in ipairs(getElementsByType("player")) do
- if (isPlayerInRangeOfPoint(v, pX, pY, pZ, range)) then
- table.insert(plrTable, v)
- end
- end
- local playerCount = #plrTable - 1
- for _, v in pairs(plrTable) do
- if (isPlayerInRangeOfPoint(source, pX, pY, pZ, range)) then
- outputChatBox("[Local Chat]["..playerCount.."] "..sourceNick.." "..message, v, 200, 50, 150)
- setTimer(clearAntiSpam, antiSpamTime, 1, player)
- end
- end
- antiSpam[player] = getTickCount()
- end
- addEventHandler("onPlayerChat", root, main)
Advertisement
Add Comment
Please, Sign In to add comment