Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tribe_name = tfm.get.room.name:sub(2)
- local enable_rotation = false
- local admins = {} -- Não é necessário por seu nick caso você que vá carregar o script
- local maps = {3107377, 305748, 1539148, 4543602, 390649, 495880, 1463332, 1492805, 292678, 305753, 1545834, 3175437, 2964900, 1812056, 852617, 799141, 1794907, 2939549, 459284, 1519483, 1794873, 811211, 306360, 489829, 479091, 3419948, 290546, 276534, 3220945, 281649, 390657, 311496, 295988, 802958, 2643833}
- --[[
- __-- Lista de Comandos --__
- !add <username = "Fulano"> <hp = 10> // Adiciona um participante
- !hp <username = "Fulano"> <hp = 0> // Modifica HP de um participante
- !skip // Passa pro próximo mapa
- ]]--
- -- Não mude nada a partir daqui
- local maps_cache = {}
- local current_interval = 10
- local cannon_to_spawn = false
- local current_difficulty = "easy"
- local ended = false
- local no_participants = true
- local participants = {}
- local alive_players = {}
- local difficulty_time = {
- ["easy"] = 7,
- ["normal"] = 8,
- ["hard"] = 9
- }
- local spectrum = {0x38ab07, 0x41c609, 0x47d80a, 0x50f20b, 0x91f507, 0xa2f409, 0xd1f507, 0xfff200, 0xf4e900, 0xe8dc00, 0xd9ce00, 0xd9b800, 0xd99300, 0xd95700, 0xd84201, 0xd91500, 0xc61400, 0xbb1300, 0xb31200, 0xa61100}
- do
- local _, nickname = pcall(nil)
- local owner = string.match(nickname, "(.-)%.")
- admins[#admins + 1] = owner
- end
- do
- local new_table = {}
- for o, a in next, admins do
- new_table[a] = a
- end
- admins = new_table
- end
- function split(t, s)
- local a={}
- for i in string.gmatch(t, "[^" .. (s or "%s") .. "]+") do
- a[#a + 1] = i
- end
- return a
- end
- function log(text)
- print('<V>[Log]</V> <N>' .. text)
- end
- function changeDifficulty(difficulty)
- if difficulty == "easy" or difficulty == "normal" or difficulty == "hard" then
- current_difficulty = difficulty
- current_interval = 10
- showDifficulty()
- end
- end
- function showDifficulty(user)
- local easy_text = (current_difficulty == "easy" and "" or "<a href='event:easy'>") .. "<font color=\"#4AFF59\">Fácil"
- local normal_text = (current_difficulty == "normal" and "" or "<a href='event:normal'>") .. "<font color=\"#E5EF27\">Normal"
- local hard_text = (current_difficulty == "hard" and "" or "<a href='event:hard'>") .. "<font color=\"#EF2626\">Difícil"
- local players = user and {[user] = {}} or tfm.get.room.playerList
- for name, data in next, players do
- ui.addTextArea(0, "", name, 661, 375, 130, 17, 0x010101, nil, 0.7, true)
- ui.addTextArea(1, easy_text, name, 661, 375, nil, nil, 0x767676, nil, current_difficulty == "easy" and 0.3 or 0, true)
- ui.addTextArea(2, normal_text, name, 700, 375, nil, nil, 0x767676, nil, current_difficulty == "normal" and 0.3 or 0, true)
- ui.addTextArea(3, hard_text, name, 755, 375, nil, nil, 0x767676, nil, current_difficulty == "hard" and 0.3 or 0, true)
- end
- end
- function changeMap()
- if #maps_cache == 0 then
- for index, map in next, maps do
- maps_cache[#maps_cache + 1] = map
- end
- end
- tfm.exec.newGame(enable_rotation and table.remove(maps_cache, math.random(#maps_cache)) or maps[math.random(#maps)], math.random(1, 5) == 1 and true or false)
- end
- function spawnCannon(data)
- local info = {}
- local px = data.x
- local py = data.y
- local cnnx = math.random()*800
- local cnny = math.random()*400
- if cnny > py then
- cnny = py-math.random(50)-20
- end
- if math.abs(cnnx-px) > 300 then
- cnnx = px + math.random(-50, 50)
- end
- local ang = math.deg(math.atan2(cnny-py, cnnx-px))
- tfm.exec.addShamanObject(0, cnnx, cnny, ang+90)
- info[1] = cnnx
- info[2] = cnny
- info[3] = ang - 90
- return info
- end
- function alivePlayers()
- local n = 0
- for name, player in next, tfm.get.room.playerList do
- if not player.isDead then
- n = n + 1
- end
- end
- return n
- end
- function addPlayer(name, hp)
- participants[name] = {hp = hp, score = 0, total_hp = hp}
- tfm.exec.setPlayerScore(name, hp, false)
- if no_participants then
- no_participants = false
- changeMap()
- end
- end
- function editHP(name, hp)
- if participants[name] then
- participants[name].hp = hp
- tfm.exec.setPlayerScore(name, participants[name].hp, false)
- if participants[name].hp == 0 then
- log(name .. ' perdeu todas as vidas e teve um resultado de <ROSE>' .. participants[name].score .. '</ROSE> partidas ganhas.')
- participants[name] = nil
- tfm.exec.killPlayer(name)
- end
- end
- end
- function removeHP(name)
- if participants[name] then
- editHP(name, participants[name].hp - 1)
- end
- end
- function eventChatCommand(name, cmd)
- local args = split(cmd, ' ')
- if admins[name] then
- if args[1] == 'addall' then
- for i, v in next, tfm.get.room.playerList do
- if not participants[i] then
- addPlayer(i, 10)
- end
- end
- elseif args[1] == 'add' and args[2] and tfm.get.room.playerList[args[2]] and args[3] and tonumber(args[3]) and not participants[args[2]] then
- addPlayer(args[2], tonumber(args[3]))
- elseif args[1] == 'skip' then
- changeMap()
- elseif args[1] == 'hp' and args[2] and tfm.get.room.playerList[args[2]] and args[3] and tonumber(args[3]) and participants[args[2]] then
- editHP(args[2], tonumber(args[3]))
- end
- end
- end
- function eventLoop(time, remaining)
- ui.setMapName('<CS>' .. tribe_name .. '</CS> <BL>|</BL> <VP>Teste para Cargo</VP>')
- if not no_participants then
- if time > 3000 then
- current_interval = current_interval - 1
- if not ended then
- if current_interval == difficulty_time[current_difficulty] then
- local users = {}
- for name in next, participants do
- if tfm.get.room.playerList[name] and not tfm.get.room.playerList[name].isDead then
- users[#users + 1] = tfm.get.room.playerList[name]
- end
- end
- cannon_to_spawn = #users > 0 and spawnCannon(users[math.random(#users)]) or false
- current_interval = 11
- elseif current_interval == 10 and cannon_to_spawn then
- tfm.exec.addShamanObject(17, cannon_to_spawn[1], cannon_to_spawn[2], cannon_to_spawn[3])
- cannon_to_spawn = false
- end
- elseif remaining > 0 then
- if current_interval <= 0 then
- changeMap()
- end
- end
- end
- if remaining <= 0 then
- if not ended then
- ended = true
- current_interval = 20
- tfm.exec.setGameTime(10)
- ui.addTextArea(5, "<VP><p align='center'><B><font size='18'>PARABÉNS, você conseguiu!", nil, 10, 33, 780, 30, 0x010101, 0x010101, 0.8, true)
- for name, data in next, tfm.get.room.playerList do
- if not data.isDead and participants[name] then
- participants[name].score = participants[name].score + 1
- log(name .. ' venceu uma partida! Score total: ' .. participants[name].score)
- end
- end
- end
- current_interval = current_interval - 1
- if current_interval <= 0 then
- changeMap()
- end
- end
- end
- end
- function eventTextAreaCallback(id, name, cb)
- if admins[name] then
- changeDifficulty(cb)
- end
- end
- function eventNewGame()
- ended = false
- alive_players = {}
- current_interval = 10
- ui.removeTextArea(5)
- local alive_count = 0
- for name, data in next, tfm.get.room.playerList do
- if not participants[name] then
- tfm.exec.killPlayer(name)
- else
- alive_count = alive_count + 1
- alive_players[name] = true
- tfm.exec.setNameColor(name, spectrum[math.floor((#spectrum * (participants[name].total_hp - participants[name].hp + 1)) / participants[name].total_hp)] or spectrum[1])
- end
- end
- if alive_count == 0 then
- no_participants = true
- tfm.exec.setGameTime(99999999)
- ui.addTextArea(5, "<R><p align='center'><B><font size='18'>Não há participantes o suficiente para começar", nil, 10, 33, 780, 30, 0x010101, 0x010101, 0.8, true)
- end
- end
- function eventNewPlayer(name)
- showDifficulty(name)
- tfm.exec.setPlayerScore(name, not participants[name] and 0 or participants[name].hp, false)
- end
- function eventPlayerLeft(name)
- if alive_players[name] then
- alive_players[name] = nil
- removeHP(name)
- end
- end
- function eventPlayerDied(name)
- if not ended then
- if not no_participants then
- if alivePlayers() < 1 then
- current_interval = 10
- tfm.exec.setGameTime(5)
- ended = true
- ui.addTextArea(5, "<p align='center'><CE><font size='18'>Ninguém venceu!", nil, 10, 33, 780, 30, 0x010101, 0x010101, 0.8, true)
- end
- end
- alive_players[name] = nil
- if participants[name] then
- removeHP(name)
- end
- end
- end
- for index, value in next, {'AutoScore', 'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'PhysicalConsumables', 'DebugCommand', 'MinimalistMode', 'AllShamanSkills'} do
- tfm.exec['disable' .. value]()
- end
- system.disableChatCommandDisplay("add")
- system.disableChatCommandDisplay("skip")
- system.disableChatCommandDisplay("hp")
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- tfm.exec.newGame(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement