Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admin = "Owl#3124"
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.newGame("#10",false)
- playerShoot = {}
- playerOffset = {}
- teamRed = {}
- teamBlue = {}
- objectList = {}
- validObjectId = {0,1,2,3,4,6,7,10,17,23,26,27,28,29,30,31,32,33,34,35,39,40,45,46,54,57,59,60,61,62,65,67,68,69,80,85,89,90,95}
- doom = 0
- objectid = 0
- team = 0
- win = 0
- round = 0
- starttimer = 0
- updatesecond = 0
- spawndelay = true
- customObject = false
- customObjectId = -1
- garbage = false
- teamOnly = false
- for name,player in pairs(tfm.get.room.playerList) do
- playerOffset[name] = {}
- playerOffset[name]["xOff"] = 20
- playerOffset[name]["yOff"] = 0
- end
- function try(f, catch_f)
- local status, exception = pcall(f)
- if not status then
- catch_f(exception)
- end
- end
- function splitString(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={} ; i=1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- return t
- end
- function spairs(t, order)
- local keys = {}
- for k in pairs(t) do keys[#keys+1] = k end
- if order then
- table.sort(keys, function(a,b) return order(t, a, b) end)
- else
- table.sort(keys)
- end
- local i = 0
- return function()
- i = i + 1
- if keys[i] then
- return keys[i], t[keys[i]]
- end
- end
- end
- function eventMouse(name,mx,my)
- alive = tfm.get.room.playerList[name].isDead
- if alive ~= true and win ~= 1 then
- if playerShoot[name] == 2 or spawndelay == false then
- local px,py,xpeed,yspeed,addx;
- px = tfm.get.room.playerList[name].x
- py = tfm.get.room.playerList[name].y
- if mx > px then
- addx = playerOffset[name]['xOff']
- else
- addx = 0-(playerOffset[name]['xOff'])
- end
- if my > py then
- addy = playerOffset[name]['yOff']
- else
- addy = 0-(playerOffset[name]['yOff'])
- end
- if doom == 1 then
- xspeed = (mx-px)/12
- yspeed = (my-py)/10
- else
- if objectid ~= 10 then
- xspeed = (mx-px)/10
- yspeed = (my-py)/10
- else
- xspeed = (mx-px)/18
- yspeed = (my-py)/16
- end
- end
- objectDesc = {}
- objectDesc['timer'] = 0
- if customObjectId == "random" and objectid ~= -1 then
- local objectIdTemp = math.random(1, #validObjectId )
- objectDesc['objectId'] = tfm.exec.addShamanObject(validObjectId[objectIdTemp], px+addx, py+addy, ang, xspeed, yspeed, false)
- else
- objectDesc['objectId'] = tfm.exec.addShamanObject(objectid, px+addx, py+addy, ang, xspeed, yspeed, false)
- end
- if garbage ~= true then
- table.insert(objectList, objectDesc)
- end
- playerShoot[name] = 0
- end
- end
- end
- function eventLoop(spent,remain)
- local ind = 1
- for i=1,#objectList do
- if objectList[ind].timer == 2 then
- tfm.exec.removeObject ( objectList[ind].objectId )
- table.remove( objectList, ind )
- else
- objectList[ind].timer = objectList[ind].timer+1
- ind = ind+1
- end
- end
- try(function()
- for name,player in pairs(tfm.get.room.playerList) do
- if playerShoot[name] < 2 then
- playerShoot[name] = playerShoot[name]+1
- end
- end
- end,function(e) end)
- if spent > 83000 or remain <= 0 then
- if win == 0 then
- if team == 1 then
- local redAlive = 0
- local blueAlive = 0
- for i=1,#teamRed,1 do
- try(function()
- if tfm.get.room.playerList[teamRed[i]].isDead == false then
- redAlive = redAlive+1
- end
- end,function(e) print (e) end)
- end
- for i=1,#teamBlue,1 do
- try(function()
- if tfm.get.room.playerList[teamBlue[i]].isDead == false then
- blueAlive = blueAlive+1
- end
- end,function(e) print (e) end)
- end
- if redAlive > blueAlive then
- print ("Red Win (Most Player Survived)")
- tfm.exec.setGameTime(10,true)
- win = 1
- for i=1,#teamRed,1 do
- try(function()
- if tfm.get.room.playerList[teamRed[1]].isDead ~= true then
- tfm.exec.setPlayerScore(teamRed[1],2,true)
- else
- tfm.exec.setPlayerScore(teamRed[1],1,true)
- end
- end,function(e) print (e) end)
- table.remove(teamRed,1)
- end
- elseif blueAlive > redAlive then
- print ("Blue Win (Most Player Survived)")
- tfm.exec.setGameTime(10,true)
- win = 1
- for i=1,#teamBlue,1 do
- try(function()
- if tfm.get.room.playerList[teamBlue[1]].isDead ~= true then
- tfm.exec.setPlayerScore(teamBlue[1],2,true)
- else
- tfm.exec.setPlayerScore(teamBlue[1],1,true)
- end
- end,function(e) print (e) end)
- table.remove(teamBlue,1)
- end
- else
- print ("Round Draw (All alive players got 1 score")
- for i=1,#teamRed,1 do
- try(function()
- tfm.exec.setPlayerScore(teamRed[1],1,true)
- end,function(e) print (e) end)
- table.remove(teamRed,1)
- end
- for i=1,#teamBlue,1 do
- try(function()
- tfm.exec.setPlayerScore(teamBlue[1],1,true)
- end,function(e) print (e) end)
- table.remove(teamBlue,1)
- end
- end
- else
- for name,player in pairs(tfm.get.room.playerList) do
- if(tfm.get.room.playerList[name].isDead == false) then
- tfm.exec.setPlayerScore(name,2,true)
- end
- end
- end
- end
- tfm.exec.newGame("#10",false)
- end
- if spent > 3000 and spent < 4000 then
- tfm.exec.killPlayer("Bot#1618")
- ui.removeTextArea(1,nil)
- end
- if spent < 6000 then
- updatesecond = updatesecond + 0.5
- if spent > 3000 and updatesecond >= 1 then
- ui.addTextArea(2,starttimer,nil,600,375,0,0)
- starttimer = starttimer - 1
- updatesecond = 0
- end
- objectid = -1
- elseif spent < 23000 then
- ui.removeTextArea(2,nil)
- if customObject then
- if customObjectId == "random" then
- local rand = math.random(1,#validObjectId)
- objectid = validObjectId[rand]
- else
- objectid = customObjectId
- end
- else
- objectid = 65
- end
- elseif spent < 43000 then
- if customObject then
- if customObjectId == "random" then
- local rand = math.random(1,#validObjectId)
- objectid = validObjectId[rand]
- else
- objectid = customObjectId
- end
- doom = 1
- else
- objectid = 6
- end
- elseif spent < 63000 then
- if customObject then
- if customObjectId == "random" then
- local rand = math.random(1,#validObjectId)
- objectid = validObjectId[rand]
- else
- objectid = customObjectId
- end
- doom = 1
- else
- objectid = 10
- end
- elseif spent < 83000 then
- doom = 1
- end
- end
- function eventChatCommand (name,command)
- local cP = {}
- for param in command:gmatch("[^%s]+") do
- table.insert(cP, param)
- end
- if name == admin then
- if command == "skip" then
- tfm.exec.newGame("#10",false)
- elseif command == "spawn" then
- tfm.exec.respawnPlayer(name)
- elseif command == "restart" then
- for name,player in pairs(tfm.get.room.playerList) do
- tfm.exec.setPlayerScore(name,0,false)
- end
- round = 0
- tfm.exec.newGame("#10",false)
- elseif cP[1] == "anvilonly" then
- if customObject and customObjectId ~= -1 then
- customObject = false
- customObjectId = -1
- else
- customObject = true
- customObjectId = 10
- end
- elseif cP[1] == "object" then
- if customObject and #cP == 1 then
- customObject = false
- customObjectId = -1
- else
- if cP[2] == "random" then
- customObject = true
- customObjectId = "random"
- else
- if not tonumber(cP[2])then
- ui.addPopup(9,0,"Error!",name,300, 300,200, false)
- else
- customObject = true
- customObjectId = cP[2]
- end
- end
- end
- elseif command == "spawndelay" then
- spawndelay = !spawndelay
- elseif command == "garbage" then
- garbage = !garbage
- elseif command == "teamonly" then
- teamOnly = !teamOnly
- end
- end
- if cP[1] == "off" then
- if not tonumber(cP[2]) or not tonumber(cP[3]) then
- ui.addPopup(9,0,"Error!",name,300, 300,200, false)
- else
- if tonumber(cP[2]) <= 20 and tonumber(cP[2]) >= -20 and tonumber(cP[3]) <= 20 and tonumber(cP[3]) >= -20 then
- playerOffset[name]["xOff"] = tonumber(cP[2])
- playerOffset[name]["yOff"] = tonumber(cP[3])
- ui.addPopup(9,0,"Spawn offset set to \n x="..cP[2].."\n y="..cP[3],name,300, 300,200, false)
- else
- ui.addPopup(9,0,"Offset can't be smaller than -20 or greater than 20",name, 300, 300,200, false)
- end
- end
- end
- end
- function eventNewPlayer(name)
- playerOffset[name] = {}
- playerOffset[name]["xOff"] = 20
- playerOffset[name]["yOff"] = 0
- playerShoot[name] = 0
- end
- function eventNewGame()
- if round == 10 then
- local playerScore = {}
- local winner = "nil"
- for name,player in pairs(tfm.get.room.playerList) do
- playerScore[name] = tfm.get.room.playerList[name].score
- end
- for name,score in spairs(playerScore, function(t,a,b) return t[b] < t[a] end) do
- winner = name
- break
- end
- for name,player in pairs(tfm.get.room.playerList) do
- ui.addPopup(9,0,winner .. " won the game!",name,500,300,200,false)
- tfm.exec.setPlayerScore(name,0,false)
- end
- round = 0
- end
- round = round + 1
- ui.setMapName("BFM! [Round "..round.."/10]")
- starttimer = 3
- doom = 0
- team = 0
- win = 0
- playerShoot = {}
- teamRed = {}
- teamBlue = {}
- for name,player in pairs(tfm.get.room.playerList) do
- playerShoot[name] = 0
- tfm.exec.giveMeep(name,true)
- system.bindMouse(name,true)
- system.bindKeyboard(name,32,true,true)
- tfm.exec.setNameColor(name,0)
- end
- if math.random(1,4) == 1 or teamOnly then
- team = 1
- local playerList={}
- for name,player in pairs(tfm.get.room.playerList) do
- if name ~= "Bot#1618" then
- table.insert(playerList,name)
- end
- end
- for i=1,#playerList,1 do
- local index=math.random(#playerList)
- local name=playerList[index]
- if i%2==0 then
- tfm.exec.setNameColor(name,0xff3300)
- ui.addPopup(1,0,"You are on TEAM RED, eleminate TEAM BLUE!",name,300,200,200,false)
- table.insert(teamRed,name)
- else
- tfm.exec.setNameColor(name,0x0066ff)
- ui.addPopup(1,0,"You are on TEAM BLUE, eleminate TEAM RED!",name,300,200,200,false)
- table.insert(teamBlue,name)
- end
- table.remove(playerList,index)
- end
- end
- tfm.exec.setGameTime(86,true)
- end
- function eventPlayerMeep(name,px,py)
- local facing = tfm.get.room.playerList[name].isFacingRight
- local xspeed,yspeed,addx;
- if facing then
- addx = playerOffset[name]["xOff"]
- else
- addx = 0-(playerOffset[name]["xOff"])
- end
- if objectid == 65 then
- xspeed = 65
- elseif objectid == 6 then
- xspeed = 45
- elseif objectid == 10 then
- xspeed = 25
- else
- xspeed = 50
- end
- if doom == 1 then
- xspeed = xspeed*2
- end
- if facing == false then
- xspeed = xspeed-(xspeed*2)
- end
- objectDesc = {}
- objectDesc['timer'] = 0
- objectDesc['objectId'] = tfm.exec.addShamanObject(objectid, px+addx, py-25, ang, xspeed, 2, false)
- table.insert( objectList, objectDesc )
- objectDesc['objectId'] = tfm.exec.addShamanObject(objectid, px+addx, py, ang, xspeed, 2, false)
- table.insert( objectList, objectDesc )
- objectDesc['objectId'] = tfm.exec.addShamanObject(objectid, px+addx, py+25, ang, xspeed, 2, false)
- end
- function eventPlayerDied(nameded)
- if team == 0 then
- local alive = 0
- local winname
- for name,player in pairs(tfm.get.room.playerList) do
- if tfm.get.room.playerList[name].isDead == false then
- alive = alive+1
- winname = name
- end
- end
- if alive == 1 then
- ui.addTextArea(1,"Winner : " .. winname ,nil,600,375,0)
- print (winname .. " Win")
- tfm.exec.giveMeep(winname,false)
- win = 1
- tfm.exec.setGameTime(10,true)
- tfm.exec.setPlayerScore(winname,3,true)
- end
- if alive == 0 then
- tfm.exec.newGame("#10",false)
- end
- else
- local redAlive = 0
- local blueAlive = 0
- for i=1,#teamRed,1 do
- try(function()
- if tfm.get.room.playerList[teamRed[i]].isDead == false then
- redAlive = redAlive+1
- end
- end,function(e) print (e) end)
- end
- for i=1,#teamBlue,1 do
- try(function()
- if tfm.get.room.playerList[teamBlue[i]].isDead == false then
- blueAlive = blueAlive+1
- end
- end,function(e) print (e) end)
- end
- if blueAlive == 0 and redAlive ~= 0 then
- print ("Red Win")
- ui.addTextArea(1,"Winner : Red Team",nil,600,375,0)
- tfm.exec.setGameTime(10,true)
- win = 1
- for i=1,#teamRed,1 do
- try(function()
- if tfm.get.room.playerList[teamRed[1]].isDead ~= true then
- tfm.exec.setPlayerScore(teamRed[1],2,true)
- else
- tfm.exec.setPlayerScore(teamRed[1],1,true)
- end
- tfm.exec.giveMeep(teamRed[1],false)
- end,function(e) print (e) end)
- table.remove(teamRed,1)
- end
- end
- if redAlive == 0 and blueAlive ~= 0 then
- print ("Blue Win")
- ui.addTextArea(1,"Winner : Blue Team",nil,600,375,0)
- tfm.exec.setGameTime(10,true)
- win = 1
- for j=1,#teamBlue,1 do
- try(function()
- if tfm.get.room.playerList[teamBlue[1]].isDead ~= true then
- tfm.exec.setPlayerScore(teamBlue[1],2,true)
- else
- tfm.exec.setPlayerScore(teamBlue[1],1,true)
- end
- tfm.exec.giveMeep(teamBlue[1],false)
- end,function(e) print (e) end)
- table.remove(teamBlue,1)
- end
- end
- if redAlive == 0 and blueAlive == 0 then
- tfm.exec.newGame("#10",false)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement