Advertisement
Bolodefchoco_LUAXML

[Script] Sondagem

Jul 19th, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 19/07/2016
  3. --Last update: 19/07/2016
  4. --[[ Notes:
  5.     Does:
  6.         Cria uma sondagem.
  7.     Commands
  8.         !
  9.             start --> Inicia uma nova sondagem
  10.             show --> Apresenta o resultado da sondagem
  11. ]]--
  12.  
  13. adm = {["Bolodefchoco#0000"]=1}
  14.  
  15. ask = "Impeachment da Galaktine?"
  16.  
  17. answers = [[
  18. Sim
  19. Çim
  20. Não
  21. Claro
  22. Não conheço
  23. ]]
  24.  
  25. startVotation=function(n)
  26.     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"
  27.     for id,v in next,answer do
  28.         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"
  29.     end
  30.     ui.addTextArea(0,str,n,220,80,360,270,0x324650,0x181818,1,true)
  31. end
  32. game = false
  33. eventNewPlayer=function(n)
  34.     if game then
  35.         startVotation(n)
  36.     end
  37. end
  38. eventTextAreaCallback=function(i,n,c)
  39.     if c:sub(1,1) == "!" then
  40.         if c:sub(2,2) == "!" then
  41.             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)
  42.         else
  43.             c = tonumber(c:sub(2))
  44.             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)
  45.         end
  46.     elseif c == "back" then startVotation(n)
  47.     elseif c:sub(1,1) == "@" then
  48.         c = tonumber(c:sub(2))
  49.         score[c] = score[c] + 1
  50.         ui.removeTextArea(0,n)
  51.         votes = votes+1
  52.         ui.addTextArea(1,"<PT><B>Votos: "..votes,nil,5,380,nil,nil,1,1,0,true)
  53.     end
  54. end
  55.  
  56. math.percent=function(number1,number2,_type)
  57.     number1,number2=tonumber(number1),tonumber(number2)
  58.     return ((_type==0 or not _type) and number1/number2*100 or _type==1 and (number1/100)*number2)
  59. end
  60.  
  61. eventChatCommand=function(n,c)
  62.     if adm[n] then
  63.         if c == "start" then
  64.             game = true
  65.             answer,score,votes={},{},0
  66.             for v in answers:gmatch('[^\n]+') do if v~="" then
  67.                 table.insert(answer,v);table.insert(score,0) end
  68.             end
  69.             startVotation(nil)
  70.         elseif c == "show" then
  71.             game = false
  72.             local result = 0
  73.             for i,v in next,score do
  74.                 result = result + tonumber(v)
  75.             end
  76.             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"
  77.             for id,v in next,answer do
  78.                 str = str .. "<V>"..(#v>20 and v:sub(1,20).."<J>...</J>" or v).." <G>"..math.percent(score[id],result).."% - ("..score[id]..")\n"
  79.             end
  80.             ui.addTextArea(0,str,nil,220,80,360,270,0x324650,0x181818,1,true)
  81.         end
  82.     end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement