Advertisement
Dudugz-Contistente

Untitled

Nov 21st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.58 KB | None | 0 0
  1.  
  2. mapas = {6940835,6940872,6939230,6939743,6932947,6931137,6933370,6933386,6933388,6939573,6939693,6939230,6939580,6939558,6939573,6939583,6939322}
  3. p = {}
  4.  
  5. admin = "Contistente"
  6.  
  7. click = false
  8.  
  9. jogadores = 0
  10.  
  11. tfm.exec.disableAutoNewGame(true)
  12. tfm.exec.disableAutoShaman(true)
  13. tfm.exec.disableAutoTimeLeft(true)
  14. tfm.exec.disableAfkDeath(true)
  15.  
  16. translations={
  17. EN={
  18. help={
  19. "<b><p align='center'><J><font size='18'>How to play:</font></J><br>Rats can not die by the explosions that cause killer <R>by click on the screen</R>, just do not forget win the last alive and each mouse has meep.\n<V><p align='center'><J><font size='18'>Credits: </font></J><br><N><V>Rianmojang</V>,<CE>Contistente</CE> and <J>Laagaadoo</J>.",
  20. "<p align='center'><J><font size='18'>Commands: </font></J></p><br>!p - open the profile tab<br>!help - open the help tab<br>!rank - open the ranking tab<br>!shop - ...",
  21. "<p align='center'><J><font size='18'>Credits: </font></J><br><N><V>Rianmojang</V>,<CE>Contistente</CE> e <J>Laagaadoo</J>.",
  22. },
  23. profile={
  24. wins = "Wins: ",
  25. kills = "Kills: ",
  26. rounds = "Rounds: ",
  27. killers = "Killer: "
  28. },
  29.  
  30. rank={
  31. ["name"] = "Name",
  32. ["position"] = "Place",
  33. ["wins"] = "Wins"
  34. },
  35.  
  36. errors={
  37. ["invalid_name_1"] = "<BL>-</BL> <R>Error invalid user name,",
  38. ["invalid_name_2"] = " Is not in the room.</R>",
  39. ["manutention_shop"] = "The store is under maintenance."
  40. },
  41.  
  42. buttons = {
  43. ["help"] = "Ajuda",
  44. ["rank"] = "Ranking",
  45. ["shop"] = "Loja",
  46. },
  47.  
  48. },
  49.  
  50. BR={
  51. help={
  52. "<b><p align='center'><J><font size='18'>Como Jogar:</font></J><br>Os ratos não podem morrer para as explosões que o assasino causa <R>clickando na tela</R>, cada rato tem meep e o último vivo ganha.",
  53. "<p align='center'><J><font size='18'>Comandos: </font></J></p><br>!p - abre o perfil<br>!help - abre a aba de ajuda<br>!rank - abre o ranking<br>!loja - ...",
  54. "<p align='center'><J><font size='18'>Creditos: </font></J><br><N><V>Rianmojang</V>,<CE>Contistente</CE> e <J>Laagaadoo</J>.",
  55. },
  56. profile={
  57. ["wins"] = "Vitórias: ",
  58. ["kills"] = "Mortes: ",
  59. ["rounds"] = "Rodadas: ",
  60. ["killers"] = "Assassino: "
  61. },
  62.  
  63. rank={
  64. ["name"] = "Nome",
  65. ["position"] = "Lugar",
  66. ["wins"] = "Vitórias"
  67. },
  68.  
  69. errors={
  70. ["invalid_name_1"] = "<BL>-</BL> <R>Erro nome de usuário inválido,",
  71. ["invalid_name_2"] = " não está na sala.</R>",
  72. ["manutention_shop"] = "A loja está em manutenção."
  73. },
  74.  
  75. buttons = {
  76. ["help"] = "Ajuda",
  77. ["rank"] = "Ranking",
  78. ["shop"] = "Loja"
  79. },
  80. }
  81. }
  82.  
  83. players={}
  84.  
  85. local proximoAssassino = ''
  86.  
  87. textarea=ui.addTextArea
  88. function ui.addTextArea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
  89. --if not backgroundColor then backgroundColor=0x324650 end
  90. --if not borderColor then borderColor=0x000001 end
  91. if emboss then
  92. textarea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha)
  93. textarea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha)
  94. end
  95. textarea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha)
  96. end
  97.  
  98. function trans(mes)
  99. if translations[tfm.get.room.community] and translations[tfm.get.room.community][mes] then
  100. return translations[tfm.get.room.community][mes]
  101. else
  102. return translations.BR[mes]
  103. end
  104. end
  105.  
  106. function eventRank()
  107. local sc = {}
  108. for name, player in pairs(tfm.get.room.playerList) do
  109. sc[#sc+1] = {n=name,w=p[name].wins}
  110. end
  111. table.sort(sc,function(a,b) return a.w>b.w end)
  112.  
  113. y = 25
  114.  
  115. for k,v in pairs(sc) do
  116. if k < 9 then
  117. y=y+30;
  118. ui.addTextArea(9000+k,"<J>"..k.."</J> | <V>"..v.n.."</V> | <CE>"..v.w.."</CE>",name,260,y+30,280,15,nil,0x324650,nil,true)
  119. end
  120. end
  121.  
  122. end
  123.  
  124. function eventChatCommand(name,command)
  125. local arg = {}
  126.  
  127. for args in command:gmatch("[^%s]+") do
  128. table.insert(arg, args:lower())
  129. end
  130. if arg[1]=="help" then
  131. ui.addTextArea(1,"<font size='12'>"..trans("help")[players[name].helpid],name,250,50,300,300,nil,0x324650,nil,true)
  132. ui.addTextArea(2,"<p align='center'><a href='event:previous'><b>&lt;</b></a></p>",name,445,365,16,16,nil,0x324650,nil,true)
  133. ui.addTextArea(3,"<p align='center'><a href='event:next'><b>&gt;</b></a></p>",name,532,365,16,16,nil,0x324650,nil,true)
  134. ui.addTextArea(4,"<p align='center'><a href='event:close'><b>Fechar</b></a></p>",name,275,325,250,16,nil,0x324650,nil,true)
  135. ui.addTextArea(5,"<p align='center'>"..players[name].helpid.."/"..#trans("help").."</p>",name,475,365,42,16,nil,0x324650,nil,true)
  136. end
  137.  
  138. if arg[1]=="rank" then
  139. ui.addTextArea(1,"<p align='center'><J><font size='18'>Mini-Rank</font></J></p>",name,250,50,300,300,nil,0x324650,nil,true)
  140. ui.addTextArea(2,"<p align='center'><a href='event:close'><b>Fechar</b></a></p>",name,275,325,250,16,nil,0x324650,nil,true)
  141. for i,v in pairs({3,4,5}) do
  142. ui.removeTextArea(v,name)
  143. ui.removeTextArea(6969+v,name)
  144. ui.removeTextArea(7979+v,name)
  145. end
  146.  
  147. eventRank();
  148. end
  149.  
  150. if (arg[1]=="shop" or arg[1]=="loja") then
  151. tfm.exec.chatMessage('<R>'..trans("errors")["manutention_shop"],name)
  152. end
  153.  
  154. if arg[1]=="p" then
  155. if arg[2] then
  156. nome = arg[2]:sub(1,1):upper() .. arg[2]:sub(2):lower()
  157. else
  158. nome = name
  159. end
  160.  
  161. if tfm.get.room.playerList[nome] then
  162. wins = trans("profile")["wins"]
  163. kills = trans("profile")["kills"]
  164. rounds = trans("profile")["rounds"]
  165. killers = trans("profile")["killers"]
  166.  
  167. ui.addTextArea(1,"<p align='center'><b><font size='18'><J>"..nome.."</J></font><br><font size='15'><N>"..wins.."</N><V>"..p[nome].wins.."</V><br>"..kills.."</N><V>"..p[nome].kills.."</V><br>"..rounds.."</N><V>"..p[nome].rounds.."</V><br>"..killers.."</N><V>"..p[nome].killers.."</V><br>",name,250,50,300,300,nil,0x324650,nil,true)
  168. ui.addTextArea(2,"<p align='center'><a href='event:close'><b>Fechar</b></a></p>",name,275,325,250,16,nil,0x324650,nil,true)
  169. for i,v in pairs({3,4,5}) do
  170. ui.removeTextArea(v,name)
  171. ui.removeTextArea(6969+v,name)
  172. ui.removeTextArea(7979+v,name)
  173. end
  174. else
  175. tfm.exec.chatMessage(trans("errors")["invalid_name_1"]..nome..trans("errors")["invalid_name_2"],name)
  176. end
  177. end
  178. end
  179.  
  180. function eventTextAreaCallback(id,name,callback)
  181. if callback=="help" then
  182. eventChatCommand(name,callback)
  183. elseif callback=="rank" then
  184. eventChatCommand(name,callback)
  185. elseif callback=="shop" then
  186. eventChatCommand(name,callback)
  187. elseif callback=="menu" then
  188. ui.addTextArea(10,"",name,6,365,300,25,0x1c3b40,0x1c3b40,nil,true)
  189. ui.addTextArea(11,"<p align='center'><b><a href='event:menu-close'>...</a></p>",name,6,365,20,25,0x1b393d,0x1b393d,nil,true)
  190. ui.addTextArea(12,"<p align='center'><a href='event:help'><b>"..trans("buttons")["help"].."</a></p>",name,40,368,75,20,nil,0x324650,nil,true)
  191. ui.addTextArea(13,"<p align='center'><a href='event:rank'><b>"..trans("buttons")["rank"].."</a></p>",name,130,368,75,20,nil,0x324650,nil,true)
  192. ui.addTextArea(14,"<p align='center'><a href='event:shop'><b>"..trans("buttons")["shop"].."</a></p>",name,220,368,75,20,nil,0x324650,nil,true)
  193. elseif callback=="menu-close" then
  194. for id=10,14 do
  195. ui.removeTextArea(id,name)
  196. ui.removeTextArea(6969+id,name)
  197. ui.removeTextArea(7979+id,name)
  198. end
  199.  
  200. ui.addTextArea(11,"<p align='center'><a href='event:menu'><b>...</a></p>",name,6,365,20,25,nil,0x324650,nil,true)
  201. elseif callback=="close" then
  202. players[name].helpid=1
  203. for id=1,9 do
  204. ui.removeTextArea(id,name)
  205. ui.removeTextArea(9000+id,name)
  206. ui.removeTextArea(6969+9000+id,name)
  207. ui.removeTextArea(7979+9000+id,name)
  208. ui.removeTextArea(6969+id,name)
  209. ui.removeTextArea(7979+id,name)
  210. end
  211. elseif callback=="next" and players[name].helpid<#trans("help") then
  212. players[name].helpid=(players[name].helpid)+1
  213. ui.updateTextArea(1,trans("help")[players[name].helpid],name)
  214. ui.updateTextArea(5,"<p align='center'>"..players[name].helpid.."/"..#trans("help").."</p>",name)
  215. ui.addTextArea(4,"<p align='center'><a href='event:close'><b>Fechar</b></a></p>",name,275,325,250,16,nil,0x324650,nil,true)
  216. elseif callback=="previous" and players[name].helpid>1 then
  217. players[name].helpid=players[name].helpid-1
  218. ui.updateTextArea(1,trans("help")[players[name].helpid],name)
  219. ui.updateTextArea(5,"<p align='center'>"..players[name].helpid.."/"..#trans("help").."</p>",name)
  220. ui.addTextArea(4,"<p align='center'><a href='event:close'><b>Fechar</b></a></p>",name,275,325,250,16,nil,0x324650,nil,true)
  221. end
  222. end
  223.  
  224. function eventNewPlayer(name)
  225. p[name]={
  226. click = true,
  227. time_click = 0,
  228. wins = 0,
  229. kills = 0,
  230. rounds = 0,
  231. killers = 0,
  232. }
  233.  
  234. if jogadores == 2 then
  235. tfm.exec.newGame(mapas[math.random(#mapas)])
  236. end
  237.  
  238. jogadores = jogadores+1;
  239. tfm.exec.setPlayerScore(name,0,false)
  240. system.bindMouse(name,true)
  241.  
  242. players[name]={helpid=1}
  243. ui.addTextArea(6,"<p align='center'><a href='event:menu'><b>...</a></p>",name,11,365,20,25,nil,0x324650,nil,true)
  244.  
  245. if proximoAssassino ~= '' then
  246. tfm.exec.setUIMapName("<b>#explosion</b> <font color='#6a7495'>|</font> <N>Assassino: </N><V>"..proximoAssassino.."</V>")
  247. end
  248.  
  249. tfm.exec.chatMessage("<CE>"..name.." bem-vindo ao explosion.</CE><br><VP>Acesse o nosso tópico no forum: http://atelier801.com/topic?f=6&t=838331</VP>",name)
  250. end
  251.  
  252. for all in pairs(tfm.get.room.playerList) do
  253. eventNewPlayer(all)
  254. end
  255.  
  256. function eventMouse(name,x,y)
  257. if p[name].click and admin == name and jogadores >= 3 and click then
  258. tfm.exec.explosion (x, y, 20, 100, true)
  259. tfm.exec.displayParticle(12,x,y)
  260. p[name].click = false
  261. p[name].time_click = 5
  262. end
  263. end
  264.  
  265. function eventLoop(elapsed, remaining)
  266. if elapsed >= 3800 and not click then
  267. click = true
  268. end
  269.  
  270. if jogadores >= 3 then
  271. if not p[admin].click then
  272. if p[admin].time_click > 0 then
  273. ui.addTextArea(-1,math.floor(p[admin].time_click/2),nil,750,375,20,15,nil,nil,80,true)
  274. p[admin].time_click = p[admin].time_click-1;
  275. else
  276. p[admin].click = true
  277. ui.removeTextArea(-1,nil)
  278. ui.removeTextArea(6969+-1,nil)
  279. ui.removeTextArea(7979+-1,nil)
  280. end
  281. end
  282.  
  283. if remaining < 1000 then
  284. tfm.exec.newGame(mapas[math.random(#mapas)])
  285. proximoAssassino = ''
  286. end
  287. else
  288. tfm.exec.setUIMapName("<R>É necessário 3 jogadores.</R>")
  289. end
  290. end
  291.  
  292. function eventPlayerDied(name)
  293. if vivos > 2 then
  294. vivos = vivos-1;
  295. else
  296. for i in pairs(tfm.get.room.playerList) do
  297. if not tfm.get.room.playerList[i].isDead then
  298. proximoAssassino = i
  299. tfm.exec.giveCheese(i)
  300. tfm.exec.playerVictory(i)
  301. end
  302. end
  303.  
  304. tfm.exec.newGame(mapas[math.random(#mapas)])
  305. end
  306.  
  307. p[name].kills = p[name].kills+1;
  308. end
  309.  
  310. function eventPlayerWon(name)
  311. p[name].wins = p[name].wins+1;
  312. end
  313.  
  314. function eventPlayerLeft(name)
  315. jogadores = jogadores-1;
  316. end
  317.  
  318. function eventNewGame()
  319. vivos = 0
  320.  
  321. click = false
  322.  
  323. ui.removeTextArea(-1,nil)
  324. ui.removeTextArea(-2,nil)
  325.  
  326. tfm.exec.setGameTime(120)
  327.  
  328. local sc = {}
  329. for name,player in pairs(tfm.get.room.playerList) do
  330. vivos=vivos+1;
  331. sc[#sc+1] = name
  332. tfm.exec.giveMeep(name)
  333. p[name].rounds = p[name].rounds+1;
  334. end
  335.  
  336. if proximoAssassino == '' then
  337. proximoAssassino = sc[math.random(#sc)]
  338. end
  339.  
  340. admin = proximoAssassino
  341. tfm.exec.killPlayer(admin)
  342. p[admin].killers = p[admin].killers+1;
  343.  
  344. tfm.exec.setUIMapName("<b>#explosion</b> <font color='#6a7495'>|</font> <N>Assassino: </N><V>"..proximoAssassino.."</V>")
  345. tfm.exec.chatMessage("Cuidado <V>"..admin.."</V> é o assassino.")
  346. end
  347.  
  348. for i,v in pairs({"p","help","rank","shop","loja"}) do
  349. system.disableChatCommandDisplay(v, true)
  350. end
  351.  
  352.  
  353. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement