Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- -- The racer #8 07/02/2015, escrito por Eshkation
- --
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- for index, command in pairs ({"admin", "game", "queue", "score", "pause"}) do
- system.disableChatCommandDisplay(command, true)
- end
- local _S = {
- segments = {
- windows = {},
- },
- config = {
- pauseonleft = {"Pause on DC", true},
- killnonpart = {"Kill guests", true},
- firsts = {"Number of points", 10, 1},
- difference = {"Points difference", 2, 1},
- pausetime = {"Dwell time", 120, 60},
- gametime = {"Map time ", 60, 5},
- restartpause = {"Restart dwell", false},
- },
- players = {},
- command = string.format("%x", math.random(0x000000, 0xFFFFFF)),
- gameRunning = false,
- first = false,
- pause = 0,
- party = false,
- tick = os.time(),
- maps = {
- 6730473, 6572872, 6087537, 6070140, 6063528, 5922046, 5699298, 5654008, 5630711, 5515862, 5488573, 5382687, 5339441, 5309288, 5303681, 5096937, 5067265, 5045922, 5045485, 5044309, 5028454, 4945098, 4778991, 4747722, 4581354, 4551993, 4508416, 4477124, 4220406, 4148332, 4102732, 4091580, 4088129, 3992276, 3970909, 3953425, 3854268, 3847244, 3834905, 3801780, 3799507, 3778128, 3705931, 3702767, 3696662, 3691609, 3685486, 3685382, 3685352, 3683393, 3683294, 3639993, 3636268, 3631534, 3611702, 3603802, 3556690, 3556489, 3549840, 3453351, 3408247, 3399991, 3267620, 3175920, 3156569, 3123384, 3008155, 2840770, 2816067, 2813487, 2776889, 2725924, 2683170, 2582610, 2571671, 2522826, 2393139, 2331474, 2245005, 2223685, 2150335, 2141379, 2138401, 2134537, 2106576, 2101747, 2089069, 2076632, 2070768, 2030343, 2023552, 2012147, 1985019, 1975684, 1964800, 1964752, 1956555, 1956002, 1952851, 1951856, 1927270, 1914792, 1862823, 1856349, 1841744, 1813728, 1787239, 1787232, 1759287, 1749434, 1718723, 1694602, 1659716, 1659639, 1654903, 1654841, 1651658, 1632746, 1632706, 1632294, 1621611, 1619934, 1608638, 1605364, 1602654, 1601492, 1592767, 1583655, 1573213, 1564762, 1555532, 1539791, 1538895, 1512355, 1506007, 1453667, 1448760, 1425101, 1405496, 1405249, 1404528, 1375345, 1372941, 1371294, 1368222, 1364063, 1358446, 1341396, 1311059, 1256845, 1255148, 1250021, 1249601, 1216253, 1214182, 1208798, 1195842, 1142116, 1132639, 1085530, 1019378, 1017676, 1015436, 979179, 976786, 789128, 646800, 608459, 606666, 603381, 586688, 580031, 571512, 564033, 563484, 563303, 556253, 538116, 537776, 536235, 531569, 529844, 523046, 517697, 514982, 514510, 512927, 512291, 511187, 509082, 508796, 508106, 507325, 505963, 505109, 504704, 504409, 501428, 499687, 496945, 480023, 475151, 470727, 470687, 447556, 445167, 444490, 443309, 436447, 434887, 431887, 431142, 430736, 430145, 429897, 429822, 428517, 426638, 425806, 425600, 425044, 425030, 424795, 424361, 423672, 421717, 420806, 419374, 418658, 418293, 416142, 410532, 407294, 406982, 406486, 406266, 405075, 404440, 401945, 399633, 398942, 398011, 397938, 397501, 396861, 396347, 395607, 395585, 394890, 393851, 391868, 391831, 391693, 387638, 387290, 387270, 387012, 379866, 375381, 372970, 370850, 370444, 365774, 363822, 363625, 360365, 360201, 355676, 352381, 350251, 349140, 348801, 345312, 345257, 344865, 344361, 337774, 335507, 335458, 333277, 333071, 333068, 322771, 321906, 321814, 321712, 313091, 309057, 304356, 291628, 285752, 283715, 282434, 270819, 263182, 263163, 262239, 261172, 260338, 252759, 244699, 237297, 237278, 234959, 234039, 233345, 232699, 231694, 230741, 230510, 229944, 229814, 216439, 213933, 197219, 195720, 193936, 192566, 192391, 184110, 181312, 180469, 180255, 178545, 177236, 176263, 169892, 165843, 160762, 159351, 155168, 144468, 138678, 128522, 120152, 117548, 114122
- },
- queue = {}
- }
- function _S.announceAdmin(player)
- if player then
- display(2, 1, string.format("<p align=\"center\">%s become tournament administrator!</font>", player))
- _S.displayMenu(player)
- end
- end
- function _S.displayMenu(player)
- ui.addTextArea(1, "<a href=\"event:display options\">Options</a>", player, 5, 20, 50, 17, 0x323747, 0x1C1E26, 1, true)
- ui.addTextArea(2, "<a href=\"event:display players\">Guests</a>", player, 64, 20, 45, 17, 0x323747, 0x1C1E26, 1, true)
- end
- function _S.newMap()
- tfm.exec.newGame(_S.queue[1] or _S.maps[math.random(#_S.maps)])
- table.remove(_S.queue, 1)
- end
- function _S.updateScore()
- local text = ""
- local t = false
- for player, data in pairs(_S.players) do
- if data.ingame then
- t = not t
- if t then
- text = text..string.format("%s %s ", player, data.points)
- else
- text = text..string.format("x %s %s", data.points, player)
- end
- end
- end
- ui.addTextArea(-4, "<p align=\"center\"><font size=\"17\" color=\"#1C1E26\">"..text, nil, 0, 21, 800, nil, 0, 0, 0, true)
- ui.addTextArea(-3, "<p align=\"center\"><font size=\"17\" color=\"#1C1E26\">"..text, nil, 1, 20, 800, nil, 0, 0, 0, true)
- if _S.pause == 0 then
- ui.addTextArea(-1, "<p align=\"center\"><N><font size=\"17\">"..text, nil, 0, 20, 800, nil, 0, 0, 0, true)
- else
- ui.addTextArea(-1, "<p align=\"center\"><R><font size=\"17\">"..text, nil, 0, 20, 800, nil, 0, 0, 0, true)
- end
- for player, data in pairs(_S.players) do
- if data.admin then
- _S.displayMenu(player)
- end
- end
- end
- function _S.getDifference(name)
- local diff = 0
- for player, data in pairs(_S.players) do
- if data.ingame and player ~= name then
- diff = diff+(_S.players[name].points-data.points)
- end
- end
- return diff
- end
- function eventPlayerWon(player, time)
- if not _S.first and _S.players[player].ingame and _S.pause == 0 then
- _S.first = true
- _S.players[player].points = _S.players[player].points+1
- display(1, 2, string.format("<font size=\"30\"><N2>FIRST!</N2>\n<font size=\"16\">Score %s: %s", player, _S.players[player].points))
- local difference = _S.getDifference(player)
- _S.updateScore()
- tfm.exec.setGameTime(3, true)
- if difference >= _S.config.difference[2] and _S.players[player].points >= _S.config.firsts[2] then
- display(1, 2, string.format("<font size=\"30\"><N2>END OF THE GAME!</N2>\n<font size=\"16\">%s won with difference of %s points!", player, difference))
- _S.party = os.time()
- _S.gameRunning = false
- tfm.exec.newGame("@6575947")
- tfm.exec.setNameColor(player, 0xFFCB00)
- for player, data in pairs(_S.players) do
- data.ingame = false
- data.points = 0
- data.pause = false
- end
- end
- end
- end
- function eventTextAreaCallback(id, player, callback)
- if callback == "display players" then
- local text = ""
- for player, data in pairs(tfm.get.room.playerList) do
- local pl = ""
- local t = false
- if _S.players[player].admin then
- pl = "[<VP>Owner</VP>]"
- t = true
- end
- if _S.players[player].ingame then
- pl = pl.."[<VP>Participants</VP>]"
- t = true
- end
- if not t then
- pl = pl.."[<G>Guests</G>]"
- end
- pl = pl.." "..player
- text = string.format("%s %s\n", text, pl)
- end
- text = text.." [<a href=\"event:closeText 3\"><R>CLOSE</R></a>]"
- ui.addTextArea(3, text, player, 64, 45, nil, 17, 0x323747, 0x1C1E26, 1, true)
- elseif callback == "display options" then
- local text = "<br><p align=\"center\"><font size=\"20\"><J>O P T I O N S"
- ui.addTextArea(12, text, player, 199, 69, 322, 262, 0x323747, 0x1C1E26, 1, true)
- ui.addTextArea(11, "[<a href=\"event:closeText 12 11 10\"><R>CLOSE</R></a>]", player, 460, 75, nil, nil, nil, nil, 0, true)
- text = "<font face=\"Lucida Console\"><textformat tabstops=\"[80, 160, 200, 240]\">"
- local n = 0
- for config, data in pairs(_S.config) do
- if type(data[2]) == "number" then
- text = text..string.format("<N2>%s<N>:\t[<R><a href=\"event:setConfig %s %s\">-%s</a></R>]\t[<V>%s</V>]\t[<R><a href=\"event:setConfig %s %s\">+%s</a></R>]\n", data[1], config, data[2]-data[3], data[3], data[2], config, data[2]+data[3], data[3])
- elseif type(data[2]) == "boolean" then
- text = text..string.format("<N2>%s<N>:\t[<R><a href=\"event:setConfig %s true\">YES</a></R>]\t[<V>%s</V>]\t[<R><a href=\"event:setConfig %s false\">NO</a></R>]\n", data[1], config, data[2] == true and "YES" or "NO", config)
- end
- n = n+1
- end
- n = 13-n
- local t = ""
- for i = 0, n do t = t.."\n" end
- ui.addTextArea(10, text.."</textformat>"..t, player, 220, 140, nil, nil, 0x41475B, 0x1C1E26, 1, true)
- elseif callback:sub(0, 9) == "closeText" then
- args = string.split(callback:sub(11), " ")
- for index, arg in pairs(args) do
- ui.removeTextArea(arg, player)
- end
- elseif callback:sub(0, 9) == "setConfig" then
- args = string.split(callback:sub(11), " ")
- if _S.config[args[1]] then
- _S.config[args[1]][2] = tonumber(args[2]) or args[2] == "true" and true or false
- end
- eventTextAreaCallback(id, player, "display options")
- end
- end
- function display(dp, id, text, player)
- local textWidth = #(text:gsub(" ",""))*3
- if dp == 1 then
- ui.addTextArea(id.."000", "<p align=\"center\"><font face=\"Verdana\">"..text, player, 5, 155, 790, nil, 0x323747, 0x1C1E26, 1, true)
- elseif dp == 2 then
- ui.addTextArea(id.."000", "<font face=\"Verdana\">"..text, player, 5, 382, nil, nil, 0x323747, 0x1C1E26, 1, true)
- end
- _S.segments.windows[id] = {stime = os.time()}
- end
- function eventNewPlayer(player)
- if not _S.players[player] then
- _S.players[player] = {admin = false, ingame = false, points = 0, pause = false, pauseTick = false}
- end
- end
- function eventNewGame()
- if _S.gameRunning then
- ui.removeTextArea(3)
- ui.removeTextArea(4)
- ui.removeTextArea(5)
- _S.first = false
- if _S.config.killnonpart[2] then
- for player, data in pairs(_S.players) do
- if not data.ingame then
- tfm.exec.killPlayer(player)
- end
- end
- end
- tfm.exec.setGameTime(_S.config.gametime[2])
- _S.updateScore()
- end
- end
- function eventLoop(elapsed, remain)
- if _S.gameRunning then
- remain = remain/1000
- if remain < 0 then
- remain = 100
- _S.newMap()
- end
- end
- if _S.party then
- if _S.party > os.time()-60000 then
- for i = 5, 0, -1 do
- ids = {{11, 13, 9, 0}, {9, 0}, {11, 9}, {0, 4}, {4}, {13}, {13, 0}}
- x = math.random(800)
- y = math.random(400)
- id = ids[math.random(#ids)]
- defaultEffect(1, id, x, y, 35)
- end
- else
- _S.party = false
- end
- end
- for id, data in pairs(_S.segments.windows) do
- if data.stime < os.time()-5000 then
- ui.removeTextArea(id.."000")
- tfm.exec.removePhysicObject(id)
- id = nil
- end
- end
- if _S.pause > 0 and _S.tick < os.time()-1000 then
- _S.tick = os.time()
- local text = ""
- for player, data in pairs(_S.players) do
- if data.pause then
- data.pauseTick = data.pauseTick-1
- local timeStamp = string.format("%.2d:%.2d:%.2d", data.pauseTick/(60*60), data.pauseTick/60%60, data.pauseTick%60)
- text = text..string.format("%s <font size=\"12\">%s\n", player, timeStamp)
- if data.pauseTick == 0 then
- data.pause = false
- display(3, 1, string.format("<font size=\"30\"><N2>TEMPO ESGOTADO!</N2>\n<font size=\"16\">O tempo de %s esgotou!", player))
- _S.pause = _S.pause-1
- end
- end
- end
- if #text > 1 then
- ui.addTextArea(3, "<font size=\"15\" color=\"#1C1E26\">"..text, nil, 561, 20, 255, nil, 0x323747, 0x1C1E26, 0, true)
- ui.addTextArea(4, "<font size=\"15\" color=\"#1C1E26\">"..text, nil, 560, 21, 255, nil, 0x323747, 0x1C1E26, 0, true)
- ui.addTextArea(5, "<N><font size=\"15\">"..text, nil, 560, 20, 255, nil, 0x323747, 0x1C1E26, 0, true)
- else
- ui.removeTextArea(3)
- ui.removeTextArea(4)
- ui.removeTextArea(5)
- end
- end
- end
- function eventChatCommand(player, command)
- if command == _S.command then
- _S.command = tostring(math.random())
- _S.players[player].admin = true
- _S.announceAdmin(player)
- end
- local args = string.split(command, " ")
- if _S.players[player].admin then
- if args[1] == "admin" and args[2] then
- local passivePlayer = string.title(args[2])
- _S.players[passivePlayer].admin = true
- _S.announceAdmin(passivePlayer)
- elseif args[1] == "queue" and args[2] then
- table.insert(_S.queue, args[2])
- display(2, 1, string.format("Mapa %s adicionado na queue na posição #%s", args[2], #_S.queue), player)
- elseif args[1] == "score" and args[2] then
- local passivePlayer = string.title(args[2])
- if tfm.get.room.playerList[passivePlayer] then
- if _S.players[passivePlayer].ingame then
- _S.players[passivePlayer].points = tonumber(args[3]) or _S.players[passivePlayer].points
- display(2, 1, string.format("%s mudou o placar de %s para %s!", player, passivePlayer, _S.players[passivePlayer].points), nil)
- end
- else
- display(2, 1, string.format("%s não se encontra na sala!", passivePlayer), player)
- end
- _S.updateScore()
- elseif args[1] == "pause" and args[2] then
- local passivePlayer = string.title(args[2])
- if tfm.get.room.playerList[passivePlayer] then
- if _S.players[passivePlayer].pause then
- _S.players[passivePlayer].pause = false
- _S.pause = _S.pause-1
- ui.removeTextArea(3, nil)
- ui.removeTextArea(4, nil)
- ui.removeTextArea(5, nil)
- display(1, 1, string.format("<font size=\"30\"><N2>TEMPO RETOMADO!</N2>\n<font size=\"16\">%s retomou o tempo de %s", player, passivePlayer))
- for player, data in pairs(_S.players) do
- tfm.exec.killPlayer(player)
- end
- tfm.exec.setGameTime(3, true)
- else
- display(1, 1, string.format("<font size=\"30\"><N2>JOGO PAUSADO!</N2>\n<font size=\"16\">%s pausou o tempo para %s", player, passivePlayer))
- if not _S.config.restartpause then
- _S.players[passivePlayer].pauseTick = _S.players[player].pauseTick
- else
- _S.players[passivePlayer].pauseTick = _S.config.pausetime[2]
- end
- _S.players[passivePlayer].pause = true
- _S.pause = _S.pause+1
- end
- else
- display(2, 1, string.format("%s não se encontra na sala!", passivePlayer), player)
- end
- _S.updateScore()
- elseif args[1] == "game" and args[3] then
- _S.party = false
- local player1 = string.title(args[2])
- local player2 = string.title(args[3])
- if tfm.get.room.playerList[player1] then
- if tfm.get.room.playerList[player2] then
- for player, data in pairs(_S.players) do
- if data then
- data.ingame = false
- data.points = 0
- data.pause = false
- end
- end
- _S.pause = 0
- _S.players[player1].ingame = true
- _S.players[player2].ingame = true
- _S.gameRunning = true
- tfm.exec.setGameTime(3, true)
- display(1, 1, string.format("<font size=\"30\"><N2>New Match by Awroth!</N2>\n<font size=\"16\">%s vs %s", player1, player2))
- else
- display(2, 1, string.format("%s não se encontra na sala!", player2), player)
- end
- else
- display(2, 1, string.format("%s não se encontra na sala!", player1), player)
- end
- end
- end
- end
- function eventPlayerLeft(passivePlayer)
- if not _S.party then
- if _S.config.pauseonleft[2] then
- if _S.players[passivePlayer] and _S.players[passivePlayer].ingame then
- display(1, 1, string.format("<font size=\"30\"><N2>MATCH PAUSED!</N2>\n<font size=\"16\">%s pausou o tempo para %s", "System", passivePlayer))
- if not _S.config.restartpause then
- _S.players[passivePlayer].pauseTick = _S.players[player].pauseTick
- else
- _S.players[passivePlayer].pauseTick = _S.config.pausetime[2]
- end
- _S.players[passivePlayer].pause = true
- _S.pause = _S.pause+1
- end
- end
- end
- end
- function string.title(s, n)
- return string.gsub(s, "(%S+)", function(char) return char:lower():gsub("%a", string.upper, 1) end, n)
- end
- function string.split(s, pattern, n)
- local st = {}
- for sb in string.gmatch(s, "[^"..pattern.."]+") do
- if not n or n > -1 then
- table.insert(st,sb)
- else
- st[#st] = st[#st]..pattern..sb
- end
- n = n and n-1 or false
- end
- return st
- end
- function INIT()
- print(string.format("<font color=\"#AAAAAA\">[=] Para poder iniciar os comandos do torneio, por favor digite este comando no chat: !%s</font>", _S.command))
- for player, _ in pairs(tfm.get.room.playerList) do
- eventNewPlayer(player)
- end
- tfm.exec.newGame("@6575947")
- end
- defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
- local minDist = 1
- local outerBorder = 20
- local maxDist = 30
- local totalParticles = rand and 40 or (id == -1 and 35 or 75)
- for i = 1, totalParticles do
- if rand then
- id = p[math.random(#p)]
- end
- local dist = math.min(math.random(minDist, maxDist), outerBorder)
- local angle = math.random(0, 360)
- local r = math.rad(angle)
- local dx = math.cos(r)
- local dy = math.sin(r)
- local vx = dist * dx / 10
- local vy = dist * dy / 10
- local ax = -vx / dist / 15
- local ay = (-vy / dist / 15) + 0.05
- if id == -1 then
- tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
- tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
- else
- tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
- end
- end
- end
- INIT()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement