Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. adm = {Bolodefchoco=1}
  2.  
  3. ask = "Impeachment da Galaktine?"
  4.  
  5. answers = [[
  6. Sim
  7. Çim
  8. Não
  9. Claro
  10. Não conheço essa vaca fela de uma mula que da o anus de 69
  11. ]]
  12.  
  13. startVotation=function(n)
  14.     local str = "<p align='center'><font size='30'><VP><u>Sondagem</u></VP></font>\n\n<font size='16'><CE>"..(#ask>40 and ask:sub(1,40).."<a href='event:!!'><J>...</J></a>" or ask).."</CE>\n<font size='13'>\n"
  15.     for id,v in next,answer do
  16.         str = str .. "<a href='event:@"..id.."'>"..(#v>25 and v:sub(1,25).."</a><J><a href='event:!"..id.."'>...</a></J>" or v.."</a>").."\n"
  17.     end
  18.     ui.addTextArea(0,str,n,220,80,360,270,0x324650,0x181818,1,true)
  19. end
  20. game = false
  21. eventNewPlayer=function(n)
  22.     if game then
  23.         startVotation(n)
  24.     end
  25. end
  26. eventTextAreaCallback=function(i,n,c)
  27.     if c:sub(1,1) == "!" then
  28.         if c:sub(2,2) == "!" then
  29.             ui.updateTextArea(0,"<p align='left'><font size='20'><PT><a href='event:back'>Voltar</a> <ROSE>| <PT>Pergunta :<V><font size='16'>\n\n\t"..ask,n)
  30.         else
  31.             c = tonumber(c:sub(2))
  32.             ui.updateTextArea(0,"<p align='left'><font size='20'><PT><a href='event:back'>Voltar</a> <ROSE>| <PT>Opção "..c.." :<V><font size='16'>\n\n\t"..answer[c],n)
  33.         end
  34.     elseif c == "back" then startVotation(n)
  35.     elseif c:sub(1,1) == "@" then
  36.         c = tonumber(c:sub(2))
  37.         score[c] = score[c] + 1
  38.         ui.removeTextArea(0,n)
  39.         votes = votes+1
  40.         ui.addTextArea(1,"<PT><B>Votos: "..votes,nil,5,380,nil,nil,1,1,0,true)
  41.     end
  42. end
  43.  
  44. math.percent=function(number1,number2,_type)
  45.     number1,number2=tonumber(number1),tonumber(number2)
  46.     return ((_type==0 or not _type) and number1/number2*100 or _type==1 and (number1/100)*number2)
  47. end
  48.  
  49. eventChatCommand=function(n,c)
  50.     if adm[n] then
  51.         if c == "start" then
  52.             game = true
  53.             answer,score,votes={},{},0
  54.             for v in answers:gmatch('[^\n]+') do if v~="" then
  55.                 table.insert(answer,v);table.insert(score,0) end
  56.             end
  57.             startVotation(nil)
  58.         elseif c == "show" then
  59.             game = false
  60.             local result = 0
  61.             for i,v in next,score do
  62.                 result = result + tonumber(v)
  63.             end
  64.             local str = "<p align='center'><font size='30'><VP><u>Resultados</u></VP></font>\n\n<font size='16'><CE>"..(#ask>40 and ask:sub(1,40).."<J>...</J>" or ask).."</CE>\n<font size='13'>\n"
  65.             for id,v in next,answer do
  66.                 str = str .. "<V>"..(#v>20 and v:sub(1,20).."<J>...</J>" or v).." <G>"..math.percent(score[id],result).."% - ("..score[id]..")\n"
  67.             end
  68.             ui.addTextArea(0,str,nil,220,80,360,270,0x324650,0x181818,1,true)
  69.         end
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement