Advertisement
Dudugz-Contistente

[TFM][Lua][Contistente] Warshot 2.0

Dec 6th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. p={}
  2.  
  3. indx=0
  4.  
  5. projects={}
  6.  
  7. mapas = {6879570,6879586,2173893,4392183,4569940,1870360,6880640,6882237,6882094, 1953765, 1825269, 1601580, 2186266}
  8.  
  9. time = os.time();
  10.  
  11. tfm.exec.disableAutoShaman(true)
  12. tfm.exec.disableAutoNewGame(true)
  13.  
  14. function split(t,s)
  15. local a={}
  16. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  17. table.insert(a,i)
  18. end
  19. return a
  20. end
  21.  
  22.  
  23. function eventNewGame()
  24. passar = os.time();
  25.  
  26. vivos = 0
  27.  
  28. tfm.exec.setGameTime(300)
  29.  
  30. for i in pairs(tfm.get.room.playerList) do
  31. p[i].life = 100
  32. ui.addTextArea(0,"",i,5,25,202,40,0x828282,0x828282,70,true)
  33. ui.addTextArea(1,"",i,6,30,math.floor(p[i].life*2),16,0x00EE00,0x00CD00,70,true)
  34. ui.addTextArea(2,"<p align='center'><R>"..p[i].life.."/100",i,6,30,200,16,0,0,0,true)
  35. tfm.exec.setPlayerScore(i,p[i].life,false)
  36. vivos = vivos+1;
  37. end
  38.  
  39. projects={}
  40.  
  41. end
  42.  
  43. function eventNewPlayer(name)
  44. p[name]={
  45. life = 100,
  46. tempo = os.time(),
  47. }
  48.  
  49. tfm.exec.bindKeyboard(name,32,true)
  50.  
  51. tfm.exec.setPlayerScore(name,p[name].life,false)
  52. ui.addTextArea(0,"",name,6,30,200,16,0x00CD00,0x00CD00,90,true)
  53. ui.addTextArea(1,"",name,6,30,math.floor(p[name].life*2),16,0x00EE00,0x00CD00,70,true)
  54. ui.addTextArea(2,"<p align='center'><R>"..p[name].life.."/100",name,6,30,200,16,0,0,0,true)
  55.  
  56. tfm.exec.chatMessage("• <V>[GAME]</V> <CE>Bem-vindo ao The infected mouse.</CE>",name)
  57. tfm.exec.chatMessage("• <V>[GAME]</V> <VP>Este minigame está em versão de tests.</VP>",name)
  58. end
  59.  
  60. for all in pairs(tfm.get.room.playerList) do
  61. eventNewPlayer(all)
  62. end
  63.  
  64. function eventChatMessage(name,message)
  65. local arg = split(message, " ")
  66.  
  67. end
  68.  
  69. function eventKeyboard(name, key, down, x, y)
  70. if key == 32 and p[name].tempo < os.time()-1000 then
  71. if tfm.get.room.playerList[name].isFacingRight then
  72. l = 25;
  73. else
  74. l = -25;
  75. end
  76.  
  77. table.insert(projects,{n=name,d=l,px=x,py=y,c=13,tmp=os.time()})
  78.  
  79. p[name].tempo = os.time();
  80. end
  81. end
  82.  
  83. function eventLoop(t,r)
  84. if t >= 3000 then
  85. updateProjectile()
  86. end
  87.  
  88. for i,v in ipairs(projects) do
  89. if v.tmp < os.time()-800 then
  90. table.remove(projects,i)
  91. end
  92. end
  93.  
  94. if t >= 3000 and time < os.time()-3800 then
  95. regen();
  96. end
  97. end
  98.  
  99. function eventPlayerDied(name)
  100. p[name].life = 0
  101. ui.addTextArea(1,"",name,6,30,math.floor(p[name].life*2),16,0,0,0,true)
  102. ui.addTextArea(2,"<p align='center'><font color='#EE2C2C'><font size='18'>Você Morreu",name,6,25,200,nil,0,0,0,true)
  103. tfm.exec.setPlayerScore(name,p[name].life,false)
  104. p[name].life = 1
  105. vivos = vivos-1;
  106.  
  107. if vivos == 1 then
  108. for i in pairs(tfm.get.room.playerList) do
  109. if not tfm.get.room.playerList[i].isDead then
  110. tfm.exec.giveCheese(i)
  111. tfm.exec.playerVictory(i)
  112. tfm.exec.newGame(mapas[math.random(#mapas)])
  113. end
  114. end
  115. end
  116. end
  117.  
  118. function regen()
  119. for n in pairs(tfm.get.room.playerList) do
  120. if p[n].life < 100 and p[n].life > 0 and not tfm.get.room.playerList[n].isDead then
  121. p[n].life = p[n].life+math.random(0,8)
  122.  
  123. if p[n].life > 100 then
  124. p[n].life = 100
  125. end
  126.  
  127. ui.addTextArea(1,"",n,6,30,math.floor(p[n].life*2),16,0x00EE00,0x00CD00,70,true)
  128. ui.addTextArea(2,"<p align='center'><R>"..p[n].life.."/100",n,6,30,200,16,0,0,0,true)
  129. tfm.exec.setPlayerScore(n,p[n].life,false)
  130. end
  131. end
  132.  
  133. time=os.time();
  134. end
  135.  
  136. function updateProjectile()
  137. ids = {}
  138. for i,v in pairs(projects) do
  139. for id=1,2 do
  140. v.px = v.px+v.d
  141. end
  142.  
  143. for i=1,15 do
  144. if v.d == 25 then
  145. tfm.exec.displayParticle(v.c, v.px-i, v.py,math.floor(v.d/3))
  146. else
  147. tfm.exec.displayParticle(v.c, v.px+i, v.py,math.floor(v.d/3))
  148. end
  149. end
  150.  
  151.  
  152.  
  153. for n,player in pairs(tfm.get.room.playerList) do
  154. if n ~= v.n and v.px >= player.x - 40 and v.px <= player.x + 40 and v.py >= player.y - 35 and v.py <= player.y + 35 and not tfm.get.room.playerList[n].isDead then
  155. p[n].life = p[n].life-3;
  156. tfm.exec.movePlayer(n, 0, 0, false, v.d, 0, true)
  157.  
  158. table.insert(ids,i)
  159.  
  160. if p[n].life < 1 then
  161. tfm.exec.killPlayer(n)
  162. end
  163.  
  164. ui.addTextArea(1,"",n,6,30,math.floor(p[n].life*2),16,0x00EE00,0x00CD00,70,true)
  165. ui.addTextArea(2,"<p align='center'><R>"..p[n].life.."/100",n,6,30,200,16,0,0,0,true)
  166. tfm.exec.setPlayerScore(n,p[n].life,false)
  167. end
  168. end
  169. end
  170.  
  171. for index in pairs(ids) do
  172. table.remove(projects,index)
  173. end
  174. end
  175.  
  176. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement