Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- -- RACING 3VS3
- -- Escrito por Eshkation 23/06/2016
- -- the cake is not a lie
- ---
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAutoNewGame()
- tfm.exec.disableAutoTimeLeft()
- local ADMINISTRADOR = "Osaisinho" -- CHANGE TO YOUR NICKNAME, SO YOU WILL BE GAME ADMIN
- local WINS = 10 -- POINTS TO WIN THE GAME
- system.disableChatCommandDisplay("np", true)
- system.disableChatCommandDisplay("pause", true)
- --[[
- After running the script, use the command !team1 Players and !team2 Players to set both players in the specified team
- Then you just need to press GO!
- Type !np @mapcode to run the next map.
- Type !score team1/team2 number to change its score.
- Type !pause to pause/unpause the game.
- ]]
- local teams = {
- [1] = {},
- [2] = {},
- }
- local points = {
- [1] = 0,
- [2] = 0,
- }
- local isfirst = false
- local gameRunning = false
- local winTime = false
- local playersInGame = {}
- local maps = {
- 114122, 116630, 148424, 150692, 156510, 165843, 166705, 180191, 180274, 180619, 196433, 198715, 208058, 208162, 209708, 212542, 213697, 217900, 223986, 226883, 227851, 229830, 231905, 232451, 232791, 236146, 239826, 239880, 241211, 242708, 245223, 246790, 255542, 258717, 260377, 261720, 266930, 271523, 277731, 281730, 286333, 287268, 299002, 299971, 305677, 308694, 308992, 309029, 314159, 315801, 317754, 323085, 323366, 332210, 332290, 339896, 340069, 341239, 343971, 344865, 345257, 348801, 349140, 352381, 355957, 356982, 357328, 359521, 363638, 365464, 365652, 367520, 381569, 381669, 386029, 391693, 391831, 393851, 401778, 405295, 405955, 410813, 412657, 414460, 414899, 416015, 418293, 418658, 419374, 421717, 423672, 424795, 425030, 425600, 429822, 429897, 430145, 431142, 431887, 434887, 445167, 447556, 470727, 471053, 477370, 499687, 501711, 504409, 505109, 507325, 508106, 508796, 509082, 512927, 514982, 531569, 536235, 563484, 571512, 594883, 595447, 606723, 611320, 616433, 664949, 694900, 737841, 813156, 849224, 982242, 1015582, 1033170, 1051384, 1058681, 1142116, 1195842, 1208798, 1214182, 1216253, 1255148, 1311059, 1364063, 1375345, 1448760, 1506007, 1512355, 1538895, 1601492, 1608638, 1619934, 1654841, 1663380, 1663415, 1689382, 1702169, 1724289, 1749434, 1768347, 1787232, 1813728, 1851968, 1856349, 1862823, 1927270, 1951856, 1956002, 1964752, 2012147, 2030343, 2070768, 2134537, 2141379, 2150335, 2221510, 2245005, 2331474, 2369254, 2683170, 2726034, 2796001, 2813487, 2816067, 3008155, 3156569, 3213562, 3444803, 3518418, 3537419, 3548376, 3548406, 3572407, 3575034, 3575108, 3620542, 3638794, 3654416, 3669435, 3676555, 3680223, 3685382, 3688419, 3700684, 3705931, 3716560, 3821104, 3889414, 4000001, 4234556, 4645670, 4707191, 4815404, 4911122, 4915220, 4946442, 5000090, 5024682, 5030579, 5032745, 5272513, 5346212, 5349806, 5408572, 5452432, 5495901, 5557858, 5590554, 5591416, 5712914, 5805021, 5813480, 5813783, 5861874, 5886041, 5972342, 6069526, 6112855, 6114810, 6172897, 6226519, 6276662, 6300594
- }
- local colors = {
- [1] = "ff6347",
- [2] = "19b5fe"
- }
- local queue = {}
- function newMap()
- local mapcode = maps[math.random(#maps)]
- if #queue > 0 then
- mapcode = queue[1]
- table.remove(queue, 1)
- end
- tfm.exec.newGame(mapcode)
- for player, data in pairs(tfm.get.room.playerList) do
- if not playersInGame[player] then
- tfm.exec.killPlayer(player)
- end
- end
- tfm.exec.setGameTime(60)
- end
- function eventPlayerWon(player)
- if not isfirst then
- isfirst = true
- tfm.exec.setGameTime(5)
- if table.contains(teams[1], player) then
- tfm.exec.setGameTime(5)
- for i = 0, 3 do
- defaultEffect(9, {13}, math.random(800), math.random(400), 20)
- end
- points[1] = points[1]+1
- elseif table.contains(teams[2], player) then
- tfm.exec.setGameTime(5)
- for i = 0, 3 do
- defaultEffect(9, {9}, math.random(800), math.random(400), 20)
- end
- points[2] = points[2]+1
- else
- isfirst = false
- end
- winner = false
- if points[1] >= WINS then
- winner = 1
- elseif points[2] >= WINS then
- winner = 2
- end
- if winner then
- gameRunning = false
- winTime = os.time()
- local names = {
- "Night's watch",
- "Apace"
- }
- ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>Team %s is the winner!\nGood job!", names[winner]), nil, 0, 171, 800, 500, 0, 0, 0, true)
- ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#000000'>Team %s is the winner!\nGood job!", names[winner]), nil, 1, 170, 800, 500, 0, 0, 0, true)
- ui.addTextArea(22, string.format("<p align='center'><font size='37'><font color='#FFFFFF'>Team <font color='#%s'>%s</font> is the winner!\nGood job!", colors[winner], names[winner]), nil, 1, 170, 800, 500, 0, 0, 0, true)
- end
- displayScore()
- end
- end
- function eventLoop(elapsed, remain)
- if gameRunning then
- remain = remain/1000
- if remain < 0 then
- remain = 100
- newMap()
- end
- else
- if winTime then
- if winTime > os.time()-30000 then
- for i = 0, 2 do
- defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
- end
- else
- winTime = false
- ui.removeTextArea(20)
- ui.removeTextArea(21)
- ui.removeTextArea(22)
- displayTeams()
- teams = {
- [1] = {},
- [2] = {},
- }
- points = {
- [1] = 0,
- [2] = 0,
- }
- playersInGame = {}
- end
- end
- end
- end
- function string.title(s)
- return string.gsub(s, "%a", function(c)
- return string.upper(c)
- end, 1)
- end
- function eventChatCommand(player, command)
- if player:lower() == ADMINISTRADOR:lower() then
- args = string.split(command, " ")
- if args[1] == "team1" then
- table.remove(args, 1)
- teams[1] = {}
- points[1] = 0
- for index, player in pairs(args) do
- player = string.title(player)
- table.insert(teams[1], player)
- playersInGame[player] = true
- end
- displayTeams()
- elseif args[1] == "team2" then
- table.remove(args, 1)
- teams[2] = {}
- points[2] = 0
- for index, player in pairs(args) do
- player = string.title(player)
- table.insert(teams[2], player)
- playersInGame[player] = true
- end
- displayTeams()
- elseif args[1] == "score" then
- if args[2] and args[3] then
- local team = tonumber(args[2]:match("team(%d+)") or 0)
- if team > 0 and team < 3 then
- local newScore = tonumber(args[3]) or points[team]
- points[team] = newScore
- displayScore()
- end
- end
- elseif args[1] == "np" then
- if args[2] then
- table.insert(queue, args[2])
- end
- elseif args[1] == "pause" then
- gameRunning = not gameRunning
- if not gameRunning then
- ui.addTextArea(90, "<p align='center'><font size='25'><R>P A U S E D", nil, 0, 200, 800, nil, 0, 0, 0, true)
- tfm.exec.disableAutoTimeLeft(true)
- else
- ui.removeTextArea(90)
- tfm.exec.disableAutoTimeLeft(false)
- end
- end
- end
- end
- function eventNewGame()
- if gameRunning then
- isfirst = false
- for i, p in pairs(teams[1]) do
- tfm.exec.setNameColor(p, "0x"..colors[1])
- end
- for i, p in pairs(teams[2]) do
- tfm.exec.setNameColor(p, "0x"..colors[2])
- end
- displayScore()
- end
- end
- function displayScore()
- ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
- ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
- ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> x <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
- end
- function displayTeams()
- ui.addTextArea(1, "", nil, 199, 69, 400, 260, 0x5A7A8B, 0x5A7A8B, 1, true)
- ui.addTextArea(2, "", nil, 201, 71, 400, 260, 0x0E1417, 0x0E1417, 1, true)
- ui.addTextArea(3, "", nil, 200, 70, 400, 260, 0x324650, 0x324650, 1, true)
- ui.addTextArea(4, "", nil, 209, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
- ui.addTextArea(5, "<p align='center'><V>Team 1", nil, 210, 80, 140, 20, 0x324650, 0x324650, 1, true)
- ui.addTextArea(6, "", nil, 449, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
- ui.addTextArea(7, "<p align='center'><V>Team 2", nil, 450, 80, 140, 20, 0x324650, 0x324650, 1, true)
- ui.addTextArea(8, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 210, 102, 140, 200, 0, 0, 0, true)
- ui.addTextArea(9, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 450, 102, 140, 200, 0, 0, 0, true)
- ui.addTextArea(10, "", nil, 209, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
- ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 210, 121, 138, 198, 0x324650, 0x324650, 1, true)
- ui.addTextArea(12, "", nil, 451, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
- ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 452, 121, 138, 198, 0x324650, 0x324650, 1, true)
- ui.addTextArea(14, "<p align='center'><font color='#5A7A8B'>____ ____</font>", nil, 330, 200, 140, 200, 0, 0, 0, true)
- ui.addTextArea(15, "", nil, 380, 202, 40, 20, 0x5A7A8B, 0x5A7A8B, 1, true)
- ui.addTextArea(16, "<p align='center'><V>VS", nil, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
- ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
- end
- function eventTextAreaCallback(id, player, callback)
- if callback == 'iniciarJogo' then
- if #teams[2] > 0 and #teams[1] > 0 then
- gameRunning = true
- for i = 1, 16 do
- ui.removeTextArea(i)
- end
- defaultEffect(9, {9}, 400, 212, 80)
- newMap()
- end
- end
- 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 table.contains(tableT, element)
- for _, value in pairs(tableT) do
- if value == element then
- return true
- end
- end
- return false
- 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
- displayTeams()
- function eventPlayerDied()
- local alive = 0
- for k,v in pairs(tfm.get.room.playerList) do
- if not v.isDead then
- alive = alive+1
- end
- end
- if alive < 2 then
- tfm.exec.setGameTime(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement