Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _shortOT, adminPlayer, confirm, getVotesPorcentage, restrictedPlayers, showPopup, ticketName;
- menuIDS={}
- --[[ string ]] adminPlayer = "Globo_1";
- --[[ table ]] answers = {
- { votes = 0, value = "Ótima" },
- { votes = 0, value = "Boa" },
- { votes = 0, value = "Pode melhorar" },
- { votes = 0, value = "Ruim" },
- { votes = 0, value = "Péssima" },
- };
- --[[ table ]] restrictedPlayers = {};
- --[[ string ]] ticketName = "O que você acha da tribo?";
- confirm = function ( answerId, playerName )
- local index = answerId - 1;
- answers[index].votes = answers[index].votes + 1;
- sendMenuuu(30, playerName,'<p align="center">Para ver os resultados, clique na aba "Resultados" no canto inferior esquerdo.', 150, 85, 250, 150, 1, true);
- for i = 0, 6 do
- ui.removeTextArea(i, playerName);
- end
- displayResultsBtn(playerName);
- end;
- displayResultsBtn = function ( target )
- ui.addTextArea(10000, "<font size='12'><p align='center'><a href='event:rs'>Resultados", target, 5, 380, nil, 20, 0x122528, 0x122528, 1,true);
- end;
- function sendMenuu(id, player, text, x, y, width, height, alpha)
- ui.addTextArea(id.."4440", "", player, x+10, y+height+7, width+0, 13, 0x7a8d93, 0x7a8d93, alpha, true)
- ui.addTextArea(id.."4441", "", player, x+11, y+height+8, width+0, 13, 0xe1619, 0xe1619, alpha, true)
- ui.addTextArea(id.."4442", "", player, x+11, y+height+8, width-1, 12, 0x314e57, 0x314e57, alpha, true)
- ui.addTextArea(id.."4443", text, player, x+11, y+height+5, width+0, nil, 0x314e57, 0x314e57, 0, true)
- table.insert(menuIDS,id.."4440")table.insert(menuIDS,id.."4441")table.insert(menuIDS,id.."4442")table.insert(menuIDS,id.."4443")
- end
- function sendMenu(id, player, text, x, y, width, height, alpha)
- ui.addTextArea(id..'0', '', player, x+-2, y+18, width+24, height+14, 0x2E221B, 0x2E221B, alpha, true)
- ui.addTextArea(id..'00', '', player, x+-1, y+19, width+22, height+12, 0x986742, 0x986742, alpha, true)
- ui.addTextArea(id..'000', '', player, x+2, y+22, width+16, height+6, 0x171311, 0x171311, alpha, true)
- ui.addTextArea(id..'0000', '', player, x+3, y+23, width+14, height+4, 0x0C191C, 0x0C191C, alpha, true)
- ui.addTextArea(id..'00000', '', player, x+4, y+24, width+12, height+2, 0x24474D, 0x24474D, alpha, true)
- ui.addTextArea(id..'000000', '', player, x+5, y+25, width+10, height+0, 0x183337, 0x183337, alpha, true)
- ui.addTextArea(id..'0000000', text, player, x+6, y+26, width+8, height+-2, 0x122528, 0x122528, alpha, true)
- end
- function sendMenuuu(id, player, text, x, y, width, height, alpha)
- ui.addTextArea(id..'0', '', player, x+-2, y+18, width+24, height+14, 0x2E221B, 0x2E221B, alpha, true)
- ui.addTextArea(id..'00', '', player, x+-1, y+19, width+22, height+12, 0x986742, 0x986742, alpha, true)
- ui.addTextArea(id..'000', '', player, x+2, y+22, width+16, height+6, 0x171311, 0x171311, alpha, true)
- ui.addTextArea(id..'0000', '', player, x+3, y+23, width+14, height+4, 0x0C191C, 0x0C191C, alpha, true)
- ui.addTextArea(id..'00000', '', player, x+4, y+24, width+12, height+2, 0x24474D, 0x24474D, alpha, true)
- ui.addTextArea(id..'000000', '', player, x+5, y+25, width+10, height+0, 0x183337, 0x183337, alpha, true)
- ui.addTextArea(id..'0000000', text, player, x+6, y+26, width+8, height+-2, 0x122528, 0x122528, alpha, true)
- ui.addTextArea(id.."00000000", "", player, x+10, y+height+7, width+0, 13, 0x7a8d93, 0x7a8d93, alpha, true)
- ui.addTextArea(id.."000000000", "", player, x+11, y+height+8, width+0, 13, 0xe1619, 0xe1619, alpha, true)
- ui.addTextArea(id.."0000000000", "", player, x+11, y+height+8, width-1, 12, 0x314e57, 0x314e57, alpha, true)
- 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)
- end
- function closeMenuuu(id, player)
- for x = 15,0,-1 do
- id = id..'0'
- ui.removeTextArea(id, player)
- end
- for _,id2 in pairs(menuIDS) do ui.removeTextArea(id2, player) end
- end
- function eventTextAreaCallback (id, playerName, callback)
- local restriction = restrictedPlayers[playerName];
- if os.time() > restriction.timer then
- restriction.timer = os.time() + 1000;
- if callback == 'closePopup' then
- id = tonumber(tostring(id):sub(1, -3));
- if id == 30 then
- for j = 0, 34 do
- ui.removeTextArea(j, playerName);
- end
- end
- for j = 51, 59 do
- ui.removeTextArea(tonumber(id .. j), playerName);
- end
- elseif callback == 'r' then
- confirm(tonumber(string.sub(id, 1, -5)), playerName);
- elseif callback:sub(0,6) == 'fechar' then
- id = callback:sub(8)
- closeMenuuu(id, player)
- ui.removeTextArea(20, player)
- elseif callback == 'rs' then
- sendMenuuu(30, playerName,"[Ruamorangos] O que você acha da tribo?", 150, 98, 500, 200, 1, true);
- local lastId, lastY = 5, 128;
- local votesPorcentage = getVotesPorcentage();
- for index, answer in ipairs(answers) do
- sendMenuu(lastId, playerName,"<font size='12'><p align='center'>"..answer.value.." <j>- "..answer.votes.." votos ("..votesPorcentage[index].."%)", 150, lastY, 500, 20, 1, true);
- lastId = lastId + 1;
- lastY = lastY + 30;
- end
- end
- end
- end
- _shortOT = function (item1, item2)
- return item1[2] < item2[2];
- end;
- getVotesPorcentage = function ( )
- local _answers, totalVotes = {}, 0;
- for index, answer in ipairs(answers) do
- table.insert(_answers, { index, answer.votes });
- totalVotes = totalVotes + answer.votes;
- end
- table.sort(_answers, _shortOT);
- local answersLen = #_answers;
- local result = {};
- for i, answer in ipairs(_answers) do
- local thisPercentage = tostring((answer[2] / totalVotes) * 100);
- local fi = thisPercentage:find('%.');
- fi = fi and fi - 1 or #thisPercentage;
- local fraction = thisPercentage:sub(fi + 2) or '';
- if #fraction > 0 then
- fraction = ',' .. fraction:sub(1, 2);
- end
- result[answer[1]] = thisPercentage:sub(1, fi) .. fraction;
- end
- return result;
- end;
- --Creator: Bolodefchoco
- --Made in: 29/12/2016
- --Last update: 01/01/2017
- --[[ Notes:
- Does:
- Sistema idЖntico ao sistema oficial de barra de informaушes (Autor, Mapa, Tempo, Ratos, Shaman)
- Args:
- set --> Tabela de dados
- disableCreator --> Caso seja true, desativarр o nome do autor do mapa
- disableCode --> Caso seja true, desativarр o cзdigo do mapa
- disableTime --> Caso seja true, desativarр o tempo restante
- disableMice --> Caso seja true, desativarр o contador de ratos
- disableShaman --> Caso seja true, desativarр o display dos shamans no mapa
- ... --> Outras tags a serem mostradas (Exemplo: "<T>Teste","<CE>Teste")
- ]]--
- local players = 0
- updateRoomBar = function(set,...)
- local attribs,args = {},{...}
- local author,map,time,shaman = "Tigrounette","@0",120,{}
- if not set.disableCreator then
- author = tfm.get.room.xmlMapInfo and tfm.get.room.xmlMapInfo.author or author
- attribs[#attribs+1] = string.format("<J>%s",author)
- end
- if not set.disableCode then
- map = tfm.get.room.xmlMapInfo and tfm.get.room.currentMap or map
- if not set.disableCreator then
- attribs[#attribs] = string.format("Grupo Globo",author,map)
- else
- attribs[#attribs+1] = string.format("<BL>%s",map)
- end
- end
- if not set.disableTime then
- time = timeLeft or time
- local min,sec = math.floor((time/60)%60),math.floor(time%60)
- min,sec = (min < 10 and "0"..min or min),(sec < 10 and "0"..sec or sec)
- attribs[#attribs+1] = string.format("<N>Tempo Restante: <V>%s:%s",min,sec)
- end
- if not set.disableMice then
- attribs[#attribs+1] = string.format("<N>Ratos: <V>%d",players)
- end
- if not set.disableShaman then
- for k,v in next,tfm.get.room.playerList do
- if v.isShaman then
- table.insert(shaman,k)
- end
- end
- if #shaman > 0 then
- attribs[#attribs+1] = string.format("<N>Shaman : <CH>%s",table.concat(shaman," - <PS>"))
- end
- end
- if not set.disableVotes then
- local totalVotes = 0;
- for i, answer in ipairs(answers) do
- totalVotes = totalVotes + answer.votes;
- end
- attribs[#attribs+1] = string.format("<N>Votos: <V>%d",totalVotes)
- end
- if #args > 0 then
- for k,v in next,args do
- table.insert(attribs,"<N>"..v)
- end
- end
- local str = string.format(table.concat(attribs," <G>|<N> "))
- ui.setMapName(str.."<")
- end
- eventPlayerLeft = function(n)
- players = players - 1
- end
- eventNewPlayer = function(playerName)
- players = players + 1
- if not restrictedPlayers[playerName] then
- restrictedPlayers[playerName] = { timer = 0 }
- sendMenu(30, playerName,"[Ruamorangos] O que você acha da tribo?", 150, 98, 500, 200, 1, true);
- local lastId, lastY = 2, 156;
- for index, answer in next, answers do
- sendMenuu(lastId, playerName,"<font size='12'><p align='center'><a href='event:r'>"..answer.value.."", 150, lastY, 500, 20, 1, true);
- lastId = lastId + 1;
- lastY = lastY + 30;
- end
- for i = 3054, 3056 do
- ui.removeTextArea(i, playerName);
- ui.removeTextArea(3059, playerName);
- end
- return;
- end
- displayResultsBtn(playerName);
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- eventLoop = function(currentTime,timeLeft)
- if currentTime >= 1000 then
- _G.timeLeft = (timeLeft/1000)
- if _G.timeLeft < 0 then
- _G.timeLeft = 0
- end
- end
- updateRoomBar({
- disableCreator = false,
- disableCode = false,
- disableTime = false,
- disableMice = false,
- disableShaman = true
- })
- end
- tfm.exec.newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement