daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chat_range=100
  2.  
  3. addEventHandler("onPlayerJoin",getRootElement(),
  4. function ()
  5. bindKey(source,"u","down","chatbox","LocalChat")
  6. end)
  7.  
  8. addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
  9. function ()
  10. for index, player in pairs(getElementsByType("player")) do
  11. bindKey(player,"u","down","chatbox","LocalChat")
  12.   end
  13. end)
  14.  
  15. function isPlayerInRangeOfPoint(player,x,y,z,range)
  16.    local px,py,pz=getElementPosition(player)
  17.    return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range
  18. end
  19.  
  20. function onChat(player,_,...)
  21.   local px,py,pz=getElementPosition(player)
  22.   local msg = table.concat({...}, " ")
  23.   local nick=getPlayerName(player)
  24. local r,g,b = getTeamColor(getPlayerTeam(player))
  25.   for _,v in ipairs(getElementsByType("player")) do
  26.     if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
  27.       outputChatBox("(Localchat) "..nick..": #ffffff"..msg,v,r,g,b,true)
  28.     end
  29.   end
  30. end
  31. addCommandHandler("LocalChat",onChat)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top