Jump to content

Chat Local


Recommended Posts

Eu estou com um chat local aki, e tipo quando eu vou digitar um comando na letra T n vai.

chat_range=100 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
bindKey(source,"T","down","chatbox","LocalChat") 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
bindKey(player,"T","down","chatbox","LocalChat") 
  end 
end) 
  
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 onChat(player,_,...) 
  local px,py,pz=getElementPosition(player) 
  local msg = table.concat({...}, " ") 
  local nick=getPlayerName(player) 
local r,g,b = getTeamColor(getPlayerTeam(player)) 
  for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox("#FF0000[ChatLocal]#ffffff"..nick.."#ffffff : "..msg,v,r,g,b,true) 
    end 
  end 
end 
addCommandHandler("LocalChat",onChat) 

----------------------------------------------------------------------------------------------------------------

  
function MensagemAnon(source, cmd, ...) 
    local MessagemANS = table.concat ( { ... }, " " ); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#696969[Anônimo]#696969 : "..MessagemANS,v, 255, 255, 255, true)  --efeito no chat
    end 
end 
addCommandHandler("ilegal",  MensagemAnon)
  
function MensagemRP(source, cmd, ...) 
    local MessagemFRP = table.concat ( { ... }, " " ); 
    local name = getPlayerName(source); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#FF0000[Fora RP] #FFFFFF"..name.."#ffffff : "..MessagemFRP,v, 255, 255, 255, true) --efeito no chat
    end 
end 
addCommandHandler("frp",  MensagemRP)

function MensagemO(source, cmd, ...) 
    local MessagemOLX = table.concat ( { ... }, " " ); 
    local name = getPlayerName(source); 
for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#00BFFF[OLX] #FFFFFFO "..name.."#ffffff : está anunciando "..MessagemOLX,v, 255, 255, 255, true) --efeito no chat
    end 
end 
addCommandHandler("olx",  MensagemO)
---------------------------------------------------------------------------------------------------------------

 alguém sabe me falar como eu arrumo isso?

Edited by St4rk
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...