Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p={}
- shaman = ""
- mapas = {6998890}
- vivos = 0
- time = os.time();
- jogadores = {}
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- function split(t,s)
- 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 eventChatCommand(p, cmd)
- local arg = split(cmd, " ")
- if arg[1] == "commands" then
- tfm.exec.chatMessage("<B><I><J>→ Comandos:</J></I></B><br>!help - mensagem de ajuda.<br>!rank - abre o ranking.<br>!p [nick] - abre o perfil, sem o nome abre apenas o seu.",name)
- end
- if arg[1] == "p" then
- tfm.exec.chatMessage("<I><R>→ O perfil está em manutenção.</R></I>",name)
- end
- if arg[1] == "help" then
- tfm.exec.chatMessage("<B><I><VI>→ Como jogar:</VI></B></I><br><VP>O jogo tem dois portais, um azul que segue os ratos e um laranja que aparece aleatóriamente no mapa, a função dos ratos é sobreviver e não ser morto pelos portais, se o tempo acabar os vivos vencem, caso contrário todos morrerem nimguém vence.</VP>",name)
- end
- if arg[1] == "rank" then
- eventRanking(p)
- end
- end
- function eventRanking(name)
- local sc = {}
- for name, player in pairs(tfm.get.room.playerList) do
- sc[#sc+1] = {n=name,s=player.score} -- insira o valor que quiser
- end
- table.sort(sc,function(a,b) return a.s>b.s end) -- aqui ele reorganiza tudo certinho o s ali no a.s e b.s é o score da tabela acima
- str = ''
- ui.addTextArea(0,"",name,200,45,300,300,nil,0x324650,nil,true)
- ui.addTextArea(1,'<B><J><font size="16"><I><p align="center">Ranking',name,195,40,310,30,nil,0x2e424d,nil,true)
- ui.addTextArea(2,"",name,205,85,290,223,0x0e232b,0x0e232b,nil,true)
- ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,205,320,290,20,0x3c5063,0x3c5063,nil,true)
- y1 = 87
- x1 = 208
- for k,v in pairs(sc) do
- if k < 7 then
- ui.addTextArea(4949+k,k,name,x1,y1,25,17,0x2e424d,0x2e424d,70,true)
- ui.addTextArea(3939+k,v.n,name,x1+40,y1,nil,17,0x2e424d,0x2e424d,70,true)
- ui.addTextArea(2929+k,v.s,name,x1+150,y1,60,17,0x2e424d,0x2e424d,70,true)
- y1 = y1+30
- end
- end
- end
- function eventTextAreaCallback(id,name,link)
- if link == "close" then
- for id=-1,2 do
- ui.removeTextArea(id,name)
- ui.removeTextArea(6969+id,name)
- ui.removeTextArea(7979+id,name)
- end
- for id=4949,4956 do
- ui.removeTextArea(id,name)
- ui.removeTextArea(6969+id,name)
- ui.removeTextArea(7979+id,name)
- end
- for id=3939,3946 do
- ui.removeTextArea(id,name)
- ui.removeTextArea(6969+id,name)
- ui.removeTextArea(7979+id,name)
- end
- for id=2929,2936 do
- ui.removeTextArea(id,name)
- ui.removeTextArea(6969+id,name)
- ui.removeTextArea(7979+id,name)
- end
- end
- end
- function eventLoop(t,r)
- tfm.exec.addShamanObject(27, math.random(-5,810), math.random(20,380), 90, 800, 0)
- if t >= 1000 then
- name = jogadores[math.random(#jogadores)]
- if tfm.get.room.playerList[name] then
- x = tfm.get.room.playerList[name].x
- y = tfm.get.room.playerList[name].y
- if tfm.get.room.playerList[name].isFacingRight then
- tfm.exec.addShamanObject(26, x+math.random(-5,5), y+math.random(-10,10), 270, -800, 0)
- else
- tfm.exec.addShamanObject(26, x+math.random(-5,5), y+math.random(-10,10), 90, 800, 0)
- end
- end
- end
- if r < 1000 or vivos == 0 then
- str = ''
- str2 = ''
- for i,v in pairs(tfm.get.room.playerList) do
- if not v.isDead then
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- if str ~= '' then
- str=str..','..name
- str2 = "são"
- else
- str=name
- str2 = "é"
- end
- end
- end
- if str ~= '' then
- tfm.exec.chatMessage("<B><I><J>→ <VP>"..str.." "..str2.." o(s) vencedor(s).</J></I></B>")
- end
- tfm.exec.newGame(mapas[math.random(#mapas)])
- end
- end
- function eventPlayerDied(name)
- vivos=vivos-1;
- if vivos == 0 then
- tfm.exec.chatMessage("<B><J>→ Nimguém venceu.</J></B>")
- end
- delete = nil
- for i,v in pairs(jogadores) do
- if v == name then
- delete=i
- end
- end
- if delete ~= nil then
- table.remove(jogadores,delete)
- end
- end
- function eventPlayerWon(name)
- vivos=vivos-1;
- end
- function eventNewGame()
- tfm.exec.setGameTime(60)
- system.bindMouse(shaman,false)
- vivos = 0
- jogadores = {}
- for name,v in pairs(tfm.get.room.playerList) do
- table.insert(jogadores,name)
- vivos=vivos+1;
- end
- system.bindMouse(shaman,true)
- end
- function eventNewPlayer(name)
- p[name]={
- w=0,
- l=0,
- }
- tfm.exec.chatMessage("<CE>→ Bem-vindo ao Portals Attack.</CE><VP>→ Este minigame não está 100% concluido.</VP><VI>→ Veja os comandos com !commands.</VI>",name)
- end
- for all in pairs(tfm.get.room.playerList) do
- eventNewPlayer(all)
- end
- tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement