Advertisement
Redxone

PlayerDetector - SmartHelmet Displayer

Sep 2nd, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. -- START API - smHUD
  2.  
  3. sh=peripheral.find("antenna")
  4.  
  5. function getHUD(player)
  6.  hm = sh.getHUD(player)
  7.  
  8.   return hm
  9. end
  10.  
  11. function getGUI(player)
  12.   hm = sh.getHUD(player)
  13.  
  14.   return hm.getGUI()
  15.  
  16. end
  17.  
  18. -- END API - smHUD
  19.  
  20. -- Grab Huds From These Employies
  21. local huders = {
  22.   "NAME1",
  23.   "NAME2",
  24. }
  25.  
  26. function getEmHUDS(hudppl)
  27.  
  28.   local emhuds = {}
  29.  
  30.   for i = 1, #hudppl do
  31.     emhuds[#emhuds+1] = smHUD.getHUD(hudppl[i])
  32.   end
  33.  
  34.   return emhuds
  35.  
  36. end
  37.  
  38. -- clear huds
  39.  
  40. function clearHUDS(huds)
  41.   for i = 1, #huds do
  42.     huds[i].clear()
  43.     huds[i].sync()
  44.   end
  45. end
  46.  
  47. -- Hud Broadcasting
  48. function broadcastHUD(huds,message,x,y)
  49.  
  50.   for i = 1, #huds do
  51.       huds[i].drawString(tostring(message),x,y,125,true)
  52.       huds[i].add()
  53.   end
  54.  
  55. end
  56.  
  57. -- Get Utils
  58. local pd = peripheral.wrap("right")
  59. os.loadAPI("smHUD")
  60. local pRange = 100
  61. local userhuds = {}
  62. userhuds = getEmHUDS(huders)
  63. plrz = {}
  64.  
  65. function getPlayers()
  66.     return pd.getNearbyPlayers(tonumber(pRange))
  67. end
  68.  
  69. function refresh()
  70.    clearHUDS(userhuds)
  71.    broadcastHUD(userhuds,"Players Near Lab - ",1,1)
  72.    broadcastHUD(userhuds,"In format of: ",1,11)
  73.    broadcastHUD(userhuds,"USERNAME",1,30)
  74.    broadcastHUD(userhuds,"DISTANCE",1,40)
  75.    local i = 1
  76.     for k, v in pairs(plrz) do
  77.        for l, m in pairs(v) do
  78.           i = i + 1
  79.           broadcastHUD(userhuds,"["..tostring(m).."]",100,9+(i*10))
  80.        end
  81.     end
  82. end
  83.  
  84. getPlayers()
  85. refresh()
  86.  
  87. -- Detection Loop
  88. while true do
  89.     sleep(0.01)
  90.     local nplrz = getPlayers()    
  91.     if(plrz ~= nplrz)then
  92.     plrz = nplrz
  93.     refresh()
  94.     end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement