Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TribewarModule = {}
- TribewarModule.new = function(maplist)
- local maplist = maplist or { "#0", "#1", "#1", "#1", "#7", "#17" }
- local self = {}
- --
- local tempsettings =
- {
- firstPoints = 3,
- secondPoints = 2,
- thirdPoints = 1,
- rounds = 8,
- timeSkip = 20,
- users = {
- normal = {
- power = 1,
- users = {},
- commands = {
- help = "This help",
- tribelist = "Shows the 5 best tribes",
- mort = "Kill yourself",
- tlist = "Shows the players in your tribe"
- }
- },
- watcher = {
- power = 2,
- users = {},
- commands = {
- pause = "There won't be any points in this round",
- unpause = "There will be points again",
- liststaff = "List the TWstaff"
- }
- },
- referee = {
- power = 3,
- users = {},
- commands = {
- npp = "Enqueues a map",
- ban = "Bans a player",
- unban = "Unbans a player",
- showbans="Shows bans"
- }
- },
- manager = {
- power = 4,
- users = {},
- commands = {
- addwatcher = "Makes a person a watcher",
- addreferee = "Makes a person a referee",
- removestaff = "Removes a referee/watcher",
- }
- },
- admin = {
- power = 5,
- users = { Manacer = {}, Whoms = {}, },
- commands = {
- addmanager = "Makes a person a manager",
- }
- }
- }
- }
- --
- local currentRound = {}
- local roundnumber = 0
- local botname = "Moeplluaalt"
- local orderName = "![order] "
- local requestTribe = "[requestTribe]"
- local answerTribe = "[responseTribe]"
- local showhelp = "help"
- local mortcmd = "mort"
- local showTribes = "tribelist"
- local tlist = "tlist"
- local playernamecolor = "#009D9D"
- local pointscolor = "#98E2EB"
- local addedPoints = "%s scored %s points for %s!"
- local resultsOfRound = "Results of round %s:\n%s"
- local wonTheWar = "<V>Congratulations,\n %s won the war!"
- local tfmMod = tfmMoeplModule.new("tribewar")
- local settings = savedData["games"][tfmMod.getName()]["settings"] or tempsettings
- --[[
- settings.users.admin.commands["addmanager"] = "Makes a person a manager"
- settings.users.referee.commands["ban"] = "Bans a player"
- settings.users.referee.commands["unban"] = "Unbans a player"
- settings.users.referee.commands["showbans"] = "Shows bans"
- --]]
- local commander = commandHandler.new(false, tfmMod)
- local queuedAMapAlready = false
- local refmap
- local tribeWarMapQueue = mapUtils.new(maplist)
- local commandsWithCommand = {}
- local commands = {}
- commands[orderName:sub(2, orderName:len() - 1)] = 99
- for _, users in pairs(settings.users) do
- for command, _ in pairs(users.commands) do
- commands[command] = users.power
- commandsWithCommand[command] = command
- end
- end
- for v, _ in pairs(commands) do
- system.disableChatCommandDisplay(v, true)
- end
- local buildhelp = function(power)
- local power = power or 1
- local output = {}
- local commands = {}
- for status, users in pairs(settings.users) do
- if (users.power <= power) then
- for i, v in pairs(users.commands) do
- table.insert(commands, { name = i, description = v, userstatus = status, power = users.power })
- end
- end
- end
- table.sort(commands, function(a, b)
- return a.power < b.power
- end)
- table.insert(output, { "Command", "status", "description" })
- for i, v in pairs(commands) do
- table.insert(output, { "!" .. tostring(v.name), v.userstatus, v.description })
- end
- return string.monoSpaceTransform(table.getSpaceIdentedString(output));
- end
- local helpmsguser = buildhelp()
- local helpmsgwatcher = buildhelp(2)
- local helpmsgreferee = buildhelp(3)
- local helpmsgmanager = buildhelp(4)
- local helpmsgadmin = buildhelp(5)
- local Tribes = {}
- local SortedTribes = {}
- local TribePlayers = {}
- local Referees = {}
- local playerBans = {}
- Tribe = {}
- Tribe.new = function(tribeName)
- local function num2hex(num)
- local hexstr = '0123456789abcdef'
- local s = ''
- while num > 0 do
- local mod = math.fmod(num, 16)
- s = string.sub(hexstr, mod + 1, mod + 1) .. s
- num = math.floor(num / 16)
- end
- if s == '' then s = '0' end
- return s
- end
- local tribeName = tribeName
- local tribe = {}
- local tribePlayers = {}
- local sortedPlayers = {}
- local points = 0
- local tribeintcolor = 0
- local tribecolor = "";
- tribe.calculateColors = function()
- local br = tonumber("32", 10)
- local bg = tonumber("46", 10)
- local bb = tonumber("50", 10)
- tribeintcolor = math.random(1, 16777215)
- tribecolor = "#" .. num2hex(tribeintcolor);
- local difference = 1
- for i = 2, 6, 2 do
- local str = tribecolor:sub(i, i + 1) .. ""
- local color = tonumber(str, 16) or 1
- local checkcolor = 0
- if i == 2 then
- checkcolor = br
- elseif i == 4 then
- checkcolor = bg
- elseif i == 6 then
- checkcolor = bb
- end
- local addnr = tonumber((math.max(checkcolor, color) - math.min(checkcolor, color))) or 1
- difference = difference * addnr
- end
- if difference < 400000 then tribe.calculateColors() end
- end
- tribe.calculateColors()
- tribe.getColor = function() return tribecolor end
- tribe.getColorInt = function() return tribeintcolor end
- tribe.getPlayers = function() return tribePlayers end
- tribe.getBestPlayer = function()
- return sortedPlayers[1] or TribewarPlayer.new("Nobody")
- end
- tribe.getPlayerList = function()
- local output = {}
- table.insert(output, { "Name", "Points" })
- local iteratedtribes = 0;
- for i, v in pairs(sortedPlayers) do
- table.insert(output, { string.format("%s", string.tagColor(v.getName(), playernamecolor)), v.getPoints() })
- end
- return string.monoSpaceTransform(table.getSpaceIdentedString(output));
- end
- tribe.getName = function() return tribeName end
- tribe.getPoints = function() return points end
- tribe.sortPlayers = function()
- table.sort(sortedPlayers, function(a, b) return a.getPoints() > b.getPoints() end)
- end
- tribe.addPoints = function(playerName, pts) points = points + pts
- tribe.sortPlayers()
- self.gameMessage(addedPoints:format(string.tagColor(playerName, playernamecolor), string.tagColor(pts, pointscolor), string.tagColor(tribeName, tribecolor)))
- end
- tribe.addPlayer = function(tribeplayer) tribePlayers[tribeplayer.getName()] = tribeplayer
- table.insert(sortedPlayers, tribeplayer)
- tribe.sortPlayers()
- end
- tribe.removePlayer = function(playerName)
- local ind = table.getIndexOf(sortedPlayers, tribePlayers[playerName])
- if (ind) then
- table.remove(sortedPlayers, ind)
- end
- tribePlayers[playerName] = nil
- end
- tribe.reset = function() points = 0 end
- return tribe
- end
- TribewarPlayer = {}
- TribewarPlayer.new = function(name)
- local player = {}
- local name = name
- local points = 0
- local tribe
- player.getName = function() return name end
- player.getPoints = function() return points end
- player.getTribe = function() return tribe end
- player.setTribe = function(tribeName)
- if (tribe ~= nil) then
- tribe.removePlayer(name)
- end
- local curTribe = Tribes[tribeName]
- if curTribe == nil then
- curTribe = Tribe.new(tribeName)
- self.addTribe(curTribe)
- end
- curTribe.addPlayer(player)
- xplayer.setNameColor(name, curTribe.getColorInt())
- tribe = curTribe
- end
- player.addPoints = function(pts)
- points = points + pts
- if tribe then
- tribe.addPoints(name, pts)
- end
- end
- player.leave = function()
- if (tribe ~= nil) then
- tribe.removePlayer(name)
- end
- TribePlayers[name] = nil
- end
- player.reset = function()
- points = 0
- end
- return player
- end
- Referee = {}
- Referee.new = function(name, power, createdDate, promotedBy, mainacc)
- local refself = {}
- local createdDate = createdDate or os.time()
- local promotedBy = promotedBy or "Admin"
- local mainacc = mainacc or true
- local name = name
- local power = power
- local pauseCmd = function(msg)
- currentRound.setPause(true, msg, name)
- end
- local unpauseCmd = function(msg)
- currentRound.setPause(false, msg, name)
- end
- local addRef = function(ref, power)
- if ref:len() < 2 then
- xplayer.chatMessage("<R>Error", name)
- return
- end
- ref = string.lower(ref)
- ref = string.trim(string.upper(string.sub(ref, 0, 1)) .. string.sub(ref, 2))
- local newref = Referees[ref] or Referee.new(ref, power, os.time(), name, true)
- if (newref.getPower() >= refself.getPower()) then --prevents managers from changing the rank of others managers
- xplayer.chatMessage("<R>This is not allowed!", name)
- else
- newref.setPower(power)
- Referees[ref] = newref
- xplayer.chatMessage(string.format("<R>Added \"%s\"", ref), name)
- self.rebuildStaffTable()
- end
- end
- local removeRef = function(ref)
- ref = string.lower(ref)
- ref = string.upper(string.sub(ref, 0, 1)) .. string.sub(ref, 2)
- local toRemoveRef = Referees[ref]
- if not toRemoveRef then
- xplayer.chatMessage("<R>" .. string.format("%s not found", ref), name)
- return
- end
- if toRemoveRef.getPower() < refself.getPower() then
- Referees[ref] = nil
- xplayer.chatMessage(string.format("<R>%s removed", ref), name)
- self.rebuildStaffTable()
- end
- end
- local listStaff = function()
- local output = ""
- for rankName, tbl in pairs(settings.users) do
- if (tbl.power > 1) then
- local output = string.upper(rankName) .. "\n"
- for staff, value in pairs(tbl.users) do
- output = output .. staff .. "\n"
- end
- xplayer.chatMessage(output, name)
- end
- end
- end
- local mapEnqueue = function(msg)
- local strd = msg:gsub("[^%d+]", "")
- local number = tonumber(strd)
- if number then refmap = number
- xplayer.chatMessage(string.format("Enqueued %s", number), name)
- else
- xplayer.chatMessage("Faulty input: " .. msg, name)
- end
- end
- local banunban = function(playerName, ban)
- if playerName:len() > 2 then
- playerName = playerName:lower()
- playerName = string.upper(string.sub(playerName, 0, 1)) .. string.sub(playerName, 2)
- ban = ban or false
- if ban == true then
- playerBans[playerName] = refself
- xplayer.chatMessage(string.format("Banned \"%s\"!", playerName), name)
- xplayer.chatMessage(string.format("You can't spawn anymore."),playerName)
- xplayer.killPlayer(playerName)
- else
- if (playerBans[playerName]) then
- playerBans[playerName] = nil
- xplayer.chatMessage(string.format("Unbanned \"%s\".", playerName), name)
- else
- xplayer.chatMessage(string.format("\"%s\" wasn't banned.", playerName), name)
- end
- end
- end
- end
- local showbans = function()
- local output = {}
- table.insert(output, { "Name", "Referee" })
- for i, v in pairs(playerBans) do
- table.insert(output, { i, v.getName() })
- end
- xplayer.chatMessage(string.monoSpaceTransform(table.getSpaceIdentedString(output)),name)
- end
- refself.commandHandle = function(cmd, msg, extraparas)
- if commands[cmd] and commands[cmd] <= power then
- if cmd == commandsWithCommand["pause"] then
- pauseCmd(msg)
- elseif cmd == commandsWithCommand["unpause"] then
- unpauseCmd(msg)
- elseif cmd == commandsWithCommand["liststaff"] then
- listStaff()
- elseif cmd == commandsWithCommand["addwatcher"] then
- addRef(msg, settings.users.watcher.power)
- elseif cmd == commandsWithCommand["addreferee"] then
- addRef(msg, settings.users.referee.power)
- elseif cmd == commandsWithCommand["removestaff"] then
- removeRef(msg)
- elseif cmd == commandsWithCommand["npp"] then
- mapEnqueue(msg)
- elseif cmd == commandsWithCommand["ban"] then
- banunban(msg, true)
- elseif cmd == commandsWithCommand["unban"] then
- banunban(msg, false)
- elseif cmd == commandsWithCommand["showbans"] then
- showbans()
- elseif cmd == commandsWithCommand["addmanager"] then
- addRef(msg, settings.users.manager.power)
- end
- end
- end
- refself.getName = function() return name end
- refself.getPromotedBy = function() return promotedBy end
- refself.getMainAcc = function() return mainacc end
- refself.getCreatedDate = function() return createdDate end
- refself.getPower = function() return power end
- refself.setPower = function(pw) power = pw end
- return refself;
- end
- for _, users in pairs(settings.users) do
- if (users.power > 1) then
- for i, v in pairs(users.users) do
- Referees[i] = Referee.new(i, users.power, v.createdDate, v.promotedBy, v.mainacc)
- end
- end
- end
- commander.addCommand("", 1, function(playerName, msg, cmd)
- if (Referees[playerName]) then
- Referees[playerName].commandHandle(cmd:lower(), msg)
- end
- end)
- local RoundInfo = {}
- RoundInfo.new = function(roundnr)
- local round = {}
- local roundnr = roundnr
- local ranklist = {}
- local paused = false
- local gotpoints
- round.isPaused = function() return paused end
- round.togglePause = function(msg, playerName) round.setPause(not paused, msg, playerName) end
- round.setPause = function(p, msg, playerName)
- if p ~= paused then
- paused = p
- if paused == true then
- self.gameMessage(string.format("<R>Pause! (%s):<J> %s", string.tagColor("Referee " .. playerName, playernamecolor), msg))
- roundnumber = roundnumber - 1
- elseif paused == false then
- self.gameMessage(string.format("<R>UnPause! (%s):<J> %s", string.tagColor("Referee " .. playerName, playernamecolor), msg))
- roundnumber = roundnumber + 1
- end
- local nr = 1
- local mult = 1
- if paused == true then mult = -1 end
- for i, tpl in pairs(ranklist) do
- if (nr == 4) then break end
- if nr == 1 then
- tpl.addPoints(settings.firstPoints * mult)
- elseif nr == 2 then
- tpl.addPoints(settings.secondPoints * mult)
- elseif nr == 3 then
- tpl.addPoints(settings.thirdPoints * mult)
- end
- nr = nr + 1
- end
- self.sortTribes()
- end
- end
- round.playerScore = function(playerName)
- if #ranklist <= 3 then
- self.getTribeNames(playerName)
- end
- local tpl = TribePlayers[playerName]
- if tpl ~= nil then
- table.insert(ranklist, tpl)
- if round.isPaused() == true then return end
- if #ranklist == 1 then
- tpl.addPoints(settings.firstPoints)
- self.sortTribes()
- elseif #ranklist == 2 then
- tpl.addPoints(settings.secondPoints)
- self.sortTribes()
- elseif #ranklist == 3 then
- tpl.addPoints(settings.thirdPoints)
- self.sortTribes()
- end
- end
- end
- round.getRound = function() return roundnr end
- round.playersEntered = function() return #ranklist end
- return round
- end
- tfmMod.addMap = function(map)
- tribeWarMapQueue.addMap(map)
- end
- tfmMod.removeMap = function(map)
- return tribeWarMapQueue.removeMap(map)
- end
- tfmMod.showMaps = function()
- local sortedmaps = tribeWarMapQueue.getMaps()
- table.sort(sortedmaps)
- return table.concat(sortedmaps, " ")
- end
- tfmMod.getMaps = function()
- return tribeWarMapQueue.getMaps()
- end
- self.sortTribes = function()
- table.sort(SortedTribes, function(a, b) return a.getPoints() > b.getPoints() end)
- end
- self.addTribe = function(tribe)
- Tribes[tribe.getName()] = tribe
- table.insert(SortedTribes, tribe)
- end
- self.removeTribe = function(tribe)
- Tribes[tribe.getName()] = nil
- local index = table.getIndexOf(SortedTribes, tribe)
- if index then
- table.remove(SortedTribes, index)
- end
- end
- self.rebuildStaffTable = function()
- local staffRank = {}
- for staffname, staffpos in pairs(settings.users) do
- staffpos.users = {}
- staffRank[staffpos.power] = staffname
- end
- for i, v in pairs(Referees) do
- local pw = v.getPower()
- settings.users[staffRank[pw]].users[v.getName()] = { createdDate = v.getCreatedDate(), promotedBy = v.getPromotedBy(), mainacc = v.getMainAcc() }
- end
- savedData["games"][tfmMod.getName()]["settings"] = settings or tempsettings
- -- print(type(savedData["games"][tfmMod.getName()]))
- -- print(moepl.save(savedData["games"][tfmMod.getName()]))
- admin.savedata()
- end
- self.queueNextMap = function()
- if queuedAMapAlready == false then
- queuedAMapAlready = true
- local nextmap = refmap or tribeWarMapQueue.getNextMap()
- refmap = nil
- local mapplayed = false
- local newgamev
- --make sure that a new map is actually played and we don't get stuck because a ref queued an invalid map
- newgamev = tfmMod.registerEvent("eventNewGame",
- function()
- mapplayed = true
- tfmMod.addTimerTask(function() tfmMod.unregisterEvent(newgamev) end, 100, false)
- end)
- tfmMod.addTimerTask(function()
- if (mapplayed == false) then refmap = nil xplayer.newGame(tribeWarMapQueue.getNextMap()) end
- end, 3000, false)
- xplayer.newGame(nextmap)
- end
- end
- self.getTribeNames = function(playerName)
- if (playerName ~= botname) then
- if (not tfm.get.room.playerList[botname]) then
- eventChatCommand(botname, orderName:sub(2, orderName:len()) .. answerTribe .. playerName .. "-" .. "Team" .. math.random(1, 6))
- end
- xplayer.chatMessage(orderName .. requestTribe .. playerName, botname)
- end
- end
- self.getBestTribes = function()
- return SortedTribes
- end
- self.getTribeList = function(short, tribePlayer)
- short = short or false
- local output = {}
- table.insert(output, { "Rank", "Name", "Score", "Ppl", "Best player" })
- local iteratedtribes = 0;
- for i, v in pairs(SortedTribes) do
- if (short and iteratedtribes >= 3) or (not short and iteratedtribes >= 5) then break end
- table.insert(output, { tostring(iteratedtribes + 1) .. ".", string.format("%s", string.tagColor(v.getName(), v.getColor())), v.getPoints(), table.size(v.getPlayers()), string.format("%s (%s)", string.tagColor(v.getBestPlayer().getName(), playernamecolor), v.getBestPlayer().getPoints()) })
- iteratedtribes = iteratedtribes + 1
- end
- return string.monoSpaceTransform(table.getSpaceIdentedString(output));
- end
- self.wonGame = function()
- local t = self.getBestTribes()[1]
- local besttribe = "<V>Nobody"
- if t then besttribe = string.tagColor(t.getName(), t.getColor()) end
- self.gameMessage(string.format(wonTheWar, besttribe))
- end
- self.gameMessage = function(msg, p)
- xplayer.chatMessage(string.format("<J>[GAME] %s", msg), p)
- end
- local function clearUp()
- tfmMod.removeAllTimerTasks()
- queuedAMapAlready = false
- currentRound = RoundInfo.new(roundnumber)
- end
- self.showHelp = function(playerName)
- local out = ""
- local ref = Referees[playerName]
- if ref then
- if ref.getPower() == settings.users.watcher.power then
- out = helpmsgwatcher
- elseif ref.getPower() == settings.users.referee.power then
- out = helpmsgreferee
- elseif ref.getPower() == settings.users.manager.power then
- out = helpmsgmanager
- elseif ref.getPower() == settings.users.admin.power then
- out = helpmsgadmin
- end
- else
- out = helpmsguser
- end
- xplayer.chatMessage(out, playerName)
- end
- self.mapManager = function()
- local setTime = function(t)
- if t > 0 and t < 6 then
- --nothing
- else
- xplayer.setGameTime(t)
- end
- end
- local timeLeft = 120
- setTime(timeLeft)
- local newgamev = nil
- local executednextmap = false
- local currentplayers = {}
- for i, v in pairs(tfm.get.room.playerList) do
- if i ~= botname then
- currentplayers[i] = v
- if v.isShaman == true then
- -- shaman = i
- end
- end
- end
- local playing = table.size(currentplayers)
- local playerDone = function(pl)
- if currentplayers[pl] then
- currentplayers[pl] = nil
- playing = playing - 1
- if tfm.moepl.getPlayerSize() > 5 and tfm.moepl.getPlayerSize() / (tfm.moepl.getPlayerSize() - playing) < 1.75 and timeLeft > 20 then
- timeLeft = 20
- setTime(timeLeft)
- elseif tfm.moepl.getPlayerSize() > 4 and tfm.moepl.getPlayerSize() / (tfm.moepl.getPlayerSize() - playing) < 1.5 and currentRound.playersEntered() > 0 and timeLeft > 20 then
- timeLeft = 20
- setTime(timeLeft)
- end
- if playing == 0 then
- timeLeft = 0
- setTime(timeLeft)
- elseif playing == 1 and timeLeft > 20 and timeLeft > 20 then
- timeLeft = 20
- setTime(timeLeft)
- elseif (tfm.get.room.playerList[pl] and tfm.get.room.playerList[pl].isShaman == true and timeLeft > 20) then
- timeLeft = 20
- setTime(timeLeft)
- end
- end
- end
- local plswonev = tfmMod.registerEvent("eventPlayerWon", function(t) playerDone(t) end)
- local plsdied = tfmMod.registerEvent("eventPlayerDied", function(t) playerDone(t) end)
- newgamev = tfmMod.registerEvent("eventNewGame",
- function()
- tfmMod.unregisterEvent(plswonev)
- tfmMod.unregisterEvent(plsdied)
- --using timertask to not get "next" key problems on consumeevent for eventNewGame
- tfmMod.addTimerTask(function() tfmMod.unregisterEvent(newgamev) end, 100, false)
- end)
- tfmMod.addTimerTask(function()
- if timeLeft <= 0 and not executednextmap then
- self.queueNextMap()
- executednextmap = true
- end
- timeLeft = timeLeft - 1
- if timeLeft % 2 == 0 then
- setTime(timeLeft)
- end
- end, 1000, true)
- end
- local function eventNewGame()
- roundnumber = roundnumber + 1
- if roundnumber > settings.rounds then
- roundnumber = 1
- self.wonGame()
- local todeletetribes = {}
- for i, v in pairs(Tribes) do
- v.reset()
- if table.size(v.getPlayers()) == 0 then
- table.insert(todeletetribes, v)
- end
- end
- for _, v in pairs(todeletetribes) do
- self.removeTribe(v)
- end
- for i, v in pairs(TribePlayers) do
- v.reset()
- end
- end
- clearUp()
- if (currentRound.getRound() ~= 1) then
- self.gameMessage(resultsOfRound:format(currentRound.getRound() - 1, self.getTribeList(true)))
- end
- --using timertask to prevent "next" key problems
- tfmMod.addTimerTask(self.mapManager, 100, false)
- end
- local function eventNewPlayer(playerName)
- self.showHelp(playerName)
- self.getTribeNames(playerName)
- end
- local eventPlayerLeft = function(playerName)
- local tplayer = TribePlayers[playerName]
- if tplayer ~= nil then
- tplayer.leave()
- end
- end
- local eventPlayerWon = function(playerName)
- if (currentRound.playerScore ~= nil) then
- currentRound.playerScore(playerName)
- end
- end
- local botHandler = function(name, msg)
- if (name == botname) then
- if ("!" .. msg:sub(1, orderName:len() - 1) == orderName) then
- local order = msg:sub(orderName:len())
- if (order:sub(1, answerTribe:len()) == answerTribe) then
- local nameAndTribe = order:sub(answerTribe:len() + 1)
- local name = nameAndTribe:sub(1, nameAndTribe:find("-") - 1)
- local tribe = nameAndTribe:sub(nameAndTribe:find("-") + 1, nameAndTribe:len()):gsub("\\", ""):gsub("<", ""):gsub("^", "")
- if tribe == "" then tribe = "No Tribe" end
- local tribeplayer = TribePlayers[name] or TribewarPlayer.new(name)
- tribeplayer.setTribe(tribe)
- TribePlayers[name] = tribeplayer
- -- local str = self.getTribeList()
- -- xplayer.chatMessage(str)
- end
- end
- end
- end
- local chatHandler = function(player, msg)
- if (string.equalsIgnoreCase(msg, showTribes)) then
- local str = self.getTribeList(false, TribePlayers[player])
- self.gameMessage("\n" .. str, player)
- elseif string.equalsIgnoreCase(msg, showhelp) then
- self.showHelp(player)
- elseif string.equalsIgnoreCase(msg, mortcmd) then
- xplayer.killPlayer(player)
- elseif string.equalsIgnoreCase(msg, tlist) then
- local tpl = TribePlayers[player]
- if (tpl and tpl.getTribe()) then
- xplayer.chatMessage(tpl.getTribe().getPlayerList(), player)
- end
- elseif player == "Moepl" and string.equalsIgnoreCase(msg, "win") then
- xplayer.giveCheese(player)
- xplayer.playerVictory(player)
- end
- end
- local eventPlayerDied = function(playerName)
- if playerName == botname then
- xplayer.setPlayerScore(botname, -1, false)
- end
- end
- local killUnwantedPlayers = function()
- for i, _ in pairs(playerBans) do
- xplayer.killPlayer(i)
- end
- end
- self.startfunction = function()
- updatingPos = true
- xplayer.disableAutoNewGame(true)
- xplayer.setRoomMaxPlayers(60)
- xplayer.disableAutoTimeLeft(true)
- tfmMod.addTimerTask(function() self.queueNextMap() end, 1000, false)
- tfmMod.registerEvent("eventFileLoaded", function(filename, file)
- end)
- tfmMod.registerEvent("eventNewGame", eventNewGame)
- tfmMod.registerEvent("eventNewGame", killUnwantedPlayers)
- tfmMod.registerEvent("eventChatCommand", botHandler)
- tfmMod.registerEvent("eventChatCommand", chatHandler)
- tfmMod.registerEvent("eventNewPlayer", eventNewPlayer)
- tfmMod.registerEvent("eventPlayerLeft", eventPlayerLeft)
- tfmMod.registerEvent("eventPlayerWon", eventPlayerWon)
- tfmMod.registerEvent("eventPlayerDied", eventPlayerDied)
- for i, _ in pairs(tfm.get.room.playerList) do
- self.getTribeNames(i)
- end
- end
- tfmMod.setStartFunc(self.startfunction)
- tfmMod.setStopFunc(function()
- updatingPos = true
- xplayer.disableAutoTimeLeft(false)
- xplayer.setRoomMaxPlayers(150)
- xplayer.disableAutoNewGame(false)
- end)
- return tfmMod
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement