Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.32 KB | None | 0 0
  1. keys = {69}
  2.  
  3. players={}
  4. morreu={}
  5. mapas={6879570,6879586,2173893,4392183,4569940,1870360,6880640}
  6.  
  7. shopList = {
  8. {"Galinha",50,33,2},
  9. {"Flecha",120,35,3}
  10. }
  11.  
  12. game = "<J>#Wars</J>"
  13.  
  14. tempoMax = 1
  15.  
  16. start=false
  17. timestart = 10
  18.  
  19. vivos=0
  20. jogadores=0
  21.  
  22. tfm.exec.disableAutoShaman(true)
  23. tfm.exec.disableAutoScore(true)
  24. tfm.exec.disableAutoTimeLeft(true)
  25.  
  26. function eventPlayerLeft(name)
  27. jogadores=jogadores-1;
  28. end
  29.  
  30. function eventNewPlayer(name)
  31. jogadores=jogadores+1;
  32. tfm.exec.chatMessage("<CH>Ξ</CH> <CE>Bem-vindo ao #wars</CE>",name)
  33. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Para atirar pressione a tecla E</J>",name)
  34. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Jogo desenvolvido por: <V>Contistente</V></J>",name)
  35. players[name] = {
  36. tempo = 0,
  37. moedas = 0,
  38. objeto = 34,
  39. balas = 30,
  40. maxBalas = 30,
  41. tmpBala = 0,
  42. recarga = 0,
  43. inventory={}
  44. }
  45.  
  46. morreu[name] = true
  47.  
  48. ui.addTextArea(1,"<J><p align='center'>"..players[name].moedas.."</p></J>",name,5,20,nil,20,nil,0x6a8495,70,true)
  49. ui.addTextArea(2,"<p align='center'><J><a href='event:loja'>Loja</a></J></p>",name,5,350,nil,20,nil,0x6a8495,70,true)
  50. ui.addTextArea(5,"<p align='center'><J><a href='event:inventory'>Inventário</a></J></p>",name,5,380,nil,20,nil,0x6a8495,70,true)
  51.  
  52. table.insert(players[name].inventory,{"Bola de Neve",34,1})
  53. for i,v in pairs(keys) do
  54. tfm.exec.bindKeyboard(name,v,true)
  55. end
  56. end
  57.  
  58. for all in pairs(tfm.get.room.playerList) do
  59. eventNewPlayer(all)
  60. end
  61.  
  62. function eventLoop(time)
  63. if jogadores >= 2 then
  64. for i in pairs(tfm.get.room.playerList) do
  65. if players[i].tmpBala > 0 then
  66. players[i].tmpBala = players[i].tmpBala-1;
  67. ui.addTextArea(7,"",i,750,370,40,20,0x1E90FF,0xFFF00C,70,true)
  68. if math.floor(players[i].tmpBala*2) < 5 then
  69. ui.addTextArea(8,"",i,750,370,40,20,0x40E0D0,0xFFF00C,70,true)
  70. else
  71. ui.addTextArea(8,"",i,750,370,math.floor(players[i].tmpBala*2),20,0x00BFFF,0xFFF00C,70,true)
  72. end
  73. elseif players[i].tmpBala == 0 and players[i].balas == 0 then
  74. ui.removeTextArea(7,i)
  75. ui.removeTextArea(8,i)
  76. players[i].balas = players[i].maxBalas
  77. players[i].recarga = 0
  78. end
  79. ui.addTextArea(1,"<J><p align='center'>"..players[i].moedas.."</p></J>",i,5,20,nil,20,nil,0x6a8495,70,true)
  80. if players[i].balas < 10 then
  81. ui.addTextArea(6,"<J><p align='center'><V>0"..players[i].balas.."</V><N>/</N>"..players[i].maxBalas.."</p></J>",i,730,30,nil,20,nil,0x6a8495,70,true)
  82. else
  83. ui.addTextArea(6,"<J><p align='center'><V>"..players[i].balas.."</V><N>/</N>"..players[i].maxBalas.."</p></J>",i,730,30,nil,20,nil,0x6a8495,70,true)
  84. end
  85. tfm.exec.setPlayerScore(i,players[i].moedas,false)
  86. if vivos == 1 then
  87. if not morreu[i] then
  88. newcoin = math.random(10,30)
  89. players[i].moedas = players[i].moedas+newcoin
  90. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <BL>é o vencedor!.</BL>")
  91. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <J>recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>")
  92. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Você recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>", i)
  93. tfm.exec.newGame(mapas[math.random(#mapas)])
  94. end
  95. end
  96. end
  97. if not start and time >= 2000 then
  98. tfm.exec.setUIMapName("<J>Iniciando guerra em <V>"..timestart.."</V> segundos.</J>")
  99. if timestart > 0 then
  100. timestart = timestart-1;
  101. else
  102. start=true
  103. end
  104. else
  105. tfm.exec.setUIMapName(game)
  106. end
  107. for i in pairs(tfm.get.room.playerList) do
  108. if players[i].tempo > 0 then
  109. players[i].tempo = players[i].tempo-1;
  110. end
  111. end
  112. end
  113. end
  114.  
  115. function eventKeyboard(name, key, down, x, y)
  116. if (key==69) and players[name].tempo == 0 and start and not tfm.get.room.playerList[name].isDead and players[name].balas > 0 then
  117. if tfm.get.room.playerList[name].isFacingRight then
  118. id=tfm.exec.addShamanObject(players[name].objeto,x+14,y-10,0,70,0)
  119. else
  120. id=tfm.exec.addShamanObject(players[name].objeto,x-14,y-10,0,-70,0)
  121. end
  122. for i,v in pairs(players[name].inventory) do
  123. players[name].tempo = v[3]
  124. players[name].balas = players[name].balas-1;
  125. end
  126. end
  127. if (key==69) and players[name].balas == 0 and players[name].recarga == 0 then
  128. players[name].tmpBala = 20
  129. players[name].recarga = 1
  130. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Suas munições acabaram.</J>",name)
  131. tfm.exec.chatMessage("<CH>Ξ</CH> <J>As munições do(a) <V>"..name.."</V> acabaram.</J>")
  132. end
  133. end
  134.  
  135. function eventPlayerDied(name)
  136. morreu[name] = true
  137. vivos=vivos-1;
  138. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..name.."</V><BL> morreu.</BL>")
  139. end
  140.  
  141. function eventNewGame()
  142. tfm.exec.setGameTime(300)
  143. tfm.exec.setUIMapName(game)
  144. tfm.exec.newGame(mapas[math.random(#mapas)])
  145. start=false
  146. timestart = 10
  147. vivos=0
  148. for i in pairs(tfm.get.room.playerList) do
  149. vivos=vivos+1;
  150. morreu[i] = false
  151. end
  152. end
  153.  
  154. function eventTextAreaCallback(id, player, link)
  155. if link == "loja" then
  156. texto = '<B><p align="center"><font size="18"><J>Loja</J></font><br>[<V>Nome</V>][<J>Preço</J>][<ROSE>Botão</ROSE>]<br>'
  157. for i,v in pairs(shopList) do
  158. texto = texto..'<br>[<V>'..v[1]..'</V>][<J>'..v[2]..'</J>][<ROSE><a href="event:buy-'..v[1]..'">COMPRAR</a></ROSE>]'
  159. end
  160. ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
  161. ui.addTextArea(4,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
  162. elseif link == "fechar-loja" then
  163. ui.removeTextArea(3,player)
  164. ui.removeTextArea(4,player)
  165. elseif link == "inventory" then
  166. texto = '<B><p align="center"><font size="18"><J>Inventário</J></font><br>[<V>Nome</V>][<CE>Tempo de Tiro</CE>][<ROSE>Botão</ROSE>]<br>'
  167. for i,v in pairs(players[player].inventory) do
  168. if v[2] == players[player].objeto then
  169. texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<J>Equipado</J>]'
  170. else
  171. texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<ROSE><a href="event:equip-'..v[1]..'">Equipar</a></ROSE>]'
  172. end
  173. end
  174. ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
  175. ui.addTextArea(4,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
  176. end
  177.  
  178. for i,v in pairs(shopList) do
  179. if link == "buy-"..v[1] then
  180. if players[player].moedas >= v[2] then
  181. ui.addTextArea(3,"<J><B><p align='center'>Você comprou um(a) "..v[1].." com sucesso por <ROSE>-"..v[2].."</ROSE> moedas</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
  182. ui.addTextArea(4,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
  183. players[player].moedas = players[player].moedas-v[2]
  184. table.insert(players[player].inventory, {v[1],v[3],v[4]})
  185. else
  186. ui.addTextArea(3,"<J><B><p align='center'>Você não tem moedas suficientes.</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
  187. ui.addTextArea(4,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
  188. end
  189. end
  190. end
  191.  
  192. for i,v in pairs(players[player].inventory) do
  193. if link == "equip-"..v[1] then
  194. players[player].objeto = v[2]
  195. ui.addTextArea(3,"<J><B><p align='center'>Você equipou a(o) "..v[1].." para atirar.</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
  196. ui.addTextArea(4,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
  197. end
  198. end
  199. end
  200.  
  201. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement