Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---Last update : 16/11/2015
- -----You may change the following 6 values----------
- -- 1) The maximum number of players in a team
- TEAM_SIZE = 4
- -- 2) The minimum number of players in a team
- MIN_SIZE = 2
- -- 3) Game time (seconds)
- TIME = 180
- -- 4) Length of the interval between rounds. (seconds)
- INTERVAL = 8
- -- 5) Time limit for each section. Players need to reach the next check point in SECTION_TIME seconds.
- SECTION_TIME = 15
- -- 6) Map list
- maps = {
- {"@500000", {{1, 69}, {513, 362}, {691, 290}, {510, 210}, {794, 74}, {527, 63}}, 5},
- {"@213755", {{631, 332}, {618, 197}, {415, 213}, {352, 146}, {535, 31}, {91, 168}}, 7},
- {"@213752", {{736, 300}, {546, 230}, {725, 92}, {286, 102}}, 5},
- {"@208653", {{759, 310}, {754, 177}, {204, 361}, {87, 201}}, 3},
- {"@205506", {{187, 246}, {353, 150}, {480, 161}, {763, 316}, {759, 140}}, 3},
- {"@205240", {{74, 353}, {167, 190}, {531, 340}, {582, 264}, {769, 112}, {701, 20}, {202, 290}, {33, 354}}, 7}, {"@204647", {{161, 148}, {520, 106}, {759, 37}, {571, 38}}, 5}, {"@204488", {{450, 348}, {748, 145}, {605, 61}, {447, 36}, {97, 343}}, 5}, {"@203664", {{325, 337}, {231, 220}, {540, 260}, {556, 142}, {276, 333}, {323, 206}}, 4}, {"@202574", {{302, 351}, {310, 253}, {488, 252}, {396, 156}, {422, 44}}, 5}, {"@201000", {{77, 348}, {36, 258}, {60, 73}, {770, 319}, {675, 221}, {552, 64}}, 4}, {"@195672", {{562, 327}, {743, 215}, {718, 54}, {371, 134}, {25, 359}}, 3}, {"@193662", {{737, 140}, {486, 132}, {481, 26}, {193, 245}, {170, 307}, {434, 221}, {529, 28}}, 5}, {"@192560", {{724, 328}, {719, 177}, {684, 36}, {501, 44}, {80, 330}, {87, 154}, {35, 195}, {425, 341}, {719, 361}, {719, 212}}, 7}, {"@191443", {{48, 156}, {187, 118}, {647, 369}, {757, 224}, {757, 31}}, 6}, {"@192158", {{492, 226}, {516, 26}, {253, 359}, {177, 217}}, 3}, {"@191203", {{770, 332}, {774, 162}, {590, 153}, {375, 154}, {60, 296}}, 5}, {"@191177", {{121, 333}, {116, 257}, {210, 132}, {406, 107}, {764, 171}}, 5}, {"@185428", {{476, 247}, {459, 181}, {401, 74}, {656, 30}}, 2}, {"@183139", {{558, 367}, {607, 285}, {716, 176}, {522, 111}, {150, 347}, {472, 40}}, 5}, {"@182769", {{760, 318}, {509, 147}, {155, 322}, {103, 211}}, 3}, {"@180801", {{189, 149}, {204, 28}, {414, 148}, {488, 336}, {359, 258}}, 4}, {"@176507", {{333, 184}, {509, 149}, {533, 47}, {176, 202}}, 4}, {"@175204", {{771, 315}, {794, 133}, {196, 342}, {101, 207}, {281, 101}}, 5}, {"@172951", {{772, 350}, {771, 156}, {291, 232}, {491, 137}, {619, 77}, {166, 365}}, 6}, {"@172520", {{750, 329}, {716, 207}, {462, 166}, {390, 59}}, 4}, {"@172512", {{241, 227}, {165, 116}, {151, 23}, {728, 25}, {651, 137}}, 6}, {"@172501", {{542, 337}, {744, 295}, {766, 165}, {716, 67}}, 5}, {"@171148", {{420, 260}, {721, 336}, {768, 333}, {721, 118}}, 3}, {"@169076", {{51, 208}, {373, 309}, {382, 203}, {765, 121}, {422, 304}}, 5}, {"@166430", {{498, 294}, {770, 308}, {629, 122}, {219, 246}, {24, 255}}, 3}, {"@163159", {{387, 315}, {436, 291}, {601, 199}, {244, 150}, {450, 114}, {726, 69}}, 3}, {"@160841", {{347, 361}, {237, 272}, {30, 359}, {-10, 262}, {65, 185}, {28, 137}, {214, 107}, {385, 92}}, 9}, {"@157960", {{70, 341}, {20, 340}, {20, 275}, {18, 130}, {23, 38}}, 1},
- {"@157203", {{504, 349}, {553, 349}, {660, 236}, {716, 54}, {142, 343}, {-15, 312}}, 5}, {"@157004", {{346, 245}, {393, 120}, {218, 29}, {717, 339}, {773, 316}, {743, 171}}, 4}, {"@151655", {{717, 297}, {738, 22}, {332, 250}, {287, 190}, {9, 199}, {16, 100}, {312, 115}}, 7}, {"@2329940", {{169, 217}, {212, 24}, {481, 293}, {288, 353}, {567, 352}, {317, 293}, {783, 142}, {610, 22}, {279, 208}}, 5}, {"@4445580", {{391, 227}, {762, 141}, {213, 86}, {154, 101}, {366, 206}}, 4}, {"@886744", {{232, 256}, {469, 340}, {499, 235}, {733, 80}, {422, 145}, {155, 161}}, 3}, {"@330933", {{615, 330}, {678, 329}, {700, 129}, {587, 88}, {541, 84}, {428, 211}, {380, 78}, {218, 129}}, 6}, {"@179807", {{647, 322}, {696, 158}, {771, 310}, {738, 181}, {582, 147}, {399, 239}}, 3}, {"@177652", {{753, 354}, {751, 282}, {270, 287}, {166, 82}, {344, 21}}, 5}, {"@206396", {{482, 352}, {498, 143}, {650, 147}, {697, 137}, {570, 27}, {215, 170}}, 6}, {"@179488", {{751, 329}, {747, 160}, {778, 62}, {502, 68}, {133, 268}}, 4}, {"@1427980", {{697, 212}, {546, 87}, {72, 151}, {340, 257}, {487, 163}, {314, 101}}, 3}, {"@815336", {{117, 346}, {204, 294}, {695, 161}, {466, 36}, {450, 324}, {173, 347}}, 4}, {"@161434", {{232, 211}, {312, 61}, {743, 367}, {789, 302}, {740, 259}, {764, 144}, {195, 371}, {8, 287}}, 6}, {"@216173", {{704, 247}, {767, 41}, {598, 128}, {355, 108}, {235, 244}, {6, 241}, {202, 287}, {318, 207}, {541, 268}, {730, 77}}, 6}, {"@172621", {{346, 367}, {393, 255}, {414, 155}, {687, 236}, {685, 98}, {523, 82}, {412, 72}}, 8}, {"@592189", {{615, 357}, {651, 88}, {390, 80}, {156, 54}, {110, 53}}, 3}, {"@168754", {{793, 33}, {129, 370}, {192, 314}, {252, 284}, {329, 271}}, 2}, {"@512887", {{391, 91}, {655, 81}, {457, 353}, {527, 175}, {739, 359}, {622, 83}, {294, 290}}, 5}, {"@306365", {{173, 196}, {215, 38}, {362, 351}, {409, 352}, {432, 252}, {462, 125}, {733, 101}, {596, 267}, {788, 327}, {704, 233}}, 7}, {"@2130169", {{14, 257}, {42, 101}, {434, 43}, {744, 168}, {520, 169}, {741, 368}}, 7}, {"@410045", {{450, 365}, {494, 300}, {251, 102}, {81, 140}, {59, 49}, {471, 240}, {721, 363}, {741, 249}}, 6}, {"@186066", {{490, 300}, {478, 190}, {530, 22}, {722, 100}, {140, 353}, {27, 305}, {41, 20}, {268, 191}, {357, 148}}, 4}, {"@2636519", {{759, 192}, {428, 173}, {720, 59}, {661, 103}, {204, 174}}, 4}, {"@263819", {{57, 276}, {66, 43}, {221, 182}, {374, 42}, {737, 39}, {631, 118}, {736, 340}, {480, 291}}, 8}, {"@528032", {{299, 105}, {331, 29}, {509, 81}, {576, 72}, {740, 39}, {160, 356}, {172, 277}, {34, 284}}, 8}, {"@511136", {{127, 253}, {163, 130}, {184, 42}, {455, 31}, {724, 113}}, 6}, {"@295932", {{566, 362}, {568, 254}, {580, 124}, {743, 58}, {697, 189}, {652, 188}, {725, 193}, {762, 111}, {602, 78}}, 6}, {"@271193", {{151, 303}, {185, 210}, {203, 92}, {308, 271}, {336, 70}, {440, 88}, {525, 64}, {744, 349}, {764, 245}, {726, 95}}, 8}, {"@3988424", {{299, 264}, {90, 80}, {644, 33}, {701, 83}, {518, 189}, {696, 263}, {556, 187}, {582, 32}}, 6}, {"@166032", {{687, 330}, {741, 316}, {736, 178}, {677, 40}, {357, 225}, {144, 254}, {1, 257}, {109, 36}, {639, 286}}, 9}, {"@460961", {{762, 377}, {705, 190}, {656, 155}, {651, 82}, {412, 163}, {286, 121}, {128, 78}, {420, 356}}, 8}, {"@315666", {{795, 178}, {106, 376}, {86, 296}, {85, 212}, {28, 39}, {350, 156}, {399, 157}, {445, 67}, {622, 94}}, 8}, {"@162482", {{634, 314}, {570, 193}, {722, 123}, {734, 52}, {547, 54}, {87, 310}}, 6}, {"@316012", {{163, 231}, {737, 370}, {644, 274}, {757, 179}, {646, 179}, {450, 220}, {346, 194}, {311, 71}}, 5}, {"@304861", {{64, 154}, {165, 64}, {365, 330}, {392, 328}, {438, 330}, {595, 263}, {589, 131}, {612, 45}}, 4}
- }
- --[[
- ----The structure of the map list----
- maps = {map data1, map data2, ... , map dataN}
- -map data -> {map code, check points coordinates, cheese check point}
- -map code -> for example "@500000"
- -check points coordinates -> {{x1, y1}, {x2, y2}, ..., {xM, yM}}
- -cheese check point is the number the first check point where mice are spawned with cheese
- ]]--
- ------Dont change anything below-----------
- print("length of maps: " .. tostring(#maps))
- if type(TEAM_SIZE) ~= type(1) then TEAM_SIZE = 4 end
- TEAM_SIZE = math.max(1, TEAM_SIZE)
- if type(TIME) ~= type(1) then TIME = 180 end
- TIME = math.max(60, TIME)
- if type(INTERVAL) ~= type(1) then INTERVAL = 8 end
- INTERVAL = math.max(3, INTERVAL)
- if type(SECTION_TIME) ~= type(1) then SECTION_TIME = 15 end
- SECTION_TIME = math.max(5, SECTION_TIME)
- if type(MIN_SIZE) ~= type(1) then MIN_SIZE = 2 end
- MIN_SIZE = math.min(TEAM_SIZE, math.max(1, MIN_SIZE))
- players = {}
- map = {cp={},ccp=1}
- teams = {}
- --[[
- teams[i] = {
- member = {}, :names
- runner = 1, :index of the current runner
- cp = 0, :the last check point (0:start point)
- cpTime = 0, :section time limit remaining (seconds)
- winTime = -1 :the time elapsed when the team wins since the start of the round(milliseconds)
- }
- ]]--
- countl = 0;
- interval = false;
- interval_rem = 0;
- IDs = {invitation = 0, interval = 1, message = 2, timer = 3, help = 4} -- 11, 12, 13,... are for check points
- text = {
- begin = "Let's begin! team: %s",
- begin_no_team = "No team was made",
- few_players = "Not enough players to make a team",
- alone = "Please wait for a new comer to make your team.",
- get_alone = "Your fellows have gone away.",
- join_team = "You joined a new team. Member : %s",
- new_member = "%s is now your teammate.",
- new_team = "A new team joined. Member : %s",
- finish = "Winner : %s<br>%s",
- invite = "Do you want to participate?"
- }
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoTimeLeft(true)
- function sendChatMessage(message, name, prefix, f)
- if name~=nil then
- if players[name] == nil then
- return
- end
- message=(text[players[name].lang] or text)[message] or message
- if prefix then
- message=prefix..message
- end
- if f then
- message=message:format(f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10])
- end
- --tfm.exec.chatMessage(message, name)
- --temporary
- if #(players[name].chat.messages)==5 then
- table.remove(players[name].chat.messages, 1)
- end
- table.insert(players[name].chat.messages, message)
- ui.updateTextArea(IDs.message, table.concat(players[name].chat.messages,"<br>"), name)
- --temporary
- else
- for name,player in pairs(tfm.get.room.playerList) do
- sendChatMessage(message, name, prefix, f)
- end
- end
- end
- function eventLoop(current, remaining)
- countl = countl + 1
- if interval then
- interval_rem = interval_rem - 1;
- if interval_rem <= 0 then
- interval = false
- startRound()
- showIntervalRemaining()
- else
- if interval_rem % 2 == 0 then
- showIntervalRemaining(interval_rem / 2)
- end
- end
- else
- if remaining < 500 then
- if not interval then
- finishRound();
- interval = true
- interval_rem = INTERVAL * 2
- showIntervalRemaining(interval_rem / 2)
- ui.addPopup(IDs.invitation, 1, "<font size=\"20\">Do you want to participate?</font>", nil, 250, 300, 300, true)
- end
- else
- for i, team in pairs(teams) do
- if team.winTime and team.winTime < 0 then
- if team.cpTime > SECTION_TIME then
- tfm.exec.killPlayer(team.member[team.runner])
- end
- team.cpTime = team.cpTime + 0.5
- if team.cpTime % 1 == 0 then
- for j, name in pairs(team.member) do
- ui.updateTextArea(IDs.timer, SECTION_TIME - team.cpTime, name)
- end
- end
- end
- end
- end
- end
- end
- function showIntervalRemaining(remaining)
- if not remaining then
- for name, player in pairs(players) do
- if player.attendance == nil then
- ui.addTextArea(IDs.interval, "This round has already begun.", name, 250, 250, 300, 30, 0x324650, 0, 1, true)
- else
- ui.removeTextArea(IDs.interval, name)
- end
- end
- else
- ui.addTextArea(IDs.interval, "The next round will start in ".. tostring(remaining) .. " seconds.", nil, 250, 250, 300, 30, 0x324650, 0, 1, true)
- end
- end
- function eventPopupAnswer(id, name, answer)
- local p = players[name]
- if id == IDs.invitation then
- if answer=="yes" then
- if p.attendance then
- return
- end
- p.attendance = true
- if not interval then
- reconstructTeams(name)
- end
- else
- p.attendance = false
- end
- if not interval then
- ui.removeTextArea(IDs.interval, name)
- end
- end
- end
- function eventNewPlayer(name)
- tfm.exec.bindKeyboard(name, 32, true, true)
- tfm.exec.bindKeyboard(name, 9, true, true)
- ui.addTextArea(IDs.timer, "10", name, 780, 20, 20, 15, 0,0,0, true)
- ui.addTextArea(IDs.message, "", name, 10, 20, 500,300,0,0,0,true) --temporary alternative for the chat area
- players[name]={
- name=name,
- lang=roomLang,
- attendance = nil, --nil, true, false
- chat={type=0, messages={}} -- temporary alternative for the chat area
- }
- if not interval then showIntervalRemaining() end
- ui.addPopup(IDs.invitation, 1, "<font size=\"20\">Do you want to participate?</font>", name, 250, 300, 300, true)
- drawCheckPoint(name)
- eventChatCommand(name, "help")
- end
- function startRound()
- local mp = queue or maps[math.random(#maps)][1]
- queue = nil
- tfm.exec.newGame(mp)
- end
- function eventNewGame()
- local sum
- local member = {}
- local nteam
- local tem
- local tem2
- local rnd
- local formation = {}
- map = {}
- map.code = "@" .. tostring(tfm.get.room.xmlMapInfo.mapCode)
- for i,mapdata in pairs(maps) do
- if map.code == mapdata[1] then
- tem = mapdata
- break;
- end
- end
- if not tem then
- tem = {map.code, {}}
- end
- if tem[2] and type(tem[2])==type({}) then
- for i = 1, #tem[2] do
- tem2 = tem[2][i]
- if not (type(tem2)==type({}) and type(tem2[1])==type(1) and type(tem2[2])==type(1)) then
- print("Invalid check points")
- tem[2] = nil
- break
- end
- end
- else
- print("Invalid check points")
- tem[2] = nil
- end
- map.cp = tem[2] or {} --check points
- if type(tem[3])~=type(1) then
- tem[3] = #(map.cp) + 1
- else
- tem[3] = math.min(#(map.cp) + 1, math.max(1, tem[3]))
- end
- map.ccp = tem[3] or #(map.cp) + 1 --the first check point requiring cheese
- --Make up teams
- for name, player in pairs(players) do
- if player.attendance then
- table.insert(member, name)
- end
- end
- sum = #member
- if sum < MIN_SIZE * 2 then
- if sum >= MIN_SIZE then
- table.insert(formation, math.min(sum, TEAM_SIZE))
- end
- elseif sum <= TEAM_SIZE then
- tem = math.floor(sum/2)
- table.insert(formation, tem)
- table.insert(formation, sum - tem)
- else
- nteam = math.ceil(sum / TEAM_SIZE)
- tem = math.floor(sum / nteam)
- if tem < MIN_SIZE then
- for i = 1, nteam - 1 do
- table.insert(formation, TEAM_SIZE)
- end
- else
- for i = 1, sum % nteam do
- table.insert(formation, tem + 1)
- end
- for i = (sum % nteam) + 1, nteam do
- table.insert(formation, tem)
- end
- end
- end
- teams = {}
- for i, value in pairs(formation) do
- teams[i] = {
- member = {},
- runner = 1,
- cp = 0,
- cpTime = 0,
- winTime = -1
- }
- for h = 1, value do
- rnd = math.random(#member)
- teams[i].member[h] = member[rnd]
- players[member[rnd]].team = teams[i]
- table.remove(member, rnd)
- end
- end
- for i, name in pairs(member) do
- sendChatMessage("alone", name)
- end
- local t = {}
- for i, team in pairs(teams) do
- table.insert(t, table.concat(team.member, "-"))
- end
- if #teams == 0 then
- sendChatMessage("begin_no_team")
- else
- sendChatMessage("begin", nil, nil, {table.concat(t, " vs ")})
- end
- for i = 1, map.ccp - 1 do
- ui.addTextArea(10 + i, "", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xBBFFBB, 0.5)
- end
- for i = map.ccp, #(map.cp) do
- ui.addTextArea(10 + i, "<font size=\"20\" color=\"#EFD76D\"><b>C</b></font>", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xBBFFBB, 0.5)
- end
- for i, team in pairs(teams) do
- for h = 2, #(team.member) do
- tfm.exec.killPlayer(team.member[h])
- end
- end
- tfm.exec.setGameTime(TIME)
- end
- function drawCheckPoint(name)
- if name then
- local p = players[name]
- if p.team then
- for i=1, p.team.cp do
- ui.removeTextArea(10 + i, name)
- end
- for i = p.team.cp + 1, map.ccp - 1 do
- ui.addTextArea(10 + i, "", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xFFFFFF, 0.5)
- end
- for i = math.max(map.ccp, p.team.cp + 1), #(map.cp) do
- ui.addTextArea(10 + i, "<font size=\"20\" color=\"#EFD76D\"><b>C</b></font>", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xBBFFBB, 0.5)
- end
- else
- for i = 1, map.ccp - 1 do
- ui.addTextArea(10 + i, "", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xFFFFFF, 0.5)
- end
- for i = map.ccp, #(map.cp) do
- ui.addTextArea(10 + i, "<font size=\"20\" color=\"#EFD76D\"><b>C</b></font>", nil, map.cp[i][1] - 12, map.cp[i][2] - 12, 25, 25, 0x91A918, 0xBBFFBB, 0.5)
- end
- end
- else
- for n, player in pairs(players) do
- drawCheckPoint(n)
- end
- end
- end
- function eventKeyboard(name, code, down, x, y)
- local p = players[name]
- local p2 = tfm.get.room.playerList[name]
- local lim
- if code==32 then
- local team = p.team
- if team and team.member[team.runner] == name then
- if p2.hasCheese then
- lim = #(map.cp)
- else
- lim = map.ccp - 1
- end
- for i = team.cp + 1, lim do
- if (map.cp[i][1] - x)^2 + (map.cp[i][2] - y)^2 < 256 then
- team.cp = i
- team.cpTime = 0
- for j, name in pairs(team.member) do
- for h=1, i do
- ui.removeTextArea(10 + h, name)
- end
- end
- break
- end
- end
- end
- elseif code==9 then --tribe house only
- local message = table.concat(players[name].chat.messages, "<br>")
- local type = players[name].chat.type
- ui.removeTextArea(IDs.message, name);
- if type % 3 == 0 then
- ui.addTextArea(IDs.message, message, name, 10, 20, 400, 150, 0x583d23, 0xFFFFFF, 1, true)
- elseif type % 3 == 2 then
- ui.addTextArea(IDs.message, message, name, 10, 20, 400, 150, 0, 0, 0, true)
- end
- players[name].chat.type = type + 1
- end
- end
- function eventPlayerDied(name)
- local pname
- local team = nil
- if players[name] then
- team = players[name].team
- if team and team.member[team.runner]==name then
- local cp_xy = map.cp[team.cp]
- team.runner = (team.runner % #(team.member)) + 1
- pname = team.member[team.runner]
- tfm.exec.respawnPlayer(pname)
- if team.cp > 0 then
- if team.cp >= map.ccp then
- tfm.exec.giveCheese(pname)
- end
- tfm.exec.movePlayer(pname, cp_xy[1], cp_xy[2])
- end
- team.cpTime = 0
- elseif not team then
- tfm.exec.respawnPlayer(name)
- end
- end
- end
- function eventPlayerWon(name, time)
- local p = players[name]
- local team = p.team
- if team and team.member[team.runner]==name then
- for i, pname in pairs(team.member) do
- if pname ~= name then
- tfm.exec.respawnPlayer(pname)
- tfm.exec.giveCheese(pname)
- tfm.exec.playerVictory(pname)
- end
- end
- team.winTime = time
- end
- for i, team in pairs(teams) do
- if team.winTime==nil or team.winTime < 0 then
- return
- end
- end
- eventLoop(0,0)
- end
- function finishRound()
- local rank = ""
- local winner
- for i, team in pairs(teams) do
- if team.winTime < 0 then
- team.winTime = 10000
- end
- end
- table.sort(teams, function (a,b) return (a.winTime < b.winTime) end)
- if teams[1] and teams[1].winTime ~= 10000 then
- winner = table.concat(teams[1].member, "-") .."(".. tostring(teams[1].winTime / 100).."s) "
- for i=2, #teams do
- if teams[i].winTime == 10000 then break end
- rank = rank..tostring(i)..":"..table.concat(teams[i].member, "-").."("..tostring(teams[i].winTime / 100).."s) ";
- end
- sendChatMessage("finish", nil, nil, {winner, rank})
- end
- for name, player in pairs(players) do
- player.attendance = nil
- player.team = nil
- player.skip = nil
- player.mirror = nil
- end
- for i=1 , #(map.cp) do
- ui.removeTextArea(10 + i, nil)
- end
- end
- function eventPlayerLeft(name)
- local p = players[name]
- local team = p.team
- if team and team.winTime < 0 then
- for i, pname in pairs(team.member) do
- if pname==name then
- table.remove(team.member,i)
- break
- end
- end
- reconstructTeams(nil, team)
- end
- players[name] = nil
- end
- function reconstructTeams(comer, leftTeam)
- local recruit = {}
- local free = {}
- local tem
- local sum
- for name, player in pairs(players) do
- if not player.team and player.attendance then
- table.insert(free, name)
- end
- end
- local i = 1
- while i <= #(teams) do
- if teams[i].winTime > 0 then
- i = i + 1
- else
- tem = #(teams[i].member)
- if tem < TEAM_SIZE then
- if tem + #free < MIN_SIZE then
- for j = 1, tem do
- table.insert(free, teams[i].member[j])
- players[teams[i].member[j]].team = nil
- end
- table.remove(teams, i)
- else
- for j = 1, math.min(TEAM_SIZE-tem, #free) do
- table.insert(teams[i].member, free[1])
- players[free[1]].team = teams[i]
- sendChatMessage("join_team", free[1], nil, {table.concat(teams[i].member, "-")})
- for h, name in pairs(teams[i].member) do
- if name~=free[1] then sendChatMessage("new_member", name, nil, {free[1]}) end
- end
- table.remove(free, 1)
- end
- i = i + 1
- end
- else
- i = i + 1
- end
- end
- end
- if #free >= MIN_SIZE then
- tem = {
- member = {},
- runner = 1,
- cp = 0,
- cpTime = 0,
- winTime = -1
- }
- for i = 1, math.min(TEAM_SIZE, #free) do
- tem.member[i] = free[i]
- players[free[i]].team = tem
- end
- table.insert(teams, tem)
- sendChatMessage("new_team", nil, nil, {table.concat(tem.member, "-")})
- end
- for i, team in pairs(teams) do
- if team.runner > #(team.member) then
- team.runner = 1
- end
- for h, name in pairs(team.member) do
- if name~=team.member[team.runner] then
- tfm.exec.killPlayer(name)
- else
- tfm.exec.respawnPlayer(name)
- end
- end
- end
- if comer~=nil and players[comer].team==nil then
- sendChatMessage("alone", comer)
- end
- if leftTeam then
- for i, member in pairs(leftTeam.member) do
- if players[member].team==nil then
- sendChatMessage("get_alone", member)
- end
- end
- end
- drawCheckPoint()
- end
- function eventChatCommand(name, message)
- local args={}
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- if args[1] == "join" then
- eventPopupAnswer(IDs.invitation, name, "yes")
- elseif args[1] == "map" and name=="Gekkeiju" then
- queue = args[2]
- eventLoop(0, 0)
- elseif args[1] == "skip" then
- if interval then return end
- players[name].skip = true
- local sum = 0
- local yes = 0
- for name, player in pairs(players) do
- if player.attendance then
- if player.skip then yes = yes + 1 end
- sum = sum + 1
- end
- end
- if yes/sum > 0.7 then
- eventLoop(0, 0)
- end
- elseif args[1] == "help" then
- ui.addPopup(IDs.help, 0, '<p align ="center"><font size="20">Welcome to Bootcamp Relay!</font></p><font size="15" color="#55FF55">~Rules~</font><font size="12"><li>Work for your teammates</li><li>Rectangles are check points. Press Space key on a check point and the next player will respawn there</li><li>Get to a check point in 15 seconds after leaving the last one</li><li>You need cheese to check at the check points with a yellow"C". Your teammates will respawn there with cheese.</li><li>Type !skip to skip the map (70% votes are required)</li><li>Type !mirror if the check points arrangement needs reversing. (50% votes are required)</li></font>', name, 181, 146, 488, true)
- elseif args[1] == "mirror" then
- if interval then
- return
- end
- players[name].mirror = true
- local sum = 0
- local yes = 0
- for name, player in pairs(players) do
- if player.mirror then
- yes = yes + 1
- end
- sum = sum + 1
- end
- if yes/sum > 0.5 then
- reverseCheckPoint()
- end
- end
- end
- function reverseCheckPoint()
- if map.mirror then return end
- map.mirror = true
- for i, p in pairs(map.cp) do
- p[1] = 800 - p[1]
- end
- drawCheckPoint()
- end
- for name, player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- eventLoop(0,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement