Advertisement
Dudugz-Contistente

Untitled

Dec 6th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. p={}
  2.  
  3. mapas = {0}
  4.  
  5. time = os.time();
  6.  
  7. tfm.exec.disableAutoShaman(true)
  8. tfm.exec.disableAutoNewGame(true)
  9.  
  10. function split(t,s)
  11. local a={}
  12. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  13. table.insert(a,i)
  14. end
  15. return a
  16. end
  17.  
  18.  
  19. function eventNewGame()
  20. passar = os.time();
  21.  
  22. vivos = 0
  23.  
  24. tfm.exec.setGameTime(9999)
  25.  
  26. for i in pairs(tfm.get.room.playerList) do
  27. p[i].life = 100
  28. ui.addTextArea(1,"",i,6,30,math.floor(p[i].life*2),16,0x00EE00,0x00CD00,70,true)
  29. ui.addTextArea(2,"<p align='center'><R>"..p[i].life.."/100",i,6,30,200,16,0,0,0,true)
  30. tfm.exec.setPlayerScore(i,p[i].life,false)
  31. vivos = vivos+1;
  32. end
  33.  
  34. end
  35.  
  36. function eventNewPlayer(name)
  37. p[name]={
  38. life = 100,
  39. tempo = os.time(),
  40. }
  41.  
  42. tfm.exec.bindKeyboard(name,32,true)
  43.  
  44. tfm.exec.setPlayerScore(name,p[name].life,false)
  45. ui.addTextArea(0,"",name,6,30,200,16,0x00CD00,0x00CD00,90,true)
  46. ui.addTextArea(1,"",name,6,30,math.floor(p[name].life*2),16,0x00EE00,0x00CD00,70,true)
  47. ui.addTextArea(2,"<p align='center'><R>"..p[name].life.."/100",name,6,30,200,16,0,0,0,true)
  48.  
  49. end
  50.  
  51. for all in pairs(tfm.get.room.playerList) do
  52. eventNewPlayer(all)
  53. end
  54.  
  55. function eventKeyboard(name, key, down, x, y)
  56. if key == 32 and p[name].tempo < os.time()-800 then
  57. for n,player in pairs(tfm.get.room.playerList) do
  58. if n ~= name and x >= player.x - 25 and x <= player.x + 25 and y >= player.y - 25 and y <= player.y + 25 and not tfm.get.room.playerList[n].isDead then
  59. p[n].life=p[n].life-3;
  60. p[name].tempo = os.time();
  61. ui.addTextArea(1,"",n,6,30,math.floor(p[n].life*2),16,0x00EE00,0x00CD00,70,true)
  62. ui.addTextArea(2,"<p align='center'><R>"..p[n].life.."/100",n,6,30,200,16,0,0,0,true)
  63. tfm.exec.setPlayerScore(n,p[n].life,false)
  64. end
  65. end
  66. end
  67. end
  68.  
  69. function eventLoop(t,r)
  70. if t >= 1000 and time < os.time()-10000 then
  71. regen();
  72. end
  73. end
  74.  
  75. function eventPlayerDied(name)
  76. p[name].life = 0
  77. ui.addTextArea(1,"",name,6,30,math.floor(p[name].life*2),16,0,0,0,true)
  78. ui.addTextArea(2,"<p align='center'><font color='#EE2C2C'><font size='18'>You are dead ☠",name,6,25,200,nil,0,0,0,true)
  79. tfm.exec.setPlayerScore(name,p[name].life,false)
  80. p[name].life = 1
  81. vivos = vivos-1;
  82.  
  83. if vivos == 1 then
  84. for i in pairs(tfm.get.room.playerList) do
  85. if not tfm.get.room.playerList[i].isDead then
  86. tfm.exec.giveCheese(i)
  87. tfm.exec.playerVictory(i)
  88. tfm.exec.newGame(mapas[math.random(#mapas)])
  89. end
  90. end
  91. end
  92. end
  93.  
  94. function regen()
  95. for n in pairs(tfm.get.room.playerList) do
  96. if p[n].life < 100 and p[n].life > 0 and not tfm.get.room.playerList[n].isDead then
  97. p[n].life = p[n].life+math.random(0,8)
  98.  
  99. if p[n].life > 100 then
  100. p[n].life = 100
  101. end
  102.  
  103. ui.addTextArea(1,"",n,6,30,math.floor(p[n].life*2),16,0x00EE00,0x00CD00,70,true)
  104. ui.addTextArea(2,"<p align='center'><R>"..p[n].life.."/100",n,6,30,200,16,0,0,0,true)
  105. tfm.exec.setPlayerScore(n,p[n].life,false)
  106. end
  107. end
  108.  
  109. time=os.time();
  110. end
  111.  
  112.  
  113. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement