daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 53 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. local playertable = getElementsByType("player")
  26. local newplayertable = {}
  27.   for i,v in ipairs(playertable ) do
  28.     if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
  29.     if v ~= player then
  30.      table.insert(newplayertable , v)
  31.     end
  32.   end
  33. local thecount = #newplayertable
  34.   for _,v in ipairs(newplayertable ) do
  35.       outputChatBox("(Localchat)["..thecount.."] "..nick..": #ffffff"..msg,v,r,g,b,true) -- put "thecount" somewhere in here
  36.   end
  37. end
  38. end
  39. 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