Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ballua
- -- Créditos:Brenower
- -- Tables
- data={}
- mg={
- ["baloes"]=0;
- ["ids"]=100;
- ["sta"]=false;
- ["time"]=os.time();
- maps={0,4560949,4701122,4701807,4701827};
- dif1={0};
- dif2={4701827,4701807,4701122};
- dif3={4560949,4788077};
- };
- lang={
- EN={
- ["d1"]="Easy";
- ["d2"]="Medium";
- ["d3"]="Hard";
- ["we"]="<J>Wellcome to minigame <v>ballua<j>!";
- };
- BR={
- ["d1"]="Fácil";
- ["d2"]="Medio";
- ["d3"]="Difícil";
- ["we"]="<J>Bem vindo ao minigame <v>ballua<j>!";
- };
- };
- -- Functions
- function giveData(p)
- if not data[p] then
- nD={
- ["baloes"]=0;
- ["pontos"]=0;
- ["vy"]=0;
- ["id"]=nil;
- ["trans"]=false;
- ["time"]=os.time();
- ["t"]=0;
- ["q"]=false;
- };
- data[p]=nD;
- mg.ids=mg.ids+1;
- data[p].t=mg.ids;
- end
- end
- function mapLevel(map)
- map = tonumber(map:sub(2))
- for i,v in pairs(mg.dif1) do
- if tonumber(v) == map then
- tfm.exec.setUIMapName("<CH>"..trans("d1").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
- end
- end
- for i,v in pairs(mg.dif2) do
- if tonumber(v) == map then
- tfm.exec.setUIMapName("<CH>"..trans("d2").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
- end
- end
- for i,v in pairs(mg.dif3) do
- if tonumber(v) == map then
- tfm.exec.setUIMapName("<CH>"..trans("d3").." <BL>- "..tfm.get.room.currentMap.." - <J>"..tfm.get.room.xmlMapInfo.author)
- end
- end
- end
- function trans(msg,sender)
- if lang[tfm.get.room.community] then
- msg = lang[tfm.get.community][msg]
- else
- msg = lang.EN[msg]
- end
- if sender then
- msg = msg:format(sender[1],sender[2],sender[3],sender[4],sender[5],sender[6],sender[7],sender[8],sender[9],sender[10])
- end
- return msg
- end
- -- Novo jogador entra na sala
- function eventNewPlayer(p)
- tfm.exec.chatMessage(trans("we"),p)
- giveData(p)
- tfm.exec.bindKeyboard(p,32,false,true)
- tfm.exec.bindKeyboard(p,40,false,true)
- ui.addTextArea(30,"",nil,-20,-425,300,300,0x6a7495,0x6a7495,1,true)
- end
- -- Inicio do script
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
- for i in pairs(tfm.get.room.playerList) do
- eventNewPlayer(i)
- end
- -- Eventos do teclado
- function eventKeyboard(p,key,down,x,y)
- if not tfm.get.room.playerList[p].isDead and mg.sta == true and data[p].time < os.time()-1600 then
- if data[p].trans == false then
- id=tfm.exec.addShamanObject(28,x,y,0,0,0,true)
- data[p].trans=true;
- data[p].id=id;
- ui.addTextArea(data[p].t,"<font size='17'color='#000000' face='Soopafresh,Verdana'><I>ballua!</I></font>",nil,x-25,y,100,50,0,0,0)
- ui.addTextArea(data[p].t+500,"<font size='17'color='#1C8484' face='Soopafresh,Verdana'><I>ballua!</I></font>",nil,x-25+2,y-1,100,50,0,0,0)
- data[p].time=os.time();
- else
- data[p].trans=false;
- ui.removeTextArea(data[p].t+250,nil)
- tfm.exec.movePlayer(p,tfm.get.room.objectList[data[p].id].x,tfm.get.room.objectList[data[p].id].y,false,0,-25)
- tfm.exec.removeObject(data[p].id)
- data[p].time=os.time();
- end
- end
- end
- -- Loop
- function eventLoop(ct,rt)
- for i in pairs(data) do
- if data[i].trans == true then
- tfm.exec.movePlayer(i,30,-200,false,0,-100)
- end
- if data[i].time < os.time()-1500 then
- ui.removeTextArea(data[i].t,nil)
- ui.removeTextArea(data[i].t+500,nil)
- if data[i].trans == true then
- ui.addTextArea(data[i].t+250,i,nil,tfm.get.room.objectList[data[i].id].x-30,tfm.get.room.objectList[data[i].id].y,nil,nil,1,1,0.3)
- end
- end
- end
- if rt <= 0 then
- tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
- end
- if mg.time < os.time()-3000 then
- mg.sta=true;
- end
- end
- -- Jogador morre
- function eventPlayerDied(p)
- data[p].time=os.time();
- tfm.exec.respawnPlayer(p)
- if data[p].trans == true and data[p].q == true then
- tfm.exec.movePlayer(p,30,-200,false,0,-100)
- tfm.exec.giveCheese(p)
- end
- end
- -- Jogador pega o queijo
- function eventPlayerGetCheese(p)
- data[p].q=true;
- end
- -- Novo jogo inicia-se
- function eventNewGame()
- tfm.exec.setGameTime(63)
- mapLevel(tfm.get.room.currentMap)
- mg.time=os.time();
- mg.sta=false;
- for i in pairs(data) do
- data[i].trans=false;
- data[i].q=false;
- ui.removeTextArea(data[i].t+250,nil)
- end
- end
- -- Jogador ganha a partida
- function eventPlayerWon(p)
- local v = 0;
- for i in pairs(tfm.get.room.playerList) do
- if not tfm.get.room.playerList[i].isDead then
- v=v+1;
- end
- end
- if v == 0 then
- tfm.exec.newGame(mg.maps[math.random(#mg.maps)])
- end
- end
- -- Comandos
- function eventChatCommand(p,cm)
- if p == [[Brenower]] then
- if cm:sub(1) == [[c]] then
- tfm.exec.chatMessage("<R>• <b>"..p.."</b> : <j>"..cm:sub(3))
- end
- if cm:sub(2) == [[np]] then
- tfm.exec.newGame(cm:sub(4))
- end
- end
- if cm == [[help]] then
- tfm.exec.chatMessage("<R>ERROR",p)
- end
- if cm == [[noob]] then
- tfm.exec.chatMessage("<J>PR0 :P",p)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment