ZNZNCOOP

health

Aug 6th, 2014
232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. players={}
  2. os.loadAPI('ip')
  3. ip.open()
  4. ip.getIP()
  5. p=peripheral.wrap('bottom')
  6.  
  7. function health()
  8.   while true do
  9.     for name,player in pairs(players) do
  10.       if player.time>0 then
  11. --        player.pl.heal(20)
  12.         player.time=player.time-1
  13.       else
  14.         player.pl.sendChat(name..', time out!')
  15.         players[name]=nil
  16.       end
  17.     end
  18.     sleep(1)
  19.   end
  20. end
  21.  
  22. function check()
  23.   while true do
  24.     local event,name=os.pullEvent("player_logout")
  25.     players[name]=nil
  26.   end
  27. end
  28.  
  29. t=30
  30. function craftnet()
  31.   while true do
  32.     name=ip.receive()
  33.     pl=p.getPlayerByName(name)
  34.     if pl then
  35.       pl.sendChat(name..', you are deathless for '..t..' seconds!')
  36.       players[name]={pl=pl,time=t}
  37.       file=io.open('health.log','a')
  38.       file:write(name..'\n')
  39.       file:close()
  40.     end
  41.   end
  42. end
  43.  
  44. parallel.waitForAll(health,check,craftnet)
RAW Paste Data