Advertisement
Dudugz-Contistente

Untitled

Mar 25th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. jogos={{"#paintball",0},{"#dancefloor",0},{"#bombs",0},{"#murder",0},{"#powers",0},{"#batata",0},{"#circuit",0},{"#divinity",0},{"#fight",0},{"#retro",0},{"#spiritual",0},{"#cheesehunter",0},{"#campal",0},{"#playground",0},{"#powerup",0},{"#ratapult",0},{"#pewpew",0},{"#domination",0},{"#basketball",0},{"#ffarace",0},{"#infected",0},{"#virus",0},{"#mestre",0},{"#deathmatch",0},{"#prophunt",0},{"#campal",0},{"#traitor",0},{"#football",0}}
  2.  
  3. _D4t4b4s3={}
  4.  
  5. --[[
  6.  
  7. ~~Sistema de Votos~~~
  8. Versão: 1.2.5
  9. CreatedBy: Contistente
  10.  
  11. Novidades:
  12. - Comando: !minigamelist = Abre a lista de minigames
  13. - Comando: !voto add #nome = Vota em um minigame
  14. - Comando: !voto del = Deleta seu voto do minigame que você votou
  15. - Sistema de Auto Atualizar a lista de minigames quando ela está aberta para você.
  16.  
  17. --]]
  18.  
  19. function split(t,s) -- retorna uma table com a string dividida
  20. local a={}
  21. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  22. table.insert(a,i)
  23. end
  24. return a
  25. end
  26.  
  27. function eventNewPlayer(name)
  28. if not _D4t4b4s3[name] then
  29. _D4t4b4s3[name]={
  30. inList=false,
  31. voted=false,
  32. minigameVoted="#nome"
  33. }
  34. else
  35. _D4t4b4s3[name].inList=false
  36. end
  37. end
  38.  
  39. function eventChatCommand(name, cmd)
  40. local cmd = split(cmd, " ")
  41. if cmd[1] == "voto" and cmd[2] then
  42. if cmd[2] == "add" and not _D4t4b4s3[name].voted then
  43. nV = false
  44. if cmd[3] then
  45. local jogo = cmd[3]
  46.  
  47. for i,v in pairs(jogos) do
  48. if v[1] == jogo then
  49. v[2] = v[2]+1
  50. _D4t4b4s3[name].voted = true
  51. _D4t4b4s3[name].minigameVoted = v[1]
  52. ui.addPopup(0,3,"<font color='#00FF00'>Você votou no minigame: "..v[1].."</font>",name,200,100,450,true)
  53. nV = true
  54. break
  55. end
  56. end
  57.  
  58. for i,v in pairs(tfm.get.room.playerList) do
  59. if _D4t4b4s3[i].inList then
  60. eventChatCommand(i, "minigamelist")
  61. end
  62. end
  63. end
  64.  
  65. if not nV then
  66. ui.addPopup(0,3,"<font color='#00FFC2'>[Erro] Você não digitou um nome válido (!voto add #MinigameDaLista).</font>",name,200,100,450,true)
  67. end
  68. end
  69.  
  70. if cmd[2] == "del" and _D4t4b4s3[name].voted then
  71. for i,v in pairs(jogos) do
  72. if _D4t4b4s3[name].minigameVoted == v[1] then
  73. v[2] = v[2]-1
  74. _D4t4b4s3[name].voted = false
  75. _D4t4b4s3[name].minigameVoted = "#nome"
  76. ui.addPopup(0,3,"<font color='#00FF00'>Você deletou seu voto do minigame: "..v[1].."</font>",name,200,100,450,true)
  77. break
  78. end
  79. end
  80.  
  81. for i,v in pairs(tfm.get.room.playerList) do
  82. if _D4t4b4s3[i].inList then
  83. eventChatCommand(i, "minigamelist")
  84. end
  85. end
  86. end
  87. end
  88.  
  89. if cmd[1] == "minigamelist" then
  90. _D4t4b4s3[name].inList=true
  91. ui.addTextArea(0,"",name,4,23,791,380,0x324650,0x324650,nil,true,true)
  92. ui.addTextArea(1,"<p align='center'><B><J><font size='15' face='Fixedsys'>Lista de Minigames:",name,5,26,789,nil,0x3c5063,0x3c5063,nil,true,false,false,true)
  93. ui.addTextArea(2,"<p align='center'><font color='#FF0000' size='16'><B><I><a href='event:close'>X</a></I></B></font></p>",name,780,24,nil,nil,0,0,0,true)
  94.  
  95. texto = {}
  96. page=1
  97. selected=page
  98.  
  99. texto[page]=""
  100. texto[page+1]=""
  101. texto[page+2]=""
  102.  
  103. for i,v in pairs(jogos) do
  104. info = v[2]
  105. if info < 10 then
  106. info = "0"..v[2]
  107. end
  108.  
  109. if i == 24 or i == 47 then
  110. selected=selected+1
  111. end
  112.  
  113. if texto[selected] ~= "" then
  114. texto[selected] = texto[selected]..'<br>Votos: <BL>'..info..'</BL> Nome: <BL>'..v[1]..'</BL>'
  115. else
  116. texto[selected] = 'Votos: <BL>'..info..'</BL> Nome: <BL>'..v[1]..'</BL>'
  117. end
  118. end
  119.  
  120. if texto[page] == "" then texto[page]="<p align='center'>Não há minigames nesta lista.</p>" end
  121. if texto[page+1] == "" then texto[page+1]="<p align='center'>Não há minigames nesta lista.</p>" end
  122. if texto[page+2] == "" then texto[page+2]="<p align='center'>Não há minigames nesta lista.</p>" end
  123.  
  124. ui.addTextArea(3,"<B><VP><font size='11'>"..texto[page],name,50,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
  125. ui.addTextArea(4,"<B><VP><font size='11'>"..texto[page+1],name,295,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
  126. ui.addTextArea(5,"<B><VP><font size='11'>"..texto[page+2],name,540,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
  127. end
  128. end
  129.  
  130. function eventTextAreaCallback(id,name,link)
  131. if link == "close" then
  132. for i=0,5 do
  133. ui.removeTextArea(i,name)
  134. end
  135.  
  136. _D4t4b4s3[name].inList=false
  137. end
  138. end
  139.  
  140. for all in pairs(tfm.get.room.playerList) do
  141. eventNewPlayer(all)
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement