Eshka

Untitled

Jan 3rd, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.96 KB | None | 0 0
  1. tfm.exec.disableAutoShaman(true)
  2. tfm.exec.disableAutoNewGame(true)
  3.  
  4. -- table and locals --
  5. data ={""}
  6. maps = {1}
  7. warCount = 0
  8. count = 0
  9. catchSoul = false
  10.  
  11. local cm = tfm.get.room.community
  12.  
  13. --Messages--
  14. welcomeMessage = {["EN"]="welcome to war! if is your first time here type !help to more info!";["BR"]="bem-vindo á war se é sua primeira vez aqui digite !help para mais informações!"}
  15. helpMessage = {["EN"]="war is a minigame where your goal is win the war. Each war have 20(twenty) rounds/maps, when a new war starts all players have 0(zero) coins, you can win coins by getting one of the three positions in the race for the cheese, you can type <B>!buy help</B> to open the shop. Good luck!";["BR"]="war é um minigame onde seu objetivo é ganhar a guerra. Cada guerra tem 20(vinte) rodadas/mapas, quando uma nova guerra inicia todos os jogadores têm coins 0(zero), você pode ganhar coins, obtendo uma das três posições na corrida para o queijo, você pode digitar <B>!buy help</B> para abrir a loja. Boa sorte!"}
  16. newWarMessage = {["EN"]="A new war is starting! Prepare for the fight.";["BR"]="Uma nova guerra está começando! Preparem-se para a luta."}
  17. getSoulMessage = {["EN"]="Is time to get coins! get the cheese for teen coins.";["BR"]="é hora de coletar coins! pegue o queijo para 10 coins."}
  18. getCheeseMessage ={["EN"]="Good! you get 10 coins!";["BR"]="Otimo! Você conseguiu 10 coins!"}
  19. getFirstMessage = {["EN"]=" get cheese in first! (s)he won 15 coins!";["BR"]=" conseguiu chegar em primeiro! Ele(a) recebeu 15 coins."}
  20. getSecondessage = {["EN"]=" get cheese in second! (s)he won 10 coins!";["BR"]=" conseguiu chegar em segundo! Ele(a) recebeu 10 coins."}
  21. getThirdMessage = {["EN"]=" get cheese in thrid! (s)he won 5 coins!";["BR"]=" conseguiu chegar em terceiro! Ele(a) recebeu 5 coins."}
  22. buyHelpMessage = {["EN"]="Avaliable commands:<BR>!shop coins - to see your coins.<BR>!shop powers - to see avaliable powers to buy.<BR>More cooming soon.";["BR"]="Comandos atuais:<BR>!buy coins - veja seus coins.<BR>!buy powers - para ver uma lista de poderes que podem ser comprados.<BR>Mais em breve."}
  23. coinsAmountMessage = {["EN"]="Actually, you have ",["BR"]="Atualmente você têm "}
  24. buyPowersMessage = {["EN"] ="Avaliable powers to buy: <BR>!power respawn - 20 coins - if you die, you can respawn, use one time. <BR>!power jump - 30 coins - you can press Z to have a jump boost, you can use two times. <BR>!power speed - 50 coins - you can press X to have a speed boost, you can use three times.";["BR"]="Poderes disponiveis:<BR>!power respawn - 20 coins - Se você morrer, você pode respawnar, usos : 1 vez. <BR>!power jump - 30 coins - te dá um impulso adicional, usos : 2 vezes.<BR>!power speed - 50 coins - te dá uma velocidade maior, usos : 3 vezes"}
  25. endOfWarMessage = {["EN"] ="The war ended, all coins/powers have been reset.";["BR"]="A guerra acabou, todas as moedas/poderes foram resetados."}
  26. buyRespawnPower = {["EN"]="You buyed one respawn power!";["BR"]="Você comprou um poder de respawn"}
  27. buyJumpPower = {["EN"]="You buyed two jump powers!";["BR"]="Você comprou dois poderes de pulo"}
  28. buySpeedPower = {["EN"]="You buyed three speed powers!";["BR"]="Você comprou três poderes de velocidade"}
  29. cantBuyPower = {["EN"]="You don't have enough coins to buy it.";["BR"]="Você não têm coins para comprar isto"}
  30.  
  31.  
  32.  
  33. function newPlayerData(playerName)
  34. tfm.exec.bindKeyboard(playerName, 90, true, true)
  35. tfm.exec.bindKeyboard(playerName, 88, true, true)
  36. newData = {["banned"]=false;
  37. ["coins"]=0;
  38. ["respawns"]=0;
  39. ["jumps"]=0;
  40. ["speeds"]=0;}
  41. data[playerName] = newData
  42. end
  43.  
  44. function message(sender,reciever,msg)
  45. print(string.format("<V>[%s]<N> <I>%s</I>",sender,msg),reciever)
  46. end
  47.  
  48. function eventNewPlayer(playerName)
  49. if (cm =="BR") then
  50. message("Soldado",playerName,welcomeMessage.BR)
  51. else
  52. message("Soldier",playerName,welcomeMessage.EN)
  53. end
  54. newPlayerData(playerName)
  55. end
  56.  
  57.  
  58. function eventChatCommand(playerName, command)
  59. if (command=="help") then
  60. if (cm=="BR") then
  61. message("Inventor",playerName,helpMessage.BR)
  62. else
  63. message("Inventor",playerName,helpMessage.EN)
  64. end
  65. end
  66.  
  67. if (command:sub(0,4)=="shop") then
  68. if (command:sub(6,10)=="help") then
  69. if (cm=="BR") then
  70. message("Vendedor",playerName,buyHelpMessage.BR)
  71. else
  72. message("Seller",playerName,buyHelpMessage.EN)
  73. end
  74. end
  75.  
  76. if (command:sub(6,11)=="coins") then
  77. if (cm=="BR") then
  78. message("Vendedor",playerName,coinsAmountMessage.BR..data[playerName].coins.." coins.")
  79. else
  80. message("Seller",playerName,coinsAmountMessage.EN..data[playerName].coins.." coins.")
  81. end
  82. end
  83.  
  84. if (command:sub(6,12)=="powers") then
  85. if (cm=="BR") then
  86. message("Vendedor",playerName,buyPowersMessage.BR)
  87. else
  88. message("Seller",playerName,buyPowersMessage.EN)
  89. end
  90. end
  91. end
  92. if (command:sub(0,5)=="power") then
  93. if (command:sub(7,14)=="respawn") then
  94. if data[playerName].coins > 20 then
  95. data[playerName].coins = data[playerName].coins -20
  96. data[playerName].respawns = data[playerName].respawns +1
  97. if (cm=="BR") then
  98. message("Vendedor",playerName,buyRespawnPower.BR)
  99. else
  100. message("Seller",playerName,buyRespawnPower.EN)
  101. end
  102. else
  103. if (cm=="BR") then
  104. message("Vendedor",playerName,cantBuyPower.BR)
  105. else
  106. message("Seller",playerName,cantBuyPower.EN)
  107. end
  108. end
  109. end
  110. if (command:sub(7,11)=="jump") then
  111. if data[playerName].coins > 30 then
  112. data[playerName].coins = data[playerName].coins -30
  113. data[playerName].jump = data[playerName].jumps +2
  114. if (cm=="BR") then
  115. message("Vendedor",playerName,buyJumpPower.BR)
  116. else
  117. message("Seller",playerName,buyJumpPower.EN)
  118. end
  119. else
  120. if (cm=="BR") then
  121. message("Vendedor",playerName,cantBuyPower.BR)
  122. else
  123. message("Seller",playerName,cantBuyPower.EN)
  124. end
  125. end
  126. end
  127. if (command:sub(7,12)=="speed") then
  128. if data[playerName].coins > 50 then
  129. data[playerName].coins = data[playerName].coins -50
  130. data[playerName].speeds = data[playerName].speeds +3
  131. if (cm=="BR") then
  132. message("Vendedor",playerName,buySpeedPower.BR)
  133. else
  134. message("Seller",playerName,buySpeedPower.EN)
  135. end
  136. else
  137. if (cm=="BR") then
  138. message("Vendedor",playerName,cantBuyPower.BR)
  139. else
  140. message("Seller",playerName,cantBuyPower.EN)
  141. end
  142. end
  143. end
  144. end
  145. end
  146.  
  147.  
  148.  
  149. function eventNewGame()
  150. count = 0
  151. warCount = warCount+1
  152. if warCount == 10 then
  153. catchSoul = true
  154. if (cm=="BR") then
  155. message("General",nil,getSoulMessage.BR)
  156. else
  157. message("General",nil,getSoulMessage.EN)
  158. end
  159. end
  160. if warCount == 11 then
  161. catchSoul = false
  162. end
  163. if warCount == 21 then
  164. warCount = 0
  165. if (cm=="BR") then
  166. message("General",nil,endOfWarMessage.BR)
  167. else
  168. message("General",nil,endOfWarMessage.EN)
  169. end
  170. end
  171. end
  172.  
  173. function eventPlayerWon(playerName)
  174. if (catchSoul == true) then
  175. if (cm=="BR") then
  176. message("General",nil,getCheeseMessage.BR)
  177. else
  178. message("General",nil,getCheeseMessage.EN)
  179. end
  180. data[playerName].coins = data[playerName].coins+10
  181. endé iss
  182. if (catchSoul == false) then
  183. count = count+1
  184. if (count == 1) then
  185. data[playerName].coins = data[playerName].coins+15
  186. if (cm=="BR") then
  187. message("Banker",nil,playerName..getFirstMessage.BR)
  188. else
  189. message("Banker",nil,playerName..getFirstMessage.EN)
  190. end
  191. end
  192. if (count == 2) then
  193. data[playerName].coins = data[playerName].coins+10
  194. if (cm=="BR") then
  195. message("Banker",nil,playerName..getSecondMessage.BR)
  196. else
  197. message("Banker",nil,playerName..getSecondessage.EN)
  198. end
  199. end
  200. if (count == 3) then
  201. data[playerName].coins = data[playerName].coins+5
  202. if (cm=="BR") then
  203. message("Banker",nil,playerName..getThirdMessage.BR)
  204. else
  205. message("Banker",nil,playerName..getThirdMessage.EN)
  206. end
  207. end
  208. end
  209. end
  210.  
  211. function eventLoop(time,remaining)
  212. if (cm=="BR") then
  213. tfm.exec.setUIMapName(string.format("<N>Rodada: <V>%s/20",warCount))
  214. else
  215. tfm.exec.setUIMapName(string.format("<N>Round: <V>%s/20",warCount))
  216. end
  217.  
  218. if remaining<=0 then
  219. tfm.exec.newGame(maps[math.random(#maps)])
  220. end
  221. for playerName,name in pairs(tfm.get.room.playerList) do
  222. ui.addTextArea(0, string.format("<B> Info</B><BR><BR>Coins : %s<BR>Respawns: %s<BR>Jumps : %s<BR>Speeds : %s",data[playerName].coins,data[playerName].respawns,data[playerName].jumps,data[playerName].speeds), playerName, 714, 120, 80, 150, 1, 16777215, 0.5, true);
  223. end
  224. end
  225.  
  226.  
  227. function eventPlayerDied(playerName)
  228. local i=0
  229. for n,player in pairs(tfm.get.room.playerList) do
  230. if not player.isDead then
  231. i=i+1
  232. end
  233. end
  234. if i==0 then
  235. tfm.exec.newGame(maps[math.random(#maps)])
  236. end
  237. if (data[playerName].respawns > 0) then
  238. tfm.exec.respawnPlayer(playerName)
  239. data[playerName].respawns = data[playerName].respawns -1
  240. end
  241. end
  242.  
  243. tfm.exec.newGame(maps[math.random(#maps)])
  244.  
  245. for player,name in pairs(tfm.get.room.playerList) do
  246. newPlayerData(player)
  247. end
Advertisement
Add Comment
Please, Sign In to add comment