Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jogos={{"#paintball",0},{"#dancefloor",0},{"#bombs",0},{"#murder",0},{"#powers",0},{"#batata",0},{"#circuit",0},{"#divinity",0},{"#fight",0},{"#retro",0},{"#spiritual",0},{"#cheesehunter",0},{"#campal",0},{"#playground",0},{"#powerup",0},{"#ratapult",0},{"#pewpew",0},{"#domination",0},{"#basketball",0},{"#ffarace",0},{"#infected",0},{"#virus",0},{"#mestre",0},{"#deathmatch",0},{"#prophunt",0},{"#campal",0},{"#traitor",0},{"#football",0}}
- _D4t4b4s3={}
- --[[
- ~~Sistema de Votos~~~
- Versão: 1.2.5
- CreatedBy: Contistente
- Novidades:
- - Comando: !minigamelist = Abre a lista de minigames
- - Comando: !voto add #nome = Vota em um minigame
- - Comando: !voto del = Deleta seu voto do minigame que você votou
- - Sistema de Auto Atualizar a lista de minigames quando ela está aberta para você.
- --]]
- function split(t,s) -- retorna uma table com a string dividida
- local a={}
- for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
- table.insert(a,i)
- end
- return a
- end
- function eventNewPlayer(name)
- if not _D4t4b4s3[name] then
- _D4t4b4s3[name]={
- inList=false,
- voted=false,
- minigameVoted="#nome"
- }
- else
- _D4t4b4s3[name].inList=false
- end
- end
- function eventChatCommand(name, cmd)
- local cmd = split(cmd, " ")
- if cmd[1] == "voto" and cmd[2] then
- if cmd[2] == "add" and not _D4t4b4s3[name].voted then
- nV = false
- if cmd[3] then
- local jogo = cmd[3]
- for i,v in pairs(jogos) do
- if v[1] == jogo then
- v[2] = v[2]+1
- _D4t4b4s3[name].voted = true
- _D4t4b4s3[name].minigameVoted = v[1]
- ui.addPopup(0,3,"<font color='#00FF00'>Você votou no minigame: "..v[1].."</font>",name,200,100,450,true)
- nV = true
- break
- end
- end
- for i,v in pairs(tfm.get.room.playerList) do
- if _D4t4b4s3[i].inList then
- eventChatCommand(i, "minigamelist")
- end
- end
- end
- if not nV then
- ui.addPopup(0,3,"<font color='#00FFC2'>[Erro] Você não digitou um nome válido (!voto add #MinigameDaLista).</font>",name,200,100,450,true)
- end
- end
- if cmd[2] == "del" and _D4t4b4s3[name].voted then
- for i,v in pairs(jogos) do
- if _D4t4b4s3[name].minigameVoted == v[1] then
- v[2] = v[2]-1
- _D4t4b4s3[name].voted = false
- _D4t4b4s3[name].minigameVoted = "#nome"
- ui.addPopup(0,3,"<font color='#00FF00'>Você deletou seu voto do minigame: "..v[1].."</font>",name,200,100,450,true)
- break
- end
- end
- for i,v in pairs(tfm.get.room.playerList) do
- if _D4t4b4s3[i].inList then
- eventChatCommand(i, "minigamelist")
- end
- end
- end
- end
- if cmd[1] == "minigamelist" then
- _D4t4b4s3[name].inList=true
- ui.addTextArea(0,"",name,4,23,791,380,0x324650,0x324650,nil,true,true)
- ui.addTextArea(1,"<p align='center'><B><J><font size='15' face='Fixedsys'>Lista de Minigames:",name,5,26,789,nil,0x3c5063,0x3c5063,nil,true,false,false,true)
- ui.addTextArea(2,"<p align='center'><font color='#FF0000' size='16'><B><I><a href='event:close'>X</a></I></B></font></p>",name,780,24,nil,nil,0,0,0,true)
- texto = {}
- page=1
- selected=page
- texto[page]=""
- texto[page+1]=""
- texto[page+2]=""
- for i,v in pairs(jogos) do
- info = v[2]
- if info < 10 then
- info = "0"..v[2]
- end
- if i == 24 or i == 47 then
- selected=selected+1
- end
- if texto[selected] ~= "" then
- texto[selected] = texto[selected]..'<br>Votos: <BL>'..info..'</BL> Nome: <BL>'..v[1]..'</BL>'
- else
- texto[selected] = 'Votos: <BL>'..info..'</BL> Nome: <BL>'..v[1]..'</BL>'
- end
- end
- if texto[page] == "" then texto[page]="<p align='center'>Não há minigames nesta lista.</p>" end
- if texto[page+1] == "" then texto[page+1]="<p align='center'>Não há minigames nesta lista.</p>" end
- if texto[page+2] == "" then texto[page+2]="<p align='center'>Não há minigames nesta lista.</p>" end
- ui.addTextArea(3,"<B><VP><font size='11'>"..texto[page],name,50,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
- ui.addTextArea(4,"<B><VP><font size='11'>"..texto[page+1],name,295,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
- ui.addTextArea(5,"<B><VP><font size='11'>"..texto[page+2],name,540,65,210,320,0x38516b,0x38516b,nil,true,false,false,true)
- end
- end
- function eventTextAreaCallback(id,name,link)
- if link == "close" then
- for i=0,5 do
- ui.removeTextArea(i,name)
- end
- _D4t4b4s3[name].inList=false
- end
- end
- for all in pairs(tfm.get.room.playerList) do
- eventNewPlayer(all)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement