Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data={}
- maps={7162824,7233571,6888882,3874909,5742159}
- freezers={}
- isFreezer=function(name)
- for _,n in pairs(freezers) do
- if n == name then
- return true
- end
- end
- return false
- end
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAutoNewGame()
- getAlives=function()
- local a = 0 table.foreach(tfm.get.room.playerList, function(k,v) if not v.isDead and freezer ~= k then a=a+1 end end) return a
- end
- function eventKeyboard(name,key,down,x,y)
- if key == 32 and isFreezer(name) and data[name].cooldown < os.time()-2000 then
- for k,player in pairs(tfm.get.room.playerList) do
- if name ~= k and not isFreezer(k) and data[k].count < 2 and not player.isDead and not data[k].freezed and x >= player.x - 15 and x <= player.x + 15 and y >= player.y - 15 and y <= player.y + 15 then
- tfm.exec.killPlayer(k)
- data[k].coords = {player.x,player.y}
- data[k].id=tfm.exec.addImage("15eda796ea2.png","?"..player.id,data[k].coords[1]-20,data[k].coords[2]-20)
- data[k].freezed=true
- data[k].cooldown_dead = 20
- data[k].count = data[k].count+1
- data[name].cooldown=os.time()
- break
- elseif data[k].count == 2 then
- if math.random(1,8) == 4 then
- table.insert(freezers,k)
- tfm.exec.setNameColor(k,0xFFCC00)
- data[k].cooldown=os.time();
- else
- tfm.exec.killPlayer(k)
- data[k].freezed=true
- data[k].id=tfm.exec.addImage("15eda796ea2.png","?"..player.id,data[k].coords[1]-20,data[k].coords[2]-20)
- end
- end
- end
- end
- if key == 32 and not isFreezer(name) and not tfm.get.room.playerList[name].isDead and data[name].cooldown < os.time()-2500 then
- table.foreach(tfm.get.room.playerList,function(k,player)
- if data[k].cooldown_dead > 0 and name ~= k and player.isDead and not data[name].freezed and x >= player.x - 15 and x <= player.x + 15 and y >= player.y - 15 and y <= player.y + 15 then
- tfm.exec.respawnPlayer(k)
- tfm.exec.movePlayer(k,data[k].coords[1],data[k].coords[2])
- if data[k].id ~= nil then ui.removeImage(data[k].id) end
- data[k].freezed=false
- ui.removeTextArea(player.id)
- data[name].cooldown=os.time()
- end
- end)
- end
- end
- function eventNewGame()
- freezers={}
- table.foreach(tfm.get.room.playerList,function(k,v)
- data[k].freezed=false
- ui.removeTextArea(v.id,nil)
- if data[k].id ~= nil then ui.removeImage(data[k].id) end
- data[k].cooldown_dead=0
- data[k].count=0
- end)
- end
- function check()
- table.foreach(tfm.get.room.playerList,function(k,v)
- if v.isDead then
- if data[k].cooldown_dead > 0 then
- ui.addTextArea(v.id,'<B><font color="#2F7FCC" size="13">'..math.floor(data[k].cooldown_dead/2),nil,data[k].coords[1],data[k].coords[2],30,30,0,0,0,true)
- data[k].cooldown_dead=data[k].cooldown_dead-1
- else
- ui.removeTextArea(v.id)
- if data[k].id ~= nil then ui.removeImage(data[k].id) end
- v.isDead=false
- end
- end
- end)
- end
- function eventLoop(t,r)
- if t > 4000 then
- if #freezers == 0 then
- local p = {} table.foreach(tfm.get.room.playerList,function(k,v) tfm.exec.setNameColor(k,0) table.insert(p,k) end)
- for i=1,4 do f = p[math.random(#p)] table.insert(freezers,f) tfm.exec.setNameColor(f,0xFFCC00) data[f].cooldown=os.time(); end
- local fs,m = "", "<VP><V>%s</V> é o novo freezer, cuidado.</VP>"
- for _,n in pairs(freezers) do
- if fs == "" then
- fs=n
- else
- fs=fs.."<VP>,</VP>"..n
- m="<VP><V>%s</V> são os novos freezers, cuidado.</VP>"
- end
- end
- tfm.exec.chatMessage(string.format(m,fs))
- end
- if #freezers == 0 and t > 5000 then
- for name,v in pairs(tfm.get.room.playerList) do if not v.isDead then tfm.exec.giveCheese(name)tfm.exec.playerVictory(name) end end
- tfm.exec.chatMessage("<FC>Os freezers morreram, os ratos vivos ganharam.</FC>")
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- if r <= 1000 then
- tfm.exec.chatMessage("<FC>O tempo acabou.</FC>")
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- if getAlives() == 0 then
- for name,v in pairs(tfm.get.room.playerList) do if not v.isDead then tfm.exec.giveCheese(name)tfm.exec.playerVictory(name) end end
- tfm.exec.chatMessage("<FC>Os freezers vivos ganharam.</FC>")
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- check()
- end
- end
- function eventPlayerDied(name)
- if isFreezer(name) then
- tfm.exec.chatMessage("<FC>O freezer "..name.." morreu.</FC>")
- for _,n in ipairs(freezers) do
- if n == name then
- table.remove(freezers,_)
- break
- end
- end
- end
- end
- function eventNewPlayer(name)
- data[name]={
- id=nil,
- freezed=false,
- cooldown=0,
- cooldown_dead=0,
- count=0
- }
- system.bindKeyboard(name,32,true)
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- tfm.exec.newGame(maps[math.random(#maps)])
Add Comment
Please, Sign In to add comment