Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admins={Miiiclaroo=true,Newwthejbk=true}
- count = 0
- locations={
- {[1]={579,180},
- [2]={157,180}},
- {[1]={350,210},
- [2]={640,200},
- [3]={100,200}},
- {[1]={400,95},
- [2]={393,216},
- [3]={398,338}},
- {[1]={400,330},
- [2]={400,170}},
- {[1]={688,315},
- [2]={97,318}},
- {[1]={389,169},
- [2]={387,317},
- [3]={591,349},
- [4]={190,347}}
- }
- local maps = {
- '<C><P /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="32" H="31" Y="213" T="0" X="371" /><S P="0,0,0,0.2,0,0,0,0" L="33" H="29" Y="113" T="1" X="577" /><S L="33" X="580" H="29" Y="342" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="33" X="373" H="29" Y="316" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="33" X="168" H="29" Y="337" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="33" X="370" H="29" Y="115" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="33" X="157" H="29" Y="115" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="32" X="268" H="31" Y="270" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="478" H="31" Y="273" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="374" H="31" Y="404" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="580" H="31" Y="217" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="161" H="31" Y="210" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="266" H="31" Y="154" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="32" X="475" H="31" Y="150" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="186" X="370" /></D><O /></Z></C>',
- --arriba mapas de zax
- '<C><P /><Z><S><S L="45" H="34" X="356" Y="110" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="355" H="34" Y="230" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="355" H="34" Y="350" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" H="34" X="640" Y="230" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" H="34" X="640" Y="110" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="640" H="34" Y="350" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="100" H="34" Y="230" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="100" H="34" Y="110" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="45" X="100" H="34" Y="350" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="26" X="225" H="23" Y="170" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="26" H="23" X="497" Y="170" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="26" H="23" X="225" Y="300" T="1" P="0,0,0,0.2,0,0,0,0" /><S L="26" X="497" H="23" Y="300" T="1" P="0,0,0,0.2,0,0,0,0" /></S><D><DS Y="76" X="357" /></D><O /></Z></C>',
- '<C><P /><Z><S><S L="406" X="400" H="23" Y="120" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="406" H="23" X="400" Y="240" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="406" H="23" X="399" Y="360" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="95" X="663" H="10" Y="320" T="1" P="0,0,0,0.2,-45,0,0,0" /><S L="95" H="10" X="135" Y="320" T="1" P="0,0,0,0.2,45,0,0,0" /><S L="95" X="118" H="10" Y="180" T="1" P="0,0,0,0.2,45,0,0,0" /><S L="95" H="10" X="680" Y="180" T="1" P="0,0,0,0.2,-45,0,0,0" /></S><D><DS Y="92" X="401" /></D><O /></Z></C>',
- '<C><P /><Z><S><S L="330" H="20" X="400" Y="200" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="330" X="400" H="20" Y="350" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="176" X="399" /></D><O /></Z></C>',
- '7062433'
- }
- paginas={
- "<b>Teclas</b><br>- espacio : disparas una bolita de nieve suculenta<br>- M : congelas a un jugador cercano",
- "<b>comandos</b><br>- !p [nombre del jugador] para ver su perfil",
- "<b>info para ocupar espacio</b><br><b>creador del juego:</b> <j>Miiiclaroo</j>"
- }
- k={
- type = 8,
- width = 120,
- height = 120,
- friction = 1,
- restitution = 0,
- miceCollision =false,
- groundCollision = false
- }
- local currentMap
- local playersAlive
- dataTitlesW={
- {"pro",100},
- {"invencible",1000},
- {"frozen Balls",500}
- }
- dataTitlesM={
- {"noob",20},
- {"frozen mouse",10}
- }
- mice={}
- dataPlayer= {
- }
- gunActive=false
- gun=0
- local gunx,guny = 400,200
- contador=0
- FC=false
- equipo={azul={},rojo={}}
- lastId=0
- isBanned={}
- gameContador=0
- gameFinished = false
- -------------------
- despawnTime = 2500
- fireDelay = 750
- offsetX = 0
- offsetY = 0
- -----------------------
- keys = {0,2,32,112,77}
- _left = 0
- _right = 2
- facingLeft = {}
- toDespawn = {}
- fireTS = {}
- ------------
- function main()
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoTimeLeft (true)
- tfm.exec.disableAutoScore (true)
- startGame()
- for n in pairs(tfm.get.room.playerList) do
- eventNewPlayer(n)
- end
- end
- function eventNewPlayer(name)
- lastId=lastId+1
- if not mice[name] then
- mice[name]={[1]=0,[2]=0,[3]=false,id=lastId,title="rata congelada",frozed=false,x=0,y=0,frozedTime=0,frozen=3,contador=0,Icontador=0,on=false,pa=1}
- end
- if not dataPlayer[name] then
- dataPlayer[name]={}
- elseif dataPlayer[name] then
- mice[name][1]=dataPlayer[name][1]
- mice[name][2]=dataPlayer[name][2]
- mice[name].title=dataPlayer[name].title
- end
- if isBanned[name] then
- ui.addTextArea(mice[name].id+200,"",name,-50,-50,900,450)
- ui.addTextArea(mice[name].id-200,"<p align = 'center'>has sido baneado",name,-50,-50,900,450)
- end
- facingLeft[name] = false
- fireTS[name] = 0
- for _,k in pairs(keys) do
- system.bindKeyboard(name, k, true)
- end
- ui.addTextArea(mice[name].id+1000,"<b><font size='20'><font color='#FFFFFF'>Hola "..name.." bienvenido a </font><font color='#FFDD00'>SnowBall War</font>",name,160,200,0,0,0)
- mice[name].on=true
- ui.addTextArea(mice[name].id+2000,"<b><font size='20'><font color='#FFFFFF'>escribe </font><font color='#FF0500'>!help</font><font color='#FFFFFF'> para más info.",name,260,240,0,0,0)
- end
- function startGame()
- local newMap
- repeat
- newMap = math.random(#maps)
- until newMap ~= currentMap
- currentMap = newMap
- tfm.exec.newGame(maps[newMap])
- for n in pairs (tfm.get.room.playerList)do
- if maps[newMap] == maps[1] then
- tfm.exec.movePlayer(n,locations[1][math.random(#locations[1])][1],locations[1][math.random(#locations[1])][2])
- elseif maps[newMap] == maps[2] then
- tfm.exec.movePlayer(n,locations[2][math.random(#locations[2])][1],locations[2][math.random(#locations[2])][2])
- elseif maps[newMap] == maps[3] then
- tfm.exec.movePlayer(n,locations[3][math.random(#locations[3])][1],locations[3][math.random(#locations[3])][2])
- elseif maps[newMap] == maps[4] then
- tfm.exec.movePlayer(n,locations[4][math.random(#locations[4])][1],locations[4][math.random(#locations[4])][2])
- elseif maps[newMap] == maps[5] then
- tfm.exec.movePlayer(n,locations[5][math.random(#locations[5])][1],locations[5][math.random(#locations[5])][2])
- end
- end
- end
- function endGame()
- gameFinished = true
- tfm.exec.setGameTime(5)
- end
- function eventNewGame()
- count = count+1
- if count == 5 then
- for n in pairs(tfm.get.room.playerList)do
- tfm.exec.lowerSyncDelay(n)
- end
- count = 0
- end
- for n in pairs (mice) do
- mice[n].frozedTime = 0
- mice[n].frozen = 3
- mice[n].x = 0
- mice[n].y = 0
- if isBanned[n] then
- tfm.exec.killPlayer(n)
- end
- end
- gameFinished=false
- tfm.exec.snow(1,70)
- playersAlive = 0
- for _ in pairs(tfm.get.room.playerList) do
- playersAlive = playersAlive + 1
- end
- for name in pairs (mice) do
- mice[name][3]=true
- end
- contador=0
- end
- function eventPlayerRespawn(name)
- if mice[name].frozed then
- tfm.exec.movePlayer(name,mice[name].x,mice[name].y,false)
- mice[name][3] = true
- mice[name].frozed = false
- elseif not mice[name].frozed then
- playersAlive = playersAlive + 1
- mice[name][3] = true
- if isBanned[name]then
- tfm.exec.killPlayer(name)
- end
- end
- end
- function eventPlayerDied(name)
- if mice[name].frozed then
- mice[name][3]=false
- elseif not mice[name].frozed then
- playersAlive = playersAlive - 1
- checkPlayers()
- mice[name][1]=mice[name][1]+1
- mice[name][3]=false
- checkTitle(name)
- end
- end
- function eventPlayerLeft(name)
- dataPlayer[name][1]=mice[name][1]
- dataPlayer[name][2]=mice[name][2]
- dataPlayer[name].title=mice[name].title
- end
- function eventPlayerWon(name)
- playersAlive = playersAlive - 1
- checkPlayers()
- mice[name][2]=mice[name][2]+1
- checkTitle(name)
- end
- function checkPlayers()
- if playersAlive == 0 then
- endGame()
- end
- if playersAlive == 1 then
- for name in pairs (mice) do
- if mice[name].frozed then
- tfm.exec.respawnPlayer(name)
- mice[name].frozed=false
- end
- tfm.exec.giveCheese(name)
- endGame()
- end
- end
- end
- function eventPlayerGetCheese(name)
- tfm.exec.playerVictory(name)
- end
- function eventLoop(t, tr)
- for name in pairs (tfm.get.room.playerList) do
- if mice[name].frozed then
- mice[name].contador = mice[name].contador + 1
- end
- if mice[name].contador == 6 then
- tfm.exec.respawnPlayer(name)
- mice[name].contador = 0
- end
- if mice[name].on then
- mice[name].Icontador=mice[name].Icontador+1
- if mice[name].Icontador == 10 then
- ui.removeTextArea(mice[name].id+1000)
- ui.removeTextArea(mice[name].id+2000)
- mice[name].on=false
- mice[name].Icontador=0
- end
- end
- end
- if gunActive then
- gun=gun+1
- if gun == 10 then
- tfm.exec.removePhysicObject(0)
- gun = 0
- gunActive = false
- end
- end
- if contador <12 then
- contador = contador+1
- FC=false
- end
- if contador >= 12 then
- FC=true
- end
- if not gameFinished and tr <= 0 then
- endGame()
- elseif gameFinished and tr <= 0 then
- startGame()
- end
- for i,o in ipairs(toDespawn) do
- if os.time() > o[2]+despawnTime then
- tfm.exec.removeObject (o[1])
- table.remove (toDespawn, i)
- end
- end
- end
- function eventKeyboard(name, key, down, px, py)
- if key == _left then
- facingLeft[name] = true
- elseif key == _right then
- facingLeft[name] = false
- elseif key==32 and os.time() > fireTS[name] + fireDelay then
- local m = mice[name]
- local dx,a,id
- if px > gunx-60 and px < gunx+60 and py > guny-60 and py < guny+60 and gunActive then
- if facingLeft[name] then
- dx,dy,a,f = -30,0,-90,5
- else
- dx,dy,a,f = 30,0,90,-5
- end
- else
- if facingLeft[name] then
- dx,dy,a,f = -30,0,-90,-12
- else
- dx,dy,a,f = 30,0,90,12
- end
- end
- if FC then
- if mice[name][3] then
- fireTS[name] = os.time()
- id = tfm.exec.addShamanObject(34, px+dx+offsetX, py+offsetY, a,f)
- table.insert(toDespawn, {id, os.time()})
- end
- end
- end
- if key == 112 and not gunActive and mice[name][3] and FC then
- gunx = px
- guny = py
- tfm.exec.addPhysicObject (0,gunx, guny, k )
- gunActive=true
- end
- if key == 77 then
- if mice[name].frozen > 0 and FC and mice[name][3] and not mice[name].frozed then
- for n,mouse in pairs(tfm.get.room.playerList) do
- local x,y = mouse.x, mouse.y
- if px > x-60 and px < x+60 and py > y-60 and py < y+60 then
- if name ~= n and not mice[n].frozed and mice[n][3] then
- mice[name].frozen = mice[name].frozen - 1
- mice[n].frozed=true
- tfm.exec.killPlayer(n)
- mice[n].x=x
- mice[n].y=y
- fireTS[n] = os.time()
- id = tfm.exec.addShamanObject(54,x,y)
- table.insert(toDespawn, {id, os.time()})
- for i = -20,20 do
- tfm.exec.displayParticle(9,x,y-i,0.5,0)
- tfm.exec.displayParticle(9,x,y-i,-0.5,0)
- tfm.exec.displayParticle(9,x-i,y,0.5,0.5)
- tfm.exec.displayParticle(9,x-i,y,0,-0.5)
- tfm.exec.displayParticle(9,x-i,y-i,0.5,-0.5)
- tfm.exec.displayParticle(9,x-i,y+i,-0.5,-0.5)
- tfm.exec.displayParticle(9,x-i,y-i,-0.5,0.5)
- tfm.exec.displayParticle(9,x-i,y+i,0.5,0.5)
- end
- break
- end
- end
- end
- end
- end
- end
- function eventChatCommand(name,command)
- local a={}
- for i in command:gmatch ('[^%s]+') do
- table.insert(a,i)
- end
- if a[1] == "ban" then
- if a[2] then
- if admins[name] then
- tfm.exec.killPlayer(a[2])
- isBanned[a[2]]=true
- ui.addTextArea(mice[a[2]].id+200,"",a[2],-50,-50,900,450)
- ui.addTextArea(mice[a[2]].id-200,"<p align = 'center'>has sido baneado",a[2],300,200)
- end
- end
- elseif a[1] == "unban" then
- if isBanned[a[2]] then
- if admins[name] then
- isBanned[a[2]] = false
- ui.removeTextArea(mice[a[2]].id+200)
- ui.removeTextArea(mice[a[2]].id-200)
- end
- end
- end
- if a[1]=="p" then
- if mice[a[2]] then
- ui.addTextArea(mice[name].id-200,"<a href= 'event:close'>X<a/>",name,465,175,0,0,0xFF1000)
- ui.addTextArea(mice[name].id-100,"<j><b><font size= '14'>"..a[2].."</font></b>",name,300,175,160,0,0,1)
- ui.addTextArea(mice[name].id,"<b><j>título: </j></b>"..mice[a[2]].title.."<br><b><j>muertes: </b></j>"..mice[a[2]][1].."<br><b><j>veces ganadas: </b></j>"..mice[a[2]][2].."",name,300,200,160)
- else
- ui.addTextArea(mice[name].id-200,"<a href= 'event:close'>X<a/>",name,465,175,0,0,0xFF1000)
- ui.addTextArea(mice[name].id-100,"<j><b><font size= '14'>"..name.."</font></b>",name,300,175,160,0,0,1)
- ui.addTextArea(mice[name].id,"<b><j>título: </j></b>"..mice[name].title.."<br><b><j>muertes: </b></j>"..mice[name][1].."<br><b><j>veces ganadas: </b></j>"..mice[name][2].."",name,300,200,160)
- end
- end
- if a[1] == "save" then
- if mice[a[2]] then
- print(""..a[2].."={ "..mice[a[2]][1]..","..mice[a[2]][2]..", title="..mice[a[2]].title.."}")
- end
- end
- if command == "exit" and admins[name]then
- system.exit()
- elseif command == "next" and admins[name]then
- endGame()
- end
- if command =="help" then
- openCl(name)
- end
- end
- function eventTextAreaCallback(id,name,cb)
- if cb == 'close' then
- ui.removeTextArea(mice[name].id)
- ui.removeTextArea(mice[name].id-100)
- ui.removeTextArea(mice[name].id-200)
- end
- if cb == 'open' then
- openCl(name)
- elseif cb == 'closeCl' then
- mice[name].pa = 1
- closeCl(name)
- elseif cb == 'next' and mice[name].pa<3 then
- mice[name].pa = mice[name].pa +1
- actualizarCl(name)
- elseif cb == 'prev' and mice[name].pa >1 then
- mice[name].pa = mice[name].pa-1
- actualizarCl(name)
- end
- end
- function openCl(player)
- ui.addTextArea(mice[player].id+3000,""..paginas[mice[player].pa].."",player,250,76,210,200,0x67534F,0x67534F)
- ui.addTextArea(mice[player].id-3050,"<a href='event:closeCl'>X</a>",player,448,52,0,0,0x67534F,0x67534F)
- ui.addTextArea(mice[player].id+3100,"<a href='event:next'>next</a>",player,411,52,0,0,0x67534F,0x67534F)
- ui.addTextArea(mice[player].id+3050,"<a href = 'event:prev'>prev</a>",player,249,52,0,0,0x67534F,0x67534F)
- end
- function closeCl(player)
- ui.removeTextArea(mice[player].id+3000)
- ui.removeTextArea(mice[player].id-3050)
- ui.removeTextArea(mice[player].id+3050)
- ui.removeTextArea(mice[player].id+3100)
- end
- function actualizarCl(player)
- ui.addTextArea(mice[player].id+3000,""..paginas[mice[player].pa].."",player,250,76,210,200,0x67534F,0x67534F)
- end
- function checkTitle(name)
- for i = 1,#dataTitlesW do
- if mice[name][2] == dataTitlesW[i][2] then
- mice[name].title = dataTitlesW[i][1]
- end
- end
- for a= 1,#dataTitlesM do
- if mice[name][1] == dataTitlesM[a][2] then
- mice[name].title = dataTitlesM[a][1]
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment