Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 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. tfm.exec.lowerSyncDelay(name)
  48.  
  49. ui.addTextArea(1,"<J><p align='center'>"..players[name].moedas.."</p></J>",name,5,20,nil,20,nil,0x6a8495,70,true)
  50. ui.addTextArea(2,"<p align='center'><J><a href='event:loja'>Loja</a></J></p>",name,5,350,nil,20,nil,0x6a8495,70,true)
  51. 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)
  52.  
  53. table.insert(players[name].inventory,{"Bola de Neve",34,1})
  54. for i,v in pairs(keys) do
  55. tfm.exec.bindKeyboard(name,v,true)
  56. end
  57. end
  58.  
  59. for all in pairs(tfm.get.room.playerList) do
  60. eventNewPlayer(all)
  61. end
  62.  
  63. function eventLoop(time)
  64. if jogadores >= 2 then
  65. for i in pairs(tfm.get.room.playerList) do
  66. if players[i].tmpBala > 0 then
  67. players[i].tmpBala = players[i].tmpBala-1;
  68. ui.addTextArea(7,"",i,750,370,40,20,0x1E90FF,0xFFF00C,70,true)
  69. if math.floor(players[i].tmpBala*2) < 5 then
  70. ui.addTextArea(8,"",i,750,370,40,20,0x40E0D0,0xFFF00C,70,true)
  71. else
  72. ui.addTextArea(8,"",i,750,370,math.floor(players[i].tmpBala*2),20,0x00BFFF,0xFFF00C,70,true)
  73. end
  74. elseif players[i].tmpBala == 0 and players[i].balas == 0 then
  75. ui.removeTextArea(7,i)
  76. ui.removeTextArea(8,i)
  77. players[i].balas = players[i].maxBalas
  78. players[i].recarga = 0
  79. end
  80. ui.addTextArea(1,"<J><p align='center'>"..players[i].moedas.."</p></J>",i,5,20,nil,20,nil,0x6a8495,70,true)
  81. if players[i].balas < 10 then
  82. 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)
  83. else
  84. 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)
  85. end
  86. tfm.exec.setPlayerScore(i,players[i].moedas,false)
  87. if vivos == 1 then
  88. if not morreu[i] then
  89. newcoin = math.random(10,30)
  90. players[i].moedas = players[i].moedas+newcoin
  91. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <BL>é o vencedor!.</BL>")
  92. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <J>recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>")
  93. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Você recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>", i)
  94. tfm.exec.newGame(mapas[math.random(#mapas)])
  95. end
  96. end
  97. end
  98. if not start and time >= 2000 then
  99. tfm.exec.setUIMapName("<J>Iniciando guerra em <V>"..timestart.."</V> segundos.</J>")
  100. if timestart > 0 then
  101. timestart = timestart-1;
  102. else
  103. start=true
  104. end
  105. else
  106. tfm.exec.setUIMapName(game)
  107. end
  108. for i in pairs(tfm.get.room.playerList) do
  109. if players[i].tempo > 0 then
  110. players[i].tempo = players[i].tempo-1;
  111. end
  112. end
  113. end
  114. end
  115.  
  116. function eventKeyboard(name, key, down, x, y)
  117. if (key==69) and players[name].tempo == 0 and start and not tfm.get.room.playerList[name].isDead and players[name].balas > 0 then
  118. if tfm.get.room.playerList[name].isFacingRight then
  119. id=tfm.exec.addShamanObject(players[name].objeto,x+14,y-10,0,70,0)
  120. else
  121. id=tfm.exec.addShamanObject(players[name].objeto,x-14,y-10,0,-70,0)
  122. end
  123. for i,v in pairs(players[name].inventory) do
  124. players[name].tempo = v[3]
  125. players[name].balas = players[name].balas-1;
  126. end
  127. end
  128. if (key==69) and players[name].balas == 0 and players[name].recarga == 0 then
  129. players[name].tmpBala = 20
  130. players[name].recarga = 1
  131. tfm.exec.chatMessage("<CH>Ξ</CH> <J>Suas munições acabaram.</J>",name)
  132. tfm.exec.chatMessage("<CH>Ξ</CH> <J>As munições do(a) <V>"..name.."</V> acabaram.</J>")
  133. end
  134. end
  135.  
  136. function eventPlayerDied(name)
  137. morreu[name] = true
  138. vivos=vivos-1;
  139. tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..name.."</V><BL> morreu.</BL>")
  140. end
  141.  
  142. function eventNewGame()
  143. tfm.exec.setGameTime(300)
  144. tfm.exec.setUIMapName(game)
  145. tfm.exec.newGame(mapas[math.random(#mapas)])
  146. start=false
  147. timestart = 10
  148. vivos=0
  149. for i in pairs(tfm.get.room.playerList) do
  150. vivos=vivos+1;
  151. morreu[i] = false
  152. end
  153. end
  154.  
  155. function eventTextAreaCallback(id, player, link)
  156. if link == "loja" then
  157. 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>'
  158. for i,v in pairs(shopList) do
  159. texto = texto..'<br>[<V>'..v[1]..'</V>][<J>'..v[2]..'</J>][<ROSE><a href="event:buy-'..v[1]..'">COMPRAR</a></ROSE>]'
  160. end
  161. ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
  162. 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)
  163. elseif link == "fechar-loja" then
  164. ui.removeTextArea(3,player)
  165. ui.removeTextArea(4,player)
  166. elseif link == "inventory" then
  167. 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>'
  168. for i,v in pairs(players[player].inventory) do
  169. if v[2] == players[player].objeto then
  170. texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<J>Equipado</J>]'
  171. else
  172. texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<ROSE><a href="event:equip-'..v[1]..'">Equipar</a></ROSE>]'
  173. end
  174. end
  175. ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
  176. 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)
  177. end
  178.  
  179. for i,v in pairs(shopList) do
  180. if link == "buy-"..v[1] then
  181. if players[player].moedas >= v[2] then
  182. 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)
  183. 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)
  184. players[player].moedas = players[player].moedas-v[2]
  185. table.insert(players[player].inventory, {v[1],v[3],v[4]})
  186. else
  187. 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)
  188. 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)
  189. end
  190. end
  191. end
  192.  
  193. for i,v in pairs(players[player].inventory) do
  194. if link == "equip-"..v[1] then
  195. players[player].objeto = v[2]
  196. 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)
  197. 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)
  198. end
  199. end
  200. end
  201.  
  202. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement