Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mice=0
- round=0
- places=0
- data={
- skips={}
- }
- players={}
- admins={
- "Betelgueze",
- "Browndown",
- "Charleezy",
- "Colinzzd",
- "Fxie",
- "Hopmaster",
- "Shamousey",
- "Shininha",
- "Simosc"
- }
- skillmaps={
- { code="@2566248",
- time=105,
- medals={
- {330,365,true},
- {230,365,true},
- {130,365,true}
- }
- },
- { code="@2589629",
- medals={
- {1120,375},
- {980,375},
- {880,375}
- }
- },
- { code="@4087474",
- medals={
- {140,170},
- {380,50},
- {740,200}
- }
- },
- { code="@4092254",
- medals={
- {110,60,true},
- {360,60,true},
- {680,60,true}
- }
- },
- { code="@4087721",
- medals={
- {290,140},
- {590,140},
- {710,140}
- }
- },
- { code="@4098337",
- medals={
- {410,120},
- {500,120},
- {700,120}
- }
- },
- { code="@4103105",
- medals={
- {670,240},
- {130,110},
- {720,110}
- }
- },
- { code="@4069077",
- medals={
- {120,70},
- {390,70},
- {760,70,true}
- }
- },
- { code="@4114121",
- medals={
- {505,80},
- {625,80},
- {745,80}
- }
- },
- { code="@4131345",
- medals={
- {320,320},
- {580,320},
- {750,320}
- }
- },
- { code="@4140045",
- medals={
- {520,125},
- {650,275},
- {730,365}
- }
- },
- { code="@4147347",
- medals={
- {320,270},
- {515,270},
- {740,270}
- }
- }
- }
- text={
- greet="Welcome to %s, a better bootcamp.",
- greetSub="As always, type %s if you need it. Enjoy your stay, newbie.",
- tkJoin="Timekeeper %s has joined.",
- iEmpty="You must type a command!",
- timeAdd="%d more seconds, just for you!",
- timeMax="%d minutes isn't enough?!",
- timeWait="Wait 'til next round!",
- timeError="Time must be a number, dummy!",
- skipVote="Your vote has been added.",
- skipMap="The mice have spoken! This map will end in %d seconds...",
- skipVoted="You already voted!",
- skipAlready="The map is already being skipped!",
- betPlace="Think %s can win eh? We'll see...",
- betWon="You got %d points for your lucky bet!",
- betLose="Lucked out!",
- betLate="You can only place bets in the first %d seconds!",
- betBroke="You need at least %d points to place a bet!",
- betNobody="Hey buddy, you can't bet on people who aren't here!",
- wonRecord="New personal record!",
- wonLegit="%s completed the map without checkpoints!",
- topTime="The top time for %s was %s by %s!",
- checkpointSet="Checkpoint set!",
- checkpointError="Stand still to set a checkpoint!",
- checkpointCleared="Checkpoint cleared!",
- checkpointOverload="You died pretty fast! If you set a bad checkpoint, press %s to clear it!",
- skillmap="Think you got what it takes?",
- skillmapCountdown="Get ready! Timed skillmap in %d...",
- medal1="bronze",
- medal2="silver",
- medal3="gold",
- medalGet="%s just scored the %s medal!"
- }
- --new Player
- Player=function(name)
- return {
- name=name,
- topscore=0,
- toptimes=0,
- spawn=os.time(),
- settings={
- instaspawn=true,
- checkpoints=true
- },
- checkpoint={
- x=0,
- y=0,
- cheese=false,
- set=false,
- uses=0,
- last=0
- },
- CPset=P_CPset,
- CPuse=P_CPuse
- }
- end
- --Player:CPset(x,y,cheese)
- function P_CPset(p)
- local me=tfm.get.room.playerList[p.name]
- p.checkpoint.x=me.x
- p.checkpoint.y=me.y
- p.checkpoint.cheese=me.hasCheese
- p.checkpoint.set=true
- ui.addTextArea(4,"",p.name,me.x-2,me.y-2,4,4,0x44cc44,0xffffff,0.5)
- end
- --Player:CPuse(died)
- function P_CPuse(p,died)
- p.checkpoint.uses=p.checkpoint.uses+1
- tfm.exec.movePlayer(p.name,p.checkpoint.x,p.checkpoint.y,false,1,1,false)
- if p.checkpoint.cheese then
- system.newTimer(function()
- tfm.exec.giveCheese(p.name)
- end,1000)
- end
- if died then
- p.checkpoint.last=os.time()
- end
- end
- --Sign my ass
- function isAdmin(name)
- for i=1,#admins do
- if admins[i]==name then
- return true
- end
- end
- return false
- end
- --Sign my ass
- function haveAdmin()
- for i=1,#admins do
- if tfm.get.room.playerList[admins[i]] then
- return true
- end
- end
- return false
- end
- --Olympics automated
- function checkMedals(name,x,y)
- if timeSpent>=3 then
- for i=1,#skillmap.medals do
- local medal=skillmap.medals[i]
- if math.abs(x-medal.x)<15 and math.abs(y-medal.y)<15 and (not medal.cheese or tfm.get.room.playerList[name].hasCheese) then
- tfm.exec.chatMessage("<J>"..text.medalGet:format(name,"<N>"..text["medal"..medal.id].."<J>"))
- --tfm.exec.setPlayerScore(name,medal.id*10,true)
- end
- end
- end
- end
- --New beginnings
- function eventNewGame()
- bets={}
- voteskip={}
- votetime={}
- places=0
- timeSpent=0
- timeLeft=3*60
- tfm.exec.setGameTime(timeLeft)
- ui.removeTextArea(2)
- ui.removeTextArea(3)
- ui.removeTextArea(4)
- skillmap=nil
- local timestamp=os.time()
- for name,player in pairs(players) do
- players[name].spawn=timestamp
- players[name].checkpoint.set=false
- end
- for name,player in pairs(tfm.get.room.playerList) do
- if player.score>players[name].topscore then
- players[name].topscore=player.score
- end
- tfm.exec.setPlayerScore(name,-math.floor(player.score/10),true)
- end
- local wind,gravity=0,10
- if tfm.get.room.xmlMapInfo then
- for w,g in tfm.get.room.xmlMapInfo.xml:gmatch('<P[^/]+G="([-%d.]+),([-%d.]+)"') do
- wind,gravity=w,g
- end
- local medals={}
- for object in tfm.get.room.xmlMapInfo.xml:gmatch("<O [^/]+/>") do
- type=tonumber(object:match('C="(%d+)"'))
- if type==14 or type==22 or type==11 then
- table.insert(medals,{
- x=tonumber(object:match('X="(%d+)"')) or 0,
- y=tonumber(object:match('Y="(%d+)"')) or 0,
- id=type==11 and 1 or type==14 and 2 or 3
- })
- end
- end
- if #medals==3 then
- skillmap={
- code=tfm.get.room.xmlMapInfo.mapCode,
- medals=medals
- }
- tfm.exec.chatMessage("<CH>"..text.skillmap)
- end
- end
- tfm.exec.setUIShamanName("<N>Wind <CH>"..wind.."<N> Gravity <CH>"..gravity)
- grounds={}
- if tfm.get.room.xmlMapInfo then
- local ground,p
- local gAttrs={"c","T","X","Y","L","H"}
- local gTypes={"Wood","Ice","Trampoline","Lava","Chocolate","Earth","Grass","Sand","Cloud","Water","Stone"}
- local gProps={"Dynamic","Mass","Friction","Restitution","Rotation"}
- for sol in tfm.get.room.xmlMapInfo.xml:gmatch("<S [^/]+/>") do
- p=0
- ground={
- id=#grounds,
- P=tostring(sol:match('P="([^"]+)"'))
- }
- for i,attribute in ipairs(gAttrs) do
- ground[attribute]=tonumber(sol:match(attribute..'="([-%d.]+)"')) or 0
- end
- if ground.c~=2 and ground.c~=4 then
- if gTypes[ground.T+1] then
- ground.T=gTypes[ground.T+1]
- end
- for property in ground.P:gmatch("[^,]+") do
- p=p+1
- if gProps[p] then
- ground[gProps[p]]=property
- else
- break
- end
- end
- table.insert(grounds,1,ground)
- end
- end
- end
- end
- --A continuum
- function eventLoop(time,remaining,queue)
- timeSpent=time/1000
- timeLeft=remaining/1000
- if remaining<=500 then
- local map="#13"
- if queue then
- map=queue
- else
- round=round+1
- local modulo=math.fmod(round,7)
- if modulo==2 or modulus==5 then
- map="#3"
- elseif modulo==6 then
- --map=skillmaps[math.random(#skillmaps)]
- end
- end
- if toptime then
- local player=players[toptime.name]
- player.toptimes=player.toptimes+1
- tfm.exec.chatMessage("<J>"..text.topTime:format(tfm.get.room.currentMap,"<N>"..(toptime.time/1000).."<J>",toptime.name))
- toptime=nil
- end
- tfm.exec.setGameTime(5)
- tfm.exec.newGame(map)
- end
- end
- --Welcome to the jungle
- function eventNewPlayer(name)
- mice=mice+1
- tfm.exec.chatMessage("<VP>"..text.greet:format("<N>bootcamp44<VP>"),name)
- tfm.exec.chatMessage("<T>"..text.greetSub:format("<N>!help<T>"),name)
- if isAdmin(name) then
- tfm.exec.chatMessage("<V>"..text.tkJoin:format(name))
- end
- players[name]=Player(name)
- system.bindMouse(name)
- for i,key in ipairs({8,46,65,69,70}) do
- tfm.exec.bindKeyboard(name,key,true,true)
- end
- end
- --Welcome to suburbia
- function eventPlayerLeft(name)
- mice=mice-1
- --players[name]=nil
- end
- --Not gravity master material
- function eventPlayerDied(name)
- if players[name].settings.instaspawn then
- tfm.exec.respawnPlayer(name)
- end
- end
- --Welcome back
- function eventPlayerRespawn(name)
- local player=players[name]
- player.spawn=os.time()
- if player.checkpoint.set then
- if player.spawn-player.checkpoint.last<1000 then
- tfm.exec.chatMessage("<BL>"..text.checkpointOverload:format("<N>Q<BL>"),name)
- elseif timeLeft>5 then
- player:CPuse(true)
- end
- else
- player.checkpoint.uses=0
- end
- end
- --Good job champ
- function eventPlayerWon(name)
- local player=players[name]
- ui.removeTextArea(4,name)
- player.checkpoint.set=false
- if player.checkpoint.uses>0 then
- tfm.exec.setPlayerScore(name,math.max(10-player.checkpoint.uses,2),true)
- player.checkpoint.uses=0
- else
- local wintime=os.time()-player.spawn
- if not toptime or wintime<toptime.time then
- toptime={
- name=name,
- time=wintime
- }
- end
- places=places+1
- tfm.exec.setPlayerScore(name,10+math.max(0,8-places*2),true)
- if places==1 then
- tfm.exec.chatMessage("<J>"..text.wonLegit:format(name))
- local winners={}
- local winnings=0
- for player,bet in pairs(bets) do
- if bet==name then
- table.insert(winners,player)
- elseif tfm.get.room.playerList[player] then
- winnings=winnings+5
- tfm.exec.setPlayerScore(player,-5,true)
- tfm.exec.chatMessage("<BL>"..text.betLose,player)
- end
- end
- winnings=math.ceil(winnings/#winners)+1
- for i=1,#winners do
- tfm.exec.setPlayerScore(winners[i],winnings,true)
- tfm.exec.chatMessage("<VP>"..text.betWon:format(winnings),winners[i])
- end
- end
- end
- if player.settings.instaspawn then
- tfm.exec.respawnPlayer(name)
- end
- end
- --Floor check
- function eventMouse(name,x,y)
- local theta,c,s,cx,cy
- for i,ground in ipairs(grounds) do
- theta=math.rad(ground.Rotation)
- c,s=math.cos(-theta),math.sin(-theta)
- cx=ground.X+c*(x-ground.X)-s*(y-ground.Y)
- cy=ground.Y+s*(x-ground.X)+c*(y-ground.Y)
- if math.abs(cx-ground.X)<ground.L/2 and math.abs(cy-ground.Y)<ground.H/2 then
- ui.addTextArea(2,"<font size='12'>"
- .."<N>Ground ID "..ground.id
- .."\n"
- .."\n<N>Type <VP>"..ground.T
- .."\n<N>Friction <VP>"..ground.Friction
- .."\n<N>Restitution <VP>"..ground.Restitution
- .."\n"
- .."\n<N>X <VP>"..ground.X
- .."\n<N>Y <VP>"..ground.Y
- .."\n<N>Width <VP>"..ground.L
- .."\n<N>Height <VP>"..ground.H
- .."\n<N>Rotation <VP>"..ground.Rotation
- .."</font>"
- ,name,20,40,120,nil,0x324650,0x212F36,0.8)
- return
- end
- end
- ui.removeTextArea(2,name)
- end
- --Checkpoint newbs
- function eventKeyboard(name,key,down,x,y)
- local player=players[name]
- if key==69 then
- if skillmap then
- checkMedals(name,x,y)
- elseif player.settings.checkpoints and timeLeft>5 and not tfm.get.room.playerList[name].isJumping then
- player:CPset()
- end
- elseif key==70 then
- if player.checkpoint.set then
- if tfm.get.room.playerList[name].hasCheese and not player.checkpoint.cheese then
- tfm.exec.killPlayer(name)
- elseif timeLeft>5 then
- player:CPuse()
- end
- end
- elseif key==65 then
- player.checkpoint.set=false
- ui.removeTextArea(4,name)
- elseif key==8 or key==46 then
- tfm.exec.killPlayer(name)
- end
- end
- --Say what?
- function eventChatCommand(name,message)
- local args={}
- local admin=isAdmin(name)
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- message=message:match("%s(.*)") or ""
- if args[1]=="i" then
- if message~="" then
- eventChatCommand(name,message)
- else
- tfm.exec.chatMessage("<R>"..text.iEmpty,name)
- end
- elseif args[1]=="blind" then
- if args[2]=="off" then
- ui.removeTextArea(3,name)
- else
- ui.addTextArea(3,"",name,0,0,800,400,0x242424,0x242424,1)
- end
- elseif args[1]=="help" then
- ui.addPopup(1,0,"<font size='16'>Bootcamp44 Stuff</font><font size='12'>\n\n"..table.concat({
- "Press <i>E</i> to set a checkpoint",
- "Press <i>F</i> to go to a checkpoint",
- "Press <i>Q</i> to clear a checkpoint",
- "Press <i>backspace</i> to die",
- "Type <i>!time</i> to add time to the current map\nType <i>!skip</i> to skip the current map",
- "Click on a ground to view its properties\nClick somewhere else to make the popup go away",
- },"\n\n").."</font>",name,200,80,400)
- elseif args[1]=="timekeepers" then
- local output,haveAdmin="<VP>Timekeepers: <N>",false
- for i=1,#admins do
- output=output..admins[i]
- if tfm.get.room.playerList[admins[i]] then
- output=output.."*"
- haveAdmin=true
- end
- if i~=#admins then
- output=output..", "
- end
- end
- tfm.exec.chatMessage(output,name)
- if haveAdmin then
- tfm.exec.chatMessage("<VP><font size='10'> * online in this room!</font>",name)
- end
- elseif args[1]=="enable" or args[1]=="disable" then
- if players[name].settings[args[2]] then
- local toggle=args[1]=="enable"
- players[name].settings[args[2]]=toggle
- toggle=toggle and "Enabled" or "Disabled"
- tfm.exec.chatMessage(toggle.." : "..args[2],name)
- end
- elseif args[1]=="bet" then
- if timeSpent<30 then
- if tfm.get.room.playerList[name].score>=5 then
- local player=args[2] and args[2]:gsub("^%l",string.upper)
- if tfm.get.room.playerList[player] then
- bets[name]=player
- tfm.exec.chatMessage("<VP>"..text.betPlace:format(player),name)
- else
- tfm.exec.chatMessage("<R>"..text.betNobody,name)
- end
- else
- tfm.exec.chatMessage("<R>"..text.betBroke:format(5),name)
- end
- else
- tfm.exec.chatMessage("<R>"..text.betLate:format(30),name)
- end
- elseif args[1]=="stats" then
- local toptimes,topscores={},{}
- for name,player in pairs(players) do
- table.insert(toptimes,{
- name=name,
- value=player.toptimes
- })
- table.insert(topscores,{
- name=name,
- value=player.topscore
- })
- end
- table.sort(toptimes,function(a,b)
- return a.value>b.value
- end)
- table.sort(topscores,function(a,b)
- return a.value>b.value
- end)
- local ttString,tsString={},{}
- for i=1,math.min(5,#toptimes) do
- table.insert(ttString,"<li>"..toptimes[i].value.." - "..toptimes[i].name.."</li>")
- table.insert(tsString,"<li>"..topscores[i].value.." - "..topscores[i].name.."</li>")
- end
- ui.addPopup(1,0,"<font size='16'>Temporary Stats</font><font size='12'>"
- .."\n\nTop Times\n<ul>"..table.concat(ttString).."</ul>"
- .."\n\nHigh Scores\n<ul>"..table.concat(tsString).."</ul>"
- .."</font>",name,300,80,200)
- elseif args[1]=="die" then
- tfm.exec.killPlayer(name)
- elseif args[1]=="time" then
- if args[2] and admin then
- local time=tonumber(args[2])
- if time then
- tfm.exec.setGameTime(time*(args[3]=="min" and 60 or 1))
- else
- tfm.exec.chatMessage("<R>"..text.timeError,name)
- end
- elseif (not skillmap or not skillmap.time) and not votetime[name] and not voteskip.set then
- votetime[name]=true
- local votes=0
- for name,vote in pairs(votetime) do
- votes=votes+1
- end
- if votes<=12 then
- tfm.exec.setGameTime(timeLeft+30)
- tfm.exec.chatMessage("<J>"..text.timeAdd:format(30),name)
- else
- tfm.exec.chatMessage("<R>"..text.timeMax:format(9),name)
- end
- else
- tfm.exec.chatMessage("<R>"..text.timeWait,name)
- end
- elseif args[1]=="skip" then
- if admin and args[2]=="now" then
- eventLoop(0,0)
- elseif voteskip.set then
- tfm.exec.chatMessage("<R>"..text.skipAlready,name)
- else
- for i,player in ipairs(voteskip) do
- if player==name then
- tfm.exec.chatMessage("<R>"..text.skipVoted,name)
- return
- end
- end
- table.insert(voteskip,name)
- tfm.exec.chatMessage("<BL>"..text.skipVote,name)
- if #voteskip>=math.ceil(mice/2) then
- tfm.exec.chatMessage("<J>"..text.skipMap:format(10))
- tfm.exec.setGameTime(10)
- voteskip.set=true
- local map=tfm.get.room.currentMap
- if not data.skips[map] then
- data.skips[map]=1
- else
- data.skips[map]=data.skips[map]+1
- end
- end
- end
- elseif args[1]=="get" then
- if args[2]=="skipdata" then
- local output={}
- for map,skips in pairs(data.skips) do
- table.insert(output,map.." - "..skips.." times")
- end
- tfm.exec.chatMessage(table.concat(output,"\n"),name)
- end
- elseif admin then
- if args[1]=="tk" then
- tfm.exec.chatMessage("<ROSE><b>[Timekeeper]</b><N> "..message)
- elseif args[1]=="tkc" then
- for i=1,#admins do
- tfm.exec.chatMessage("<ROSE>• <VI>["..name.."]<ROSE> "..message,admins[i])
- end
- elseif args[1]=="play" then
- eventLoop(0,0,args[2])
- elseif args[1]=="shaman" then
- tfm.exec.setShaman(name)
- elseif args[1]=="test" then
- tfm.exec.chatMessage(" > "..message:gsub("<","<"):gsub(">",">"))
- elseif args[1]=="popup" then
- ui.addPopup(2,0,message:gsub("<","<"):gsub(">",">"),name,300,80,200)
- end
- end
- end
- --Hide spammands
- for i,command in ipairs({"i","tk","tkc","die","get","set","help","timekeepers"}) do
- system.disableChatCommandDisplay(command)
- end
- --Disability check
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- --Let's go!
- eventLoop(0,0)
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement