Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keys = {69}
- players={}
- morreu={}
- mapas={6879570,6879586,2173893,4392183,4569940,1870360,6880640}
- shopList = {
- {"Galinha",50,33,2},
- {"Flecha",120,35,3}
- }
- game = "<J>#Wars</J>"
- tempoMax = 1
- start=false
- timestart = 10
- vivos=0
- jogadores=0
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoTimeLeft(true)
- function eventPlayerLeft(name)
- jogadores=jogadores-1;
- end
- function eventNewPlayer(name)
- jogadores=jogadores+1;
- tfm.exec.chatMessage("<CH>Ξ</CH> <CE>Bem-vindo ao #wars</CE>",name)
- tfm.exec.chatMessage("<CH>Ξ</CH> <J>Para atirar pressione a tecla E</J>",name)
- tfm.exec.chatMessage("<CH>Ξ</CH> <J>Jogo desenvolvido por: <V>Contistente</V></J>",name)
- players[name] = {
- tempo = 0,
- moedas = 0,
- objeto = 34,
- balas = 30,
- maxBalas = 30,
- tmpBala = 0,
- recarga = 0,
- inventory={}
- }
- morreu[name] = true
- tfm.exec.lowerSyncDelay(name)
- ui.addTextArea(1,"<J><p align='center'>"..players[name].moedas.."</p></J>",name,5,20,nil,20,nil,0x6a8495,70,true)
- ui.addTextArea(2,"<p align='center'><J><a href='event:loja'>Loja</a></J></p>",name,5,350,nil,20,nil,0x6a8495,70,true)
- ui.addTextArea(5,"<p align='center'><J><a href='event:inventory'>Inventário</a></J></p>",name,5,380,nil,20,nil,0x6a8495,70,true)
- table.insert(players[name].inventory,{"Bola de Neve",34,1})
- 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)
- if jogadores >= 2 then
- for i in pairs(tfm.get.room.playerList) do
- if players[i].tmpBala > 0 then
- players[i].tmpBala = players[i].tmpBala-1;
- ui.addTextArea(7,"",i,750,370,40,20,0x1E90FF,0xFFF00C,70,true)
- if math.floor(players[i].tmpBala*2) < 5 then
- ui.addTextArea(8,"",i,750,370,40,20,0x40E0D0,0xFFF00C,70,true)
- else
- ui.addTextArea(8,"",i,750,370,math.floor(players[i].tmpBala*2),20,0x00BFFF,0xFFF00C,70,true)
- end
- elseif players[i].tmpBala == 0 and players[i].balas == 0 then
- ui.removeTextArea(7,i)
- ui.removeTextArea(8,i)
- players[i].balas = players[i].maxBalas
- players[i].recarga = 0
- end
- ui.addTextArea(1,"<J><p align='center'>"..players[i].moedas.."</p></J>",i,5,20,nil,20,nil,0x6a8495,70,true)
- if players[i].balas < 10 then
- ui.addTextArea(6,"<J><p align='center'><V>0"..players[i].balas.."</V><N>/</N>"..players[i].maxBalas.."</p></J>",i,730,30,nil,20,nil,0x6a8495,70,true)
- else
- ui.addTextArea(6,"<J><p align='center'><V>"..players[i].balas.."</V><N>/</N>"..players[i].maxBalas.."</p></J>",i,730,30,nil,20,nil,0x6a8495,70,true)
- end
- tfm.exec.setPlayerScore(i,players[i].moedas,false)
- if vivos == 1 then
- if not morreu[i] then
- newcoin = math.random(10,30)
- players[i].moedas = players[i].moedas+newcoin
- tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <BL>é o vencedor!.</BL>")
- tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..i.."</V> <J>recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>")
- tfm.exec.chatMessage("<CH>Ξ</CH> <J>Você recebeu <ROSE>+"..newcoin.."</ROSE> moedas.</J>", i)
- tfm.exec.newGame(mapas[math.random(#mapas)])
- end
- end
- end
- if not start and time >= 2000 then
- tfm.exec.setUIMapName("<J>Iniciando guerra em <V>"..timestart.."</V> segundos.</J>")
- if timestart > 0 then
- timestart = timestart-1;
- else
- start=true
- end
- else
- tfm.exec.setUIMapName(game)
- end
- for i in pairs(tfm.get.room.playerList) do
- if players[i].tempo > 0 then
- players[i].tempo = players[i].tempo-1;
- end
- end
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if (key==69) and players[name].tempo == 0 and start and not tfm.get.room.playerList[name].isDead and players[name].balas > 0 then
- if tfm.get.room.playerList[name].isFacingRight then
- id=tfm.exec.addShamanObject(players[name].objeto,x+14,y-10,0,70,0)
- else
- id=tfm.exec.addShamanObject(players[name].objeto,x-14,y-10,0,-70,0)
- end
- for i,v in pairs(players[name].inventory) do
- players[name].tempo = v[3]
- players[name].balas = players[name].balas-1;
- end
- end
- if (key==69) and players[name].balas == 0 and players[name].recarga == 0 then
- players[name].tmpBala = 20
- players[name].recarga = 1
- tfm.exec.chatMessage("<CH>Ξ</CH> <J>Suas munições acabaram.</J>",name)
- tfm.exec.chatMessage("<CH>Ξ</CH> <J>As munições do(a) <V>"..name.."</V> acabaram.</J>")
- end
- end
- function eventPlayerDied(name)
- morreu[name] = true
- vivos=vivos-1;
- tfm.exec.chatMessage("<CH>Ξ</CH> <V>"..name.."</V><BL> morreu.</BL>")
- end
- function eventNewGame()
- tfm.exec.setGameTime(300)
- tfm.exec.setUIMapName(game)
- tfm.exec.newGame(mapas[math.random(#mapas)])
- start=false
- timestart = 10
- vivos=0
- for i in pairs(tfm.get.room.playerList) do
- vivos=vivos+1;
- morreu[i] = false
- end
- end
- function eventTextAreaCallback(id, player, link)
- if link == "loja" then
- texto = '<B><p align="center"><font size="18"><J>Loja</J></font><br>[<V>Nome</V>][<J>Preço</J>][<ROSE>Botão</ROSE>]<br>'
- for i,v in pairs(shopList) do
- texto = texto..'<br>[<V>'..v[1]..'</V>][<J>'..v[2]..'</J>][<ROSE><a href="event:buy-'..v[1]..'">COMPRAR</a></ROSE>]'
- end
- ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(4,"<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 == "fechar-loja" then
- ui.removeTextArea(3,player)
- ui.removeTextArea(4,player)
- elseif link == "inventory" then
- texto = '<B><p align="center"><font size="18"><J>Inventário</J></font><br>[<V>Nome</V>][<CE>Tempo de Tiro</CE>][<ROSE>Botão</ROSE>]<br>'
- for i,v in pairs(players[player].inventory) do
- if v[2] == players[player].objeto then
- texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<J>Equipado</J>]'
- else
- texto = texto..'<br>[<V>'..v[1]..'</V>][<CE>'..v[3]..'</CE>][<ROSE><a href="event:equip-'..v[1]..'">Equipar</a></ROSE>]'
- end
- end
- ui.addTextArea(3,texto,player,300,50,300,300,nil,0x6a8495,70,true)
- ui.addTextArea(4,"<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)
- end
- for i,v in pairs(shopList) do
- if link == "buy-"..v[1] then
- if players[player].moedas >= v[2] then
- ui.addTextArea(3,"<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(4,"<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)
- players[player].moedas = players[player].moedas-v[2]
- table.insert(players[player].inventory, {v[1],v[3],v[4]})
- else
- ui.addTextArea(3,"<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(4,"<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)
- end
- end
- end
- for i,v in pairs(players[player].inventory) do
- if link == "equip-"..v[1] then
- players[player].objeto = v[2]
- ui.addTextArea(3,"<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(4,"<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)
- end
- end
- end
- tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement