Advertisement
Bolodefchoco_LUAXML

[Script] Votação no Brasil

Jun 27th, 2016
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.60 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 27/06/2016
  3. --Last update: 27/06/2016
  4. --[[ Notes:
  5.     Does:
  6.         Faz uma votação de 60 segundos (editável em #).
  7.         Os candidatos ficarão na tabela candidatos (editável em ##).
  8.         Após 60 segundos, o adm (editável em ###) poderá ver os resultados.
  9.     Comandos:
  10.         !results -- Ver os resultados
  11.         !new -- Nova votação
  12. ]]--
  13.  
  14. local timer = os.time() + 60000 -----------< #
  15. local adm = "Bolodefchoco" ----------------< ###
  16. stop = false
  17.  
  18. ui.election=function(n)
  19.     ui.addTextArea(0,"",n,125,50,550,300,0xe7e8cf,1,1,true)
  20.     ui.addTextArea(1,"<font color='#0' size='16'><p align='center'><font size='25'>"..mice[n].code.."</font></p>\n\n"..mice[n].p,n,140,64,250,270,0xe7e8cf,0x26292a,1,true)
  21.     ui.addTextArea(2,"",n,417,96,240,238,0x26292a,0x26292a,1,true)
  22.     ui.addTextArea(3,"<font color='#0' size='20'>JUSTIÇA FIDELGAL",n,443,61,214,67,1,1,0,true)
  23.     ui.addTextArea(4,"<font size='20'><a href='event:1'>1",n,460, 110,35,30,0x121212,0x121212,1,true)
  24.     ui.addTextArea(5,"<font size='20'><a href='event:2'>2",n,525, 110,35,30,0x121212,0x121212,1,true)
  25.     ui.addTextArea(6,"<font size='20'><a href='event:3'>3",n,590, 110,35,30,0x121212,0x121212,1,true)
  26.     ui.addTextArea(7,"<font size='20'><a href='event:4'>4",n,460, 160,35,30,0x121212,0x121212,1,true)
  27.     ui.addTextArea(8,"<font size='20'><a href='event:5'>5",n,525, 160,35,30,0x121212,0x121212,1,true)
  28.     ui.addTextArea(9,"<font size='20'><a href='event:6'>6",n,590, 160,35,30,0x121212,0x121212,1,true)
  29.     ui.addTextArea(10,"<font size='20'><a href='event:7'>7",n,460,210,35,30,0x121212,0x121212,1,true)
  30.     ui.addTextArea(11,"<font size='20'><a href='event:8'>8",n,525,210,35,30,0x121212,0x121212,1,true)
  31.     ui.addTextArea(12,"<font size='20'><a href='event:9'>9",n,590,210,35,30,0x121212,0x121212,1,true)
  32.     ui.addTextArea(13,"<font size='20'><a href='event:0'>0",n,525,260,35,30,0x121212,0x121212,1,true)
  33.     ui.addTextArea(14,"<font color='#0' letterSpacing='-1' size='13'><a href='event:BRANCO'>BRANCO",n,427,305,60,25,0xffffff,0xffffff,1,true)
  34.     ui.addTextArea(15,"<font color='#0' letterSpacing='-1' size='13'><a href='event:CORRIGE'>CORRIGE",n,503,305,60,25,0xe8652b,0xe8652b,1,true)
  35.     ui.addTextArea(16,"<font color='#0' letterSpacing='-1' size='13'><a href='event:CONFIRMA'>CONFIRMA",n,579,297,71,33,0x64e45d,0x64e45d,1,true)
  36. end
  37.  
  38. verifyVote=function(n,t)
  39.     for k,v in next,candidatos do
  40.         if v[1] == mice[n].code then
  41.             mice[n].voted = true
  42.             candidatos[k][3] = candidatos[k][3] + 1
  43.             mice[n].p = candidatos[k][2]
  44.             mice[n].code = "<VP>"..mice[n].code.."</VP>"
  45.             break
  46.         end
  47.     end
  48.     if not mice[n].voted and t then
  49.         mice[n].code = "<R>Invalid</R>"
  50.     end
  51. end
  52.  
  53. candidatos = { ---------------------< ##
  54.     {'0001',"José Sarnento",0},
  55.     {'0010',"Wilma Rouseff",0},
  56.     {'1000',"Bolsonero",0},
  57.     {'0100',"Jean Whylies",0},
  58.     {'0101',"José Ferra",0},
  59.     {'0201',"Putin",0},
  60.     {'5936',"Ynês Brazil",0},
  61.     {'5310',"Sasha Rey",0},
  62. }
  63.  
  64. mice={}
  65. eventNewPlayer=function(n)
  66.     if not stop then
  67.         if not mice[n] then
  68.             mice[n]={
  69.                 code = "",
  70.                 voted = false,
  71.                 p = "",
  72.             }
  73.         end
  74.         local candidatos2,color = "<font size='10'>",0
  75.         for k,v in next,candidatos do
  76.             color = color + 1
  77.             candidatos2 = candidatos2 .. (color%2==0 and "<G>" or "<BL>") .. v[2] .. " - N° " .. v[1] .. "\n"
  78.         end
  79.         ui.addTextArea(17,candidatos2,n,5,35,100,350,1,1,.8,true)
  80.         ui.election(n)
  81.     end
  82. end
  83. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  84.  
  85. eventTextAreaCallback=function(i,n,c)
  86.     if not mice[n].voted then
  87.         if c == "BRANCO" then
  88.             local candidato = {'',"",0}
  89.             for k,v in next,candidatos do
  90.                 if v[3] > 0 then
  91.                     if v[3] > candidato[3] then
  92.                         candidato = v
  93.                     end
  94.                 end
  95.             end
  96.             if candidato[1] ~= '' then mice[n].code=candidato[1] end
  97.             verifyVote(n,true)
  98.         elseif c == "CORRIGE" then
  99.             mice[n].code = ""
  100.         elseif c == "CONFIRMA" then
  101.             verifyVote(n,true)
  102.         else
  103.             if #mice[n].code == 14 then mice[n].code = "" end
  104.             if #mice[n].code < 4 then
  105.                 mice[n].code = mice[n].code .. c
  106.             end
  107.         end
  108.         ui.election(n)
  109.     end
  110. end
  111.  
  112. eventChatCommand=function(n,c)
  113.     if os.time() > timer and n == adm and c == "results" then
  114.         stop = true
  115.         local r,counter = "",0
  116.         table.sort(candidatos,function(a,b) return a[3] > b[3] end)
  117.         for k,v in next,candidatos do
  118.             counter = counter + 1
  119.             r = r .. (counter<4 and "<VP>" or "<R>") .. v[2] .. " <G>-</G> " .. v[3] .. "\n"
  120.         end
  121.         for n in next,tfm.get.room.playerList do
  122.             mice[n].voted = true
  123.             mice[n].code = "<PT>Resultados</PT>"
  124.             mice[n].p = r
  125.             ui.election(n)
  126.         end
  127.     end
  128.     if c == "new" then
  129.         stop = false
  130.         mice = {}
  131.         table.foreach(tfm.get.room.playerList,eventNewPlayer)
  132.     end
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement