Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admin = "Chicken" -- put nick of admin here
- cash = {}
- rturret = {}
- bturret = {}
- tfm.exec.disableAfkDeath()
- tfm.exec.disableAutoTimeLeft()
- id = 2146
- sy = 100
- rsx = 60
- bsx = 740
- shoot = 0
- function print(msg)
- ui.setShamanName(msg)
- end
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- players={}
- toDespawn={}
- maps={'<C><P /><Z><S><S X="100" L="129" Y="380" H="19" P="0,0,0.3,0.2,0,0,0,0" T="6" /><S X="700" L="129" Y="380" H="19" P="0,0,0.3,0.2,0,0,0,0" T="6" /><S X="400" L="93" Y="339" c="3" H="600" P="0,0,0.3,0.2,0,0,0,0" T="6" /><S X="399" o="324650" L="70" Y="341" c="3" H="580" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S X="10" L="70" Y="364" H="15" P="0,0,0.3,0.2,30,0,0,0" T="6" /><S X="790" L="70" Y="364" H="15" P="0,0,0.3,0.2,-30,0,0,0" T="6" /><S X="207" L="85" Y="385" H="10" P="0,0,0.3,0.2,0,0,0,0" T="5" /><S X="593" L="85" Y="385" H="10" P="0,0,0.3,0.2,0,0,0,0" T="5" /></S><D><F X="100" Y="367" /><F X="702" Y="366" /><DS X="400" Y="24" /></D><O /></Z></C>'}
- red={}
- blue={}
- cred = true
- cblue = true
- function makeTeams()
- red={}
- blue={}
- local playerList={}
- for name,player in pairs(tfm.get.room.playerList) do
- table.insert(playerList,name)
- 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, 0xCB546B)
- table.insert(red,name)
- else
- tfm.exec.setNameColor(name, 0x088FF1)
- table.insert(blue,name)
- end
- table.remove(playerList,index)
- end
- end
- function eventNewPlayer(name)
- ui.addTextArea(1, "<a href = 'event:shop'>Shop!</a>", name, 6, 25, 100, 20, 0x111111, 0x111111, 1, true) -- add shop area for player
- system.bindMouse(name, true)
- if name == admin then
- cash[name] = 888888 -- admin has 888888 cash
- else
- cash[name] = 0 -- but the rest of players has 0 cash
- end
- ui.addTextArea(2, "You have "..cash[name].." coins!", name, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- ..cash[pN].. will show cash quantity
- for i,key in ipairs({32,40,83}) do
- tfm.exec.bindKeyboard(name,key,true,true)
- end
- players[name]={
- timestamp=os.time(),
- offsets={x=2, y=10}
- }
- end
- function eventKeyboard(name,key,down,x,y)
- if (key==32 or key==40 or key==83) and not tfm.get.room.playerList[name].isDead and started then
- if players[name].timestamp < os.time()-1000 then
- local id=tfm.exec.addShamanObject(17, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, tfm.get.room.playerList[name].isFacingRight and 90 or 270)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end
- end
- end
- function eventChatCommand(name,command)
- local arg={}
- for argument in command:gmatch("[^%s]+") do
- table.insert(arg,argument)
- end
- if arg[1]=="off" then
- if tonumber(arg[2]) and tonumber(arg[3]) then
- players[name].offsets.x=tonumber(arg[2])
- players[name].offsets.y=tonumber(arg[3])
- else
- players[name].offsets.x=2
- players[name].offsets.y=10
- end
- tfm.exec.chatMessage("Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y,name)
- end
- end
- function eventNewGame()
- rturret = {}
- bturret = {}
- cred = true
- cblue = true
- makeTeams()
- for playerName,name in pairs (red) do
- tfm.exec.movePlayer (name, rsx, sy)
- end
- for playerName,name in pairs (blue) do
- tfm.exec.movePlayer (name, bsx, sy)
- end
- started=false
- end
- function eventLoop(time,remaining)
- for n in pairs (bturret) do
- local id=tfm.exec.addShamanObject(17, bturret[n][1],bturret[n][2],270)
- table.insert(toDespawn,{os.time(),id})
- end
- for n in pairs (rturret) do
- local id=tfm.exec.addShamanObject(17, rturret[n][1],rturret[n][2],90)
- table.insert(toDespawn,{os.time(),id})
- end
- for name in pairs(tfm.get.room.playerList) do
- ui.updateTextArea(2, "You have "..cash[name].." coins!", name, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- update cash area
- end
- if time >= 3000 and not started then
- started=true
- end
- if remaining<=0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- for i,cannon in ipairs(toDespawn) do
- if cannon[1] <= os.time()-3000 then
- tfm.exec.removeObject(cannon[2])
- table.remove(toDespawn,i)
- end
- end
- end
- function eventPlayerDied(name)
- local i=0
- local r = -1
- local b = -1
- local n
- b = 0
- if cblue == false then
- for playerName,n in pairs (blue) do
- if not n.isDead then
- b = b + 1
- end
- end
- r = 0
- for playerName,n in pairs (red) do
- if not n.isDead then
- r = r + 1
- end
- end
- end
- if r == 0 and cred == false then
- tfm.exec.setGameTime(5)
- print('Red wins!')
- end
- if b == 0 and cblue == false then
- tfm.exec.setGameTime(5)
- print('Blue wins!')
- end
- for playerName,n in pairs (blue) do
- if name == n and cblue == true then
- tfm.exec.respawnPlayer(name)
- tfm.exec.movePlayer (name, bsx, sy)
- tfm.exec.setNameColor(name, 0x088FF1)
- end
- end
- for playerName,n in pairs (red) do
- if name == n and cred == true then
- tfm.exec.respawnPlayer(name)
- tfm.exec.movePlayer (name, rsx, sy)
- tfm.exec.setNameColor(name, 0xCB546B)
- end
- end
- for pname,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- i=i+1
- n=pname
- end
- end
- if i==0 then
- tfm.exec.newGame(maps[math.random(#maps)])
- elseif i==1 then
- for playerName,n in pairs (red) do
- if n == name and cred == false then
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- tfm.exec.setGameTime(5)
- print('Blue wins!')
- end
- end
- for playerName,n in pairs (blue) do
- if n == name and cblue == false then
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- tfm.exec.setGameTime(5)
- print('Red wins!')
- end
- end
- end
- end
- function eventPlayerGetCheese(name)
- cash[name] = cash[name] + 1
- for playerName,n in pairs (red) do
- if name == n then
- if tfm.get.room.playerList[name].x > 400 and cblue == true then
- print('Blues Cheese was taken!')
- cblue = false
- end
- end
- end
- for playerName,n in pairs (blue) do
- if name == n then
- if tfm.get.room.playerList[name].x < 400 and cred == true then
- print('Reds Cheese was taken!')
- cred = false
- end
- end
- end
- tfm.exec.removeCheese(name)
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventTextAreaCallback(idd, pN, req)
- cash[admin] = 888888
- if req == "shop" then -- "shop" is our 'event:shop' in shop area code
- ui.addTextArea(1, [[Shop!
- <a href = 'event:big' >-> Big block - 10 coins</a>
- <a href = 'event:small' >-> Heavy block - 20 coins</a>
- <a href = 'event:meep' >-> Charge attack - 15 coins</a>
- <a href = 'event:t' >-> Turret - 30 coins</a>
- ]], pN, 6, 25, 200, 85, 0x111111, 0x111111, 1, true) -- update shop area
- elseif req == "big" then -- "meep" is our 'event:meep' in updated shop area code
- if cash[pN] >= 10 then -- check if player has more or same as 250 coins
- cash[pN] = cash[pN] - 10 -- substract actual cash value for 250
- tfm.exec.addPhysicObject(id,tfm.get.room.playerList[pN].x,tfm.get.room.playerList[pN].y,
- {
- type = 0,
- width = 70,
- height = 70,
- friction = 0.3,
- dynamic = true,
- mass = 99,
- }
- ) -- give meep for player
- ui.updateTextArea(2, "You have "..cash[pN].." coins!", pN, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- update cash area
- end
- elseif req == "t" then -- "meep" is our 'event:meep' in updated shop area code
- if cash[pN] >= 30 then -- check if player has more or same as 250 coins
- cash[pN] = cash[pN] - 30 -- substract actual cash value for 250
- if tfm.get.room.playerList[pN].isFacingRight then
- table.insert(rturret,{tfm.get.room.playerList[pN].x,tfm.get.room.playerList[pN].y})
- else
- table.insert(bturret,{tfm.get.room.playerList[pN].x,tfm.get.room.playerList[pN].y})
- end
- ui.updateTextArea(2, "You have "..cash[pN].." coins!", pN, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- update cash area
- end
- elseif req == "small" then -- "meep" is our 'event:meep' in updated shop area code
- if cash[pN] >= 20 then -- check if player has more or same as 250 coins
- cash[pN] = cash[pN] - 20 -- substract actual cash value for 250
- tfm.exec.addPhysicObject(id,tfm.get.room.playerList[pN].x,tfm.get.room.playerList[pN].y,
- {
- type = 0,
- width = 20,
- height = 20,
- friction = 0.3,
- dynamic = true,
- mass = 9999,
- }
- ) -- give meep for player
- ui.updateTextArea(2, "You have "..cash[pN].." coins!", pN, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- update cash area
- end
- elseif req == "meep" then -- "meep" is our 'event:meep' in updated shop area code
- if cash[pN] >= 15 then -- check if player has more or same as 250 coins
- cash[pN] = cash[pN] - 15 -- substract actual cash value for 250
- tfm.exec.giveMeep(pN) -- give meep for player
- ui.updateTextArea(2, "You have "..cash[pN].." coins!", pN, 625, 25, 170, 20, 0x111111, 0x111111, 1, true) -- update cash area
- end
- end
- id = id+ 1
- end
- function eventPlayerMeep (name,x,y)
- local id=tfm.exec.addShamanObject(17, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, tfm.get.room.playerList[name].isFacingRight and 90 or 270)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- local id=tfm.exec.addShamanObject(17, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, tfm.get.room.playerList[name].isFacingRight and 90 or 270)
- players[name].timestamp=os.time()
- table.insert(toDespawn,{os.time(),id})
- end
- tfm.exec.newGame(maps[math.random(#maps)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement