chat_range = 100
chatTime = {}
elementID = "ID"
lastChatMessage = {}
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 onChatLocal(text, type)
local new = ""
local iter = 0
local msg = string.gsub(text, "_", "")
for word in msg:gmatch("%S+") do
iter = iter + 1
if iter == 1 and word:len() > 0 then
word = word:gsub("%a", string.upper, 1)
end
new = new..word.." "
end
if new ~= "" then msg = new end
text = msg
if not hasObjectPermissionTo(source, "function.kickPlayer") then
if chatTime[source] and chatTime[source] + tonumber(5000) > getTickCount() then
cancelEvent()
outputChatBox("Espere 5 segundo para poder digitar novamente!", source, 255, 0, 0)
return
else
chatTime[source] = getTickCount()
end
end
lastChatMessage[source] = text
cancelEvent(true)
local px,py,pz = getElementPosition(source)
local nick = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
local id = getElementData(source, elementID) or "n.a"
for _,v in ipairs(getElementsByType("player")) do
if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
outputChatBox("᠉ #1E90FF BNR - #ffa500[ ChatLocal ] - #FFFFFF"..nick.." #1E90FF ["..id.."]#00ff00 - #ffa500"..msg, v, 200, 200, 200,true)
end
end
end
addEventHandler("onPlayerChat", root, onChatLocal)
function MensagemTwitter(source, cmd, ...)
local MessagemT = table.concat ( { ... }, " " )
local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
local id = getElementData(source, elementID) or "n.a"
for _,v in ipairs(getElementsByType("player")) do
outputChatBox("᠉ #1E90FF BNR - #1E90FF[ Facebook ] - #ffffff"..name.." #1E90FF["..id.."]#00BFFF - #1E90FF"..MessagemT,v, 255, 255, 255, true)
end
end
addCommandHandler("Facebook", MensagemTwitter)
addCommandHandler( "DeepWeb", function ( source, cmd, ... )
local message2 = #{...} > 0 and table.concat({...}," ") or nil
if message2 then
for _, p in ipairs (getElementsByType("player")) do
if hasObjectPermissionTo(p, "command.mute", true) then
local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
local id = getElementData(source, elementID) or "n.a"
outputChatBox("᠉ #1E90FF BNR - #696969[ DeepWeb ] - #ffffff"..name.." ["..id.."]#696969 - #696969"..message2, p, 255, 255, 255, true)
else
outputChatBox("᠉ #696969 DeepWeb - #696969"..message2, p, 255, 255, 255, true)
end
end
else
end
end)
addEventHandler("onPlayerJoin", getRootElement(), function()
bindKey(source, "y", "down", "chatbox", "Facebook")
end)
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function()
for index,player in pairs(getElementsByType("player")) do
bindKey(player,"y", "down", "chatbox", "Facebook")
end
end)
addEventHandler("onPlayerJoin", getRootElement(), function()
bindKey(source, "u", "down", "chatbox", "DeepWeb")
end)
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function()
for index,player in pairs(getElementsByType("player")) do
bindKey(player,"u", "down", "chatbox", "DeepWeb")
end
end)