Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 27/06/2016
- --Last update: 27/06/2016
- --[[ Notes:
- Does:
- Faz uma votação de 60 segundos (editável em #).
- Os candidatos ficarão na tabela candidatos (editável em ##).
- Após 60 segundos, o adm (editável em ###) poderá ver os resultados.
- Comandos:
- !results -- Ver os resultados
- !new -- Nova votação
- ]]--
- local timer = os.time() + 60000 -----------< #
- local adm = "Bolodefchoco" ----------------< ###
- stop = false
- ui.election=function(n)
- ui.addTextArea(0,"",n,125,50,550,300,0xe7e8cf,1,1,true)
- 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)
- ui.addTextArea(2,"",n,417,96,240,238,0x26292a,0x26292a,1,true)
- ui.addTextArea(3,"<font color='#0' size='20'>JUSTIÇA FIDELGAL",n,443,61,214,67,1,1,0,true)
- ui.addTextArea(4,"<font size='20'><a href='event:1'>1",n,460, 110,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(5,"<font size='20'><a href='event:2'>2",n,525, 110,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(6,"<font size='20'><a href='event:3'>3",n,590, 110,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(7,"<font size='20'><a href='event:4'>4",n,460, 160,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(8,"<font size='20'><a href='event:5'>5",n,525, 160,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(9,"<font size='20'><a href='event:6'>6",n,590, 160,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(10,"<font size='20'><a href='event:7'>7",n,460,210,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(11,"<font size='20'><a href='event:8'>8",n,525,210,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(12,"<font size='20'><a href='event:9'>9",n,590,210,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(13,"<font size='20'><a href='event:0'>0",n,525,260,35,30,0x121212,0x121212,1,true)
- ui.addTextArea(14,"<font color='#0' letterSpacing='-1' size='13'><a href='event:BRANCO'>BRANCO",n,427,305,60,25,0xffffff,0xffffff,1,true)
- ui.addTextArea(15,"<font color='#0' letterSpacing='-1' size='13'><a href='event:CORRIGE'>CORRIGE",n,503,305,60,25,0xe8652b,0xe8652b,1,true)
- ui.addTextArea(16,"<font color='#0' letterSpacing='-1' size='13'><a href='event:CONFIRMA'>CONFIRMA",n,579,297,71,33,0x64e45d,0x64e45d,1,true)
- end
- verifyVote=function(n,t)
- for k,v in next,candidatos do
- if v[1] == mice[n].code then
- mice[n].voted = true
- candidatos[k][3] = candidatos[k][3] + 1
- mice[n].p = candidatos[k][2]
- mice[n].code = "<VP>"..mice[n].code.."</VP>"
- break
- end
- end
- if not mice[n].voted and t then
- mice[n].code = "<R>Invalid</R>"
- end
- end
- candidatos = { ---------------------< ##
- {'0001',"José Sarnento",0},
- {'0010',"Wilma Rouseff",0},
- {'1000',"Bolsonero",0},
- {'0100',"Jean Whylies",0},
- {'0101',"José Ferra",0},
- {'0201',"Putin",0},
- {'5936',"Ynês Brazil",0},
- {'5310',"Sasha Rey",0},
- }
- mice={}
- eventNewPlayer=function(n)
- if not stop then
- if not mice[n] then
- mice[n]={
- code = "",
- voted = false,
- p = "",
- }
- end
- local candidatos2,color = "<font size='10'>",0
- for k,v in next,candidatos do
- color = color + 1
- candidatos2 = candidatos2 .. (color%2==0 and "<G>" or "<BL>") .. v[2] .. " - N° " .. v[1] .. "\n"
- end
- ui.addTextArea(17,candidatos2,n,5,35,100,350,1,1,.8,true)
- ui.election(n)
- end
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- eventTextAreaCallback=function(i,n,c)
- if not mice[n].voted then
- if c == "BRANCO" then
- local candidato = {'',"",0}
- for k,v in next,candidatos do
- if v[3] > 0 then
- if v[3] > candidato[3] then
- candidato = v
- end
- end
- end
- if candidato[1] ~= '' then mice[n].code=candidato[1] end
- verifyVote(n,true)
- elseif c == "CORRIGE" then
- mice[n].code = ""
- elseif c == "CONFIRMA" then
- verifyVote(n,true)
- else
- if #mice[n].code == 14 then mice[n].code = "" end
- if #mice[n].code < 4 then
- mice[n].code = mice[n].code .. c
- end
- end
- ui.election(n)
- end
- end
- eventChatCommand=function(n,c)
- if os.time() > timer and n == adm and c == "results" then
- stop = true
- local r,counter = "",0
- table.sort(candidatos,function(a,b) return a[3] > b[3] end)
- for k,v in next,candidatos do
- counter = counter + 1
- r = r .. (counter<4 and "<VP>" or "<R>") .. v[2] .. " <G>-</G> " .. v[3] .. "\n"
- end
- for n in next,tfm.get.room.playerList do
- mice[n].voted = true
- mice[n].code = "<PT>Resultados</PT>"
- mice[n].p = r
- ui.election(n)
- end
- end
- if c == "new" then
- stop = false
- mice = {}
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement