Advertisement
Dudugz-Contistente

Untitled

Sep 21st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.04 KB | None | 0 0
  1. local _shortOT, adminPlayer, confirm, getVotesPorcentage, restrictedPlayers, showPopup, ticketName;
  2.  
  3. menuIDS={}
  4.  
  5. --[[ string ]] adminPlayer = "Globo_1";
  6.  
  7. --[[ table ]] answers = {
  8. { votes = 0, value = "Ótima" },
  9. { votes = 0, value = "Boa" },
  10. { votes = 0, value = "Pode melhorar" },
  11. { votes = 0, value = "Ruim" },
  12. { votes = 0, value = "Péssima" },
  13. };
  14.  
  15. --[[ table ]] restrictedPlayers = {};
  16.  
  17. --[[ string ]] ticketName = "O que você acha da tribo?";
  18.  
  19. confirm = function ( answerId, playerName )
  20. local index = answerId - 1;
  21. answers[index].votes = answers[index].votes + 1;
  22. sendMenuuu(30, playerName,'<p align="center">Para ver os resultados, clique na aba "Resultados" no canto inferior esquerdo.', 150, 85, 250, 150, 1, true);
  23.  
  24. for i = 0, 6 do
  25. ui.removeTextArea(i, playerName);
  26. end
  27.  
  28. displayResultsBtn(playerName);
  29. end;
  30.  
  31. displayResultsBtn = function ( target )
  32. ui.addTextArea(10000, "<font size='12'><p align='center'><a href='event:rs'>Resultados", target, 5, 380, nil, 20, 0x122528, 0x122528, 1,true);
  33. end;
  34.  
  35. function sendMenuu(id, player, text, x, y, width, height, alpha)
  36. ui.addTextArea(id.."4440", "", player, x+10, y+height+7, width+0, 13, 0x7a8d93, 0x7a8d93, alpha, true)
  37. ui.addTextArea(id.."4441", "", player, x+11, y+height+8, width+0, 13, 0xe1619, 0xe1619, alpha, true)
  38. ui.addTextArea(id.."4442", "", player, x+11, y+height+8, width-1, 12, 0x314e57, 0x314e57, alpha, true)
  39. ui.addTextArea(id.."4443", text, player, x+11, y+height+5, width+0, nil, 0x314e57, 0x314e57, 0, true)
  40. table.insert(menuIDS,id.."4440")table.insert(menuIDS,id.."4441")table.insert(menuIDS,id.."4442")table.insert(menuIDS,id.."4443")
  41. end
  42.  
  43. function sendMenu(id, player, text, x, y, width, height, alpha)
  44. ui.addTextArea(id..'0', '', player, x+-2, y+18, width+24, height+14, 0x2E221B, 0x2E221B, alpha, true)
  45. ui.addTextArea(id..'00', '', player, x+-1, y+19, width+22, height+12, 0x986742, 0x986742, alpha, true)
  46. ui.addTextArea(id..'000', '', player, x+2, y+22, width+16, height+6, 0x171311, 0x171311, alpha, true)
  47. ui.addTextArea(id..'0000', '', player, x+3, y+23, width+14, height+4, 0x0C191C, 0x0C191C, alpha, true)
  48. ui.addTextArea(id..'00000', '', player, x+4, y+24, width+12, height+2, 0x24474D, 0x24474D, alpha, true)
  49. ui.addTextArea(id..'000000', '', player, x+5, y+25, width+10, height+0, 0x183337, 0x183337, alpha, true)
  50. ui.addTextArea(id..'0000000', text, player, x+6, y+26, width+8, height+-2, 0x122528, 0x122528, alpha, true)
  51. end
  52.  
  53. function sendMenuuu(id, player, text, x, y, width, height, alpha)
  54. ui.addTextArea(id..'0', '', player, x+-2, y+18, width+24, height+14, 0x2E221B, 0x2E221B, alpha, true)
  55. ui.addTextArea(id..'00', '', player, x+-1, y+19, width+22, height+12, 0x986742, 0x986742, alpha, true)
  56. ui.addTextArea(id..'000', '', player, x+2, y+22, width+16, height+6, 0x171311, 0x171311, alpha, true)
  57. ui.addTextArea(id..'0000', '', player, x+3, y+23, width+14, height+4, 0x0C191C, 0x0C191C, alpha, true)
  58. ui.addTextArea(id..'00000', '', player, x+4, y+24, width+12, height+2, 0x24474D, 0x24474D, alpha, true)
  59. ui.addTextArea(id..'000000', '', player, x+5, y+25, width+10, height+0, 0x183337, 0x183337, alpha, true)
  60. ui.addTextArea(id..'0000000', text, player, x+6, y+26, width+8, height+-2, 0x122528, 0x122528, alpha, true)
  61. ui.addTextArea(id.."00000000", "", player, x+10, y+height+7, width+0, 13, 0x7a8d93, 0x7a8d93, alpha, true)
  62. ui.addTextArea(id.."000000000", "", player, x+11, y+height+8, width+0, 13, 0xe1619, 0xe1619, alpha, true)
  63. ui.addTextArea(id.."0000000000", "", player, x+11, y+height+8, width-1, 12, 0x314e57, 0x314e57, alpha, true)
  64. ui.addTextArea(id.."00000000000", '<p align="center"><font size="12"><a href="event:fechar@'..id..'"><VP>Fechar</a>', player, x+11, y+height+5, width+0, nil, 0x314e57, 0x314e57, 0, true)
  65. end
  66.  
  67. function closeMenuuu(id, player)
  68. for x = 15,0,-1 do
  69. id = id..'0'
  70. ui.removeTextArea(id, player)
  71. end
  72.  
  73. for _,id2 in pairs(menuIDS) do ui.removeTextArea(id2, player) end
  74. end
  75.  
  76. function eventTextAreaCallback (id, playerName, callback)
  77. local restriction = restrictedPlayers[playerName];
  78.  
  79. if os.time() > restriction.timer then
  80. restriction.timer = os.time() + 1000;
  81.  
  82. if callback == 'closePopup' then
  83. id = tonumber(tostring(id):sub(1, -3));
  84.  
  85. if id == 30 then
  86. for j = 0, 34 do
  87. ui.removeTextArea(j, playerName);
  88. end
  89. end
  90.  
  91. for j = 51, 59 do
  92. ui.removeTextArea(tonumber(id .. j), playerName);
  93. end
  94.  
  95. elseif callback == 'r' then
  96. confirm(tonumber(string.sub(id, 1, -5)), playerName);
  97.  
  98. elseif callback:sub(0,6) == 'fechar' then
  99. id = callback:sub(8)
  100. closeMenuuu(id, player)
  101. ui.removeTextArea(20, player)
  102.  
  103. elseif callback == 'rs' then
  104. sendMenuuu(30, playerName,"[Ruamorangos] O que você acha da tribo?", 150, 98, 500, 200, 1, true);
  105.  
  106. local lastId, lastY = 5, 128;
  107. local votesPorcentage = getVotesPorcentage();
  108.  
  109. for index, answer in ipairs(answers) do
  110. sendMenuu(lastId, playerName,"<font size='12'><p align='center'>"..answer.value.." <j>- "..answer.votes.." votos ("..votesPorcentage[index].."%)", 150, lastY, 500, 20, 1, true);
  111. lastId = lastId + 1;
  112. lastY = lastY + 30;
  113. end
  114. end
  115. end
  116. end
  117.  
  118. _shortOT = function (item1, item2)
  119. return item1[2] < item2[2];
  120. end;
  121.  
  122. getVotesPorcentage = function ( )
  123. local _answers, totalVotes = {}, 0;
  124.  
  125. for index, answer in ipairs(answers) do
  126. table.insert(_answers, { index, answer.votes });
  127. totalVotes = totalVotes + answer.votes;
  128. end
  129.  
  130. table.sort(_answers, _shortOT);
  131.  
  132. local answersLen = #_answers;
  133. local result = {};
  134.  
  135. for i, answer in ipairs(_answers) do
  136. local thisPercentage = tostring((answer[2] / totalVotes) * 100);
  137. local fi = thisPercentage:find('%.');
  138. fi = fi and fi - 1 or #thisPercentage;
  139. local fraction = thisPercentage:sub(fi + 2) or '';
  140. if #fraction > 0 then
  141. fraction = ',' .. fraction:sub(1, 2);
  142. end
  143. result[answer[1]] = thisPercentage:sub(1, fi) .. fraction;
  144. end
  145.  
  146. return result;
  147. end;
  148.  
  149. --Creator: Bolodefchoco
  150. --Made in: 29/12/2016
  151. --Last update: 01/01/2017
  152. --[[ Notes:
  153. Does:
  154. Sistema idЖntico ao sistema oficial de barra de informaушes (Autor, Mapa, Tempo, Ratos, Shaman)
  155. Args:
  156. set --> Tabela de dados
  157. disableCreator --> Caso seja true, desativarр o nome do autor do mapa
  158. disableCode --> Caso seja true, desativarр o cзdigo do mapa
  159. disableTime --> Caso seja true, desativarр o tempo restante
  160. disableMice --> Caso seja true, desativarр o contador de ratos
  161. disableShaman --> Caso seja true, desativarр o display dos shamans no mapa
  162. ... --> Outras tags a serem mostradas (Exemplo: "<T>Teste","<CE>Teste")
  163. ]]--
  164.  
  165. local players = 0
  166. updateRoomBar = function(set,...)
  167.  
  168. local attribs,args = {},{...}
  169. local author,map,time,shaman = "Tigrounette","@0",120,{}
  170.  
  171. if not set.disableCreator then
  172. author = tfm.get.room.xmlMapInfo and tfm.get.room.xmlMapInfo.author or author
  173. attribs[#attribs+1] = string.format("<J>%s",author)
  174. end
  175.  
  176. if not set.disableCode then
  177. map = tfm.get.room.xmlMapInfo and tfm.get.room.currentMap or map
  178. if not set.disableCreator then
  179. attribs[#attribs] = string.format("Grupo Globo",author,map)
  180. else
  181. attribs[#attribs+1] = string.format("<BL>%s",map)
  182. end
  183. end
  184.  
  185. if not set.disableTime then
  186. time = timeLeft or time
  187. local min,sec = math.floor((time/60)%60),math.floor(time%60)
  188. min,sec = (min < 10 and "0"..min or min),(sec < 10 and "0"..sec or sec)
  189. attribs[#attribs+1] = string.format("<N>Tempo Restante: <V>%s:%s",min,sec)
  190. end
  191.  
  192. if not set.disableMice then
  193. attribs[#attribs+1] = string.format("<N>Ratos: <V>%d",players)
  194. end
  195.  
  196. if not set.disableShaman then
  197. for k,v in next,tfm.get.room.playerList do
  198. if v.isShaman then
  199. table.insert(shaman,k)
  200. end
  201. end
  202. if #shaman > 0 then
  203. attribs[#attribs+1] = string.format("<N>Shaman : <CH>%s",table.concat(shaman," - <PS>"))
  204. end
  205. end
  206.  
  207. if not set.disableVotes then
  208. local totalVotes = 0;
  209. for i, answer in ipairs(answers) do
  210. totalVotes = totalVotes + answer.votes;
  211. end
  212. attribs[#attribs+1] = string.format("<N>Votos: <V>%d",totalVotes)
  213. end
  214.  
  215. if #args > 0 then
  216. for k,v in next,args do
  217. table.insert(attribs,"<N>"..v)
  218. end
  219. end
  220.  
  221. local str = string.format(table.concat(attribs," <G>|<N> "))
  222. ui.setMapName(str.."<")
  223. end
  224.  
  225. eventPlayerLeft = function(n)
  226. players = players - 1
  227. end
  228.  
  229. eventNewPlayer = function(playerName)
  230. players = players + 1
  231. if not restrictedPlayers[playerName] then
  232. restrictedPlayers[playerName] = { timer = 0 }
  233.  
  234. sendMenu(30, playerName,"[Ruamorangos] O que você acha da tribo?", 150, 98, 500, 200, 1, true);
  235. local lastId, lastY = 2, 156;
  236.  
  237. for index, answer in next, answers do
  238. sendMenuu(lastId, playerName,"<font size='12'><p align='center'><a href='event:r'>"..answer.value.."", 150, lastY, 500, 20, 1, true);
  239. lastId = lastId + 1;
  240. lastY = lastY + 30;
  241. end
  242.  
  243. for i = 3054, 3056 do
  244. ui.removeTextArea(i, playerName);
  245. ui.removeTextArea(3059, playerName);
  246. end
  247. return;
  248. end
  249.  
  250. displayResultsBtn(playerName);
  251. end
  252. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  253.  
  254. eventLoop = function(currentTime,timeLeft)
  255. if currentTime >= 1000 then
  256. _G.timeLeft = (timeLeft/1000)
  257. if _G.timeLeft < 0 then
  258. _G.timeLeft = 0
  259. end
  260. end
  261. updateRoomBar({
  262. disableCreator = false,
  263. disableCode = false,
  264. disableTime = false,
  265. disableMice = false,
  266. disableShaman = true
  267. })
  268. end
  269. tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement