Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keys={69,32,27}
- players={}
- data={}
- ids={}
- mapas={6879570,6879586,2173893,4392183,4569940,1870360,6882237,6882094,6883595}
- shop={
- {"Bolinha Rosa",10,97,80},
- {"Bola de Papel",35,95,70},
- {"Galinha",75,33,50},
- {"Abóbora",100,89,60},
- {"Baiacu",250,65,40},
- {"Flecha",1000,35,30},
- }
- maxPStatus = 6
- maxPMoney = 4
- maxPRoom = 20
- maxBalas = 50
- vivos=0
- jogadores=0
- 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] == "p" then -- se o comando for p
- if arg[2] then -- se tiver o nome de alguem
- local nome = arg[2]:lower():gsub('%a', string.upper, 1) -- guarda na variavel
- --nome:lower():gsub('%a', string.upper, 1)
- if tfm.get.room.playerList[nome] then -- se tiver na sala (retornaria nil se n tivesse)
- perfil="<p align='center'><font size='16'><J>"..nome.."</J></font><br><font size='12'><N>Rodadas: <V>"..players[nome].rounds.."</V><br>Vitórias: <V>"..players[nome].wins.."</V><br>Mortes: <V>"..players[nome].kills.."</V><br>Moedas: <V>"..players[nome].moedas.."</V>"
- end
- else -- se ele só escreveu !p mostrar o perfil dele mesmo
- perfil="<p align='center'><font size='16'><J>"..p.."</J></font><br><font size='12'><N>Rodadas: <V>"..players[p].rounds.."</V><br>Vitórias: <V>"..players[p].wins.."</V><br>Mortes: <V>"..players[p].kills.."</V><br>Moedas: <V>"..players[p].moedas.."</V>"
- end
- ui.addTextArea(36,'<a href="event:perfilClose"><font color="#ff0000">Fechar</font></a>',p,250,102,60,nil,nil,0x6a8495,1,true)
- ui.addTextArea(35,perfil,p,300,100,300,140,nil,0x6a8495,1,true)
- end
- end
- for _,f in pairs ({'disableAutoNewGame','disableAutoShaman','disableAutoTimeLeft','disableAutoScore'}) do
- tfm.exec[f](true)
- end
- function nextRound()
- tfm.exec.newGame(mapas[math.random(#mapas)])
- end
- function eventNewGame()
- vivos=0
- tfm.exec.setGameTime(100)
- for name in pairs(tfm.get.room.playerList) do
- vivos=vivos+1;
- if jogadores >= maxPStatus then
- players[name].rounds = players[name].rounds+1;
- end
- if players[name].balas < 10 then
- ui.addTextArea(6,"<B><J><p align='center'><V>0"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- else
- ui.addTextArea(6,"<B><J><p align='center'><V>"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- end
- end
- end
- function eventPlayerLeft(name)
- jogadores=jogadores-1;
- end
- function eventNewPlayer(name)
- for i,v in pairs ({"<CE>Bem-vindo %s ao #wars</CE>","<J>Para atirar pressione a tecla E ou Espaço, O ultimo vivo ganha.</J>","<R>É necessário "..maxPMoney.." jogadores para contar moedas e "..maxPStatus.." para estátisticas.</R>","<J>Jogo desenvolvido por: <V>Contistente</V></J>"}) do
- tfm.exec.chatMessage(v:format(name),name)
- end
- if jogadores == 1 then
- nextRound()
- end
- jogadores=jogadores+1;
- players[name]={
- objeto={"Bola de Neve",34,80},
- tempo=0,
- timestamp=os.time(),
- width=0,
- moedas=0,
- balas=maxBalas,
- rounds=0,
- kills=0,
- message=false,
- wins=0,
- inventory={}
- }
- object = true
- for i,v in pairs(data) do
- if v[1] == name then
- players[name] = v[2]
- object = false
- end
- end
- if object then
- table.insert(players[name].inventory,{"Bola de Neve",34,80})
- end
- table.insert(data,{name, players[name]})
- tfm.exec.setPlayerScore(name,players[name].moedas,false)
- ui.addTextArea(0,"",name,6,320,100,80,nil,0x6a8495,80,true)
- ui.addTextArea(1,"<J><B><p align='center'>"..players[name].moedas.."</p></J>",name,6,350,100,20,nil,0x6a8495,90,true)
- ui.addTextArea(2,"<J><B><p align='center'>"..players[name].objeto[1].."</p></J>",name,6,320,100,20,nil,0x6a8495,90,true)
- ui.addTextArea(3,"<J><B><p align='center'><a href='event:menu'>Menu</a></p></J>",name,6,28,94,20,nil,0x6a8495,80,true)
- for i,v in pairs(keys) do
- tfm.exec.bindKeyboard(name,v,true)
- end
- end
- for all in pairs(tfm.get.room.playerList) do
- eventNewPlayer(all)
- end
- function eventLoop(time,remaining)
- tempo = time
- if remaining < 1000 or vivos == 0 then
- nextRound()
- if vivos == 0 then
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <J>Nenhum ratinho venceu, todos morreram.</J>")
- else
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <J>Nenhum ratinho venceu, o tempo acabou.</J>")
- end
- end
- for i,pi in pairs(tfm.get.room.playerList) do
- if vivos == 1 and jogadores >= 2 then
- tfm.exec.giveCheese(i)
- tfm.exec.playerVictory(i)
- end
- if players[i].balas == 0 then
- if not players[i].message then
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <J>As munições de "..i.." acabaram.</J>")
- players[i].message = true
- end
- eventKeyboard(i,69,nil,pi.x,pi.y)
- players[i].width = players[i].width+10;
- ui.addTextArea(7,"",i,600,380,180,10,0x363636,0x6a8495,70,true)
- ui.addTextArea(8,"",i,600,380,players[i].width,10,0x1C1C1C,0x6a8495,70,true)
- else
- ui.removeTextArea(8,i)
- ui.removeTextArea(7,i)
- players[i].width = 0
- end
- end
- end
- function eventPlayerWon(name)
- nextRound()
- if jogadores >= maxPMoney then
- players[name].moedas = players[name].moedas+math.random(10,40);
- tfm.exec.setPlayerScore(name,players[name].moedas,false)
- ui.addTextArea(1,"<J><B><p align='center'>"..players[name].moedas.."</p></J>",name,6,350,100,20,nil,0x6a8495,90,true)
- end
- if jogadores >= maxPStatus then
- players[name].wins = players[name].wins+1;
- end
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <V>"..name.."</V><BL> é o vencedor.</BL>")
- end
- function eventPlayerDied(name)
- vivos=vivos-1;
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <V>"..name.."</V><BL> morreu.</BL>")
- if jogadores >= maxPStatus then
- players[name].kills = players[name].kills+1;
- end
- end
- function eventKeyboard(name,key,down,x,y)
- if (key==69 or key==32) and not tfm.get.room.playerList[name].isDead and tempo >= 6000 and players[name].balas > 0 then
- if players[name].timestamp < os.time()-300 then
- local id
- if tfm.get.room.playerList[name].isFacingRight then
- id=tfm.exec.addShamanObject(players[name].objeto[2],x+15,y-10,0,players[name].objeto[3],0)
- id=tfm.exec.addShamanObject(players[name].objeto[2],x+15,y-10,0,players[name].objeto[3],0)
- else
- id=tfm.exec.addShamanObject(players[name].objeto[2],x-15,y-10,0,-players[name].objeto[3],0)
- id=tfm.exec.addShamanObject(players[name].objeto[2],x-15,y-10,0,-players[name].objeto[3],0)
- end
- players[name].balas = players[name].balas-1;
- if players[name].balas < 10 then
- ui.addTextArea(6,"<B><J><p align='center'><V>0"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- else
- ui.addTextArea(6,"<B><J><p align='center'><V>"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- end
- players[name].timestamp=os.time()
- end
- end
- if (key==69) and players[name].balas == 0 then
- if players[name].timestamp < os.time()-9000 then
- players[name].balas = maxBalas
- players[name].timestamp=os.time()
- tfm.exec.chatMessage("<N>[<CE>Ξ</CE>]</N> <J>As munições de "..name.." foram recarregadas.</J>")
- players[name].message = false
- if players[name].balas < 10 then
- ui.addTextArea(6,"<B><J><p align='center'><V>0"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- else
- ui.addTextArea(6,"<B><J><p align='center'><V>"..players[name].balas.."</V><N>/</N>"..maxBalas.."</p></J>",name,6,380,100,20,nil,0x6a8495,90,true)
- end
- players[name].timestamp=os.time()
- end
- end
- end
- function eventTextAreaCallback(id, player, link)
- if link == "loja" then
- y = 15
- id = 400
- table.insert(ids,id)
- local title = "<p align='center'><font size='18'><J>Loja</J></font><br>"
- ui.addTextArea(9,title,player,150,30,500,350,nil,0x6a8495,70,true)
- ui.addTextArea(10,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
- str = "<N><J>Nome</J> | <V>Preço</V> | <ROSE>Botão</ROSE></N><br>"
- ui.addTextArea(id,str,player,200,y+45,400,20,nil,0x6a8495,70,true)
- for i,v in pairs(shop) do
- y=y+30
- id=id+1;
- table.insert(ids,id)
- for i,v2 in pairs(players[player].inventory) do
- if v2[1] == v[1] then
- str = "<N><J>"..v[1].."</J> | <V>"..v[2].."</V> | <CE>COMPRADO</CE></N><br>"
- ui.addTextArea(id,str,player,200,y+45,400,20,nil,0x6a8495,70,true)
- else
- str = "<N><J>"..v[1].."</J> | <V>"..v[2].."</V> | <ROSE><a href='event:buy-"..v[1].."'>COMPRAR</a></ROSE></N><br>"
- ui.addTextArea(id,str,player,200,y+45,400,20,nil,0x6a8495,70,true)
- end
- end
- end
- ui.addTextArea(10,"<B><p align='center'><font color='#ff0000'><a href='event:fechar-loja'>Fechar</a></font></p>",player,150,360,500,20,nil,0x6a8495,70,true)
- elseif link == "fechar-loja" then
- ui.removeTextArea(9,player)
- ui.removeTextArea(10,player)
- ui.removeTextArea(11,player)
- ui.removeTextArea(12,player)
- for index,v in pairs(ids) do
- ui.removeTextArea(v,player)
- end
- elseif link == "inventory" then
- texto = '<B><p align="center"><font size="18"><J>Inventário</J></font><br>[<V>Nome</V>][<ROSE>Botão</ROSE>]<br>'
- for i,v in pairs(players[player].inventory) do
- if v[2] == players[player].objeto[2] then
- texto = texto..'<br>[<V>'..v[1]..'</V>][<J>Equipado</J>]'
- else
- texto = texto..'<br>[<V>'..v[1]..'</V>][<ROSE><a href="event:equip-'..v[1]..'">Equipar</a></ROSE>]'
- end
- end
- ui.addTextArea(9,texto,player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(10,"<a href='event:fechar-loja'><p align='center'><font color='#ff0000'><B>Fechar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
- elseif link == "ranking" then
- eventRanking(player)
- elseif link == "menu" then
- ui.addTextArea(18,"",player,6,28,94,200,nil,0x6a8495,80,true)
- ui.addTextArea(3,"<V><B><p align='center'><a href='event:menu-close'>Menu</a></p></V>",player,6,28,94,20,nil,0x6a8495,80,true)
- ui.addTextArea(20,"<J><B><p align='center'><a href='event:loja'>Loja</a></p></J>",player,6,60,94,20,nil,0x6a8495,80,true)
- ui.addTextArea(21,"<J><B><p align='center'><a href='event:inventory'>Inventário</a></p></J>",player,6,90,94,20,nil,0x6a8495,80,true)
- ui.addTextArea(22,"<J><B><p align='center'><a href='event:ranking'>Ranking</a></p></J>",player,6,120,94,20,nil,0x6a8495,80,true)
- ui.addTextArea(49,"<J><B><p align='center'><a href='event:perfil'>Perfil</a></p></J>",player,6,150,94,20,nil,0x6a8495,80,true)
- elseif link == "menu-close" then
- ui.removeTextArea(18,player)
- ui.removeTextArea(20,player)
- ui.removeTextArea(21,player)
- ui.removeTextArea(22,player)
- ui.removeTextArea(49,player)
- ui.addTextArea(3,"<J><B><p align='center'><a href='event:menu'>Menu</a></p></J>",player,6,28,94,20,nil,0x6a8495,80,true)
- elseif link == "ranking-close" then
- ui.removeTextArea(44,player)
- ui.removeTextArea(45,player)
- for index,v in pairs(ids) do
- ui.removeTextArea(v,player)
- end
- id = 50
- elseif link == "perfilClose" then
- ui.removeTextArea(35,player)
- ui.removeTextArea(36,player)
- elseif link == "perfil" then
- eventChatCommand(player, "p")
- end
- for i,v in pairs(shop) do
- if link == "buy-"..v[1] then
- for index,v in pairs(ids) do
- ui.removeTextArea(v,player)
- end
- if players[player].moedas >= v[2] then
- ui.addTextArea(9,"<J><B><p align='center'>Você comprou um(a) "..v[1].." com sucesso por <ROSE>-"..v[2].."</ROSE> moedas</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(10,"<a href='event:loja'><p align='center'><font color='#ffcc00'><B>Voltar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
- players[player].moedas = players[player].moedas-v[2]
- table.insert(players[player].inventory, {v[1],v[3],v[4]})
- tfm.exec.setPlayerScore(player,players[player].moedas,false)
- ui.addTextArea(1,"<J><B><p align='center'>"..players[player].moedas.."</p></J>",player,6,350,100,20,nil,0x6a8495,90,true)
- else
- ui.addTextArea(9,"<J><B><p align='center'>Você não tem moedas suficientes.</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(10,"<a href='event:loja'><p align='center'><font color='#ffcc00'><B>Voltar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
- end
- end
- end
- for i,v in pairs(players[player].inventory) do
- if link == "equip-"..v[1] then
- players[player].objeto = {v[1],v[2],v[3]}
- ui.addTextArea(9,"<J><B><p align='center'>Você equipou a(o) "..v[1].." para atirar.</p></B></J>",player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(10,"<a href='event:inventory'><p align='center'><font color='#ffcc00'><B>Voltar</B></font></p></a>",player,300,350,300,20,nil,0x6a8495,70,true)
- ui.addTextArea(2,"<J><B><p align='center'>"..players[player].objeto[1].."</p></J>",player,6,320,100,20,nil,0x6a8495,90,true)
- end
- 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,m=players[name].moedas,w=players[name].wins,k=players[name].kills}
- end
- table.sort(sc,function(a,b) return a.w>b.w end)
- y = 15
- id = 50
- local str = ""
- local title = "<p align='center'><font size='18'><J>Ranking</J></font><br>"
- ui.addTextArea(44,title,name,150,30,500,350,nil,0x6a8495,70,true)
- for k,v in pairs(sc) do
- if k < 11 then
- id = id+1;
- table.insert(ids, id)
- y = y+30
- str = "<N><J>"..k.."</J>. | <V>"..v.n.."</V> | Rodadas: <V>"..players[v.n].rounds.."</V> | Moedas: <V>"..v.m.."</V> | Vitórias: <V>"..v.w.."</V> | Mortes: <V>"..v.k.."</V></N><br>"
- if id < 60 then
- ui.addTextArea(id,str,name,170,y+40,460,20,nil,0x6a8495,70,true)
- end
- end
- end
- ui.addTextArea(45,"<B><p align='center'><font color='#ff0000'><a href='event:ranking-close'>Fechar</a></font></p>",name,150,360,500,20,nil,0x6a8495,70,true)
- return str
- end
- tfm.exec.setRoomMaxPlayers(maxPRoom)
- nextRound()
Add Comment
Please, Sign In to add comment