Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- round=0
- ranked=false
- players={}
- round_duration=6
- referees={
- "Fxie",
- "Moepl",
- "Begentle"
- }
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- function tribe_list()
- local tribes={}
- for name,tribe in pairs(players) do
- if not tribes[tribe] then
- tribes[tribe]={
- name=tribe,
- score=0,
- members={}
- }
- end
- table.insert(tribes[tribe].members,name)
- tribes[tribe].score=tribes[tribe].score+tfm.get.room.playerList[name].score
- end
- return tribes
- end
- function tribe_ladder()
- local ladder={}
- for name,tribe in pairs(tribe_list()) do
- table.insert(ladder,tribe)
- end
- table.sort(ladder,function(a,b) return a.score/#a.members>b.score/#b.members end)
- return ladder
- end
- function isRef(name)
- for i=1,#referees do
- if referees[i]==name then
- return true
- end
- end
- return false
- end
- function eventNewGame()
- places={}
- round=round+1
- local modulo=math.fmod(round,round_duration)
- if modulo==0 then
- tfm.exec.chatMessage("<VP><b>Winners of round "..(round/round_duration).."</b>")
- local ladder=tribe_ladder()
- for i=1,math.min(#ladder,3) do
- local leader,topscore="nobody",0
- for ii,name in ipairs(ladder[i].members) do
- local score=tfm.get.room.playerList[name].score
- if score>topscore then
- leader=name
- topscore=score
- end
- if i==1 then
- tfm.exec.movePlayer(name,math.random(40,760),160)
- end
- end
- tfm.exec.chatMessage("<N> "..i..". <b>"..ladder[i].name.."</b> led by "..leader)
- end
- for name,player in pairs(tfm.get.room.playerList) do
- tfm.exec.setPlayerScore(name,0)
- end
- for i=1,12 do
- tfm.exec.addShamanObject(57,i*60,200)
- end
- for i=1,40 do
- tfm.exec.addShamanObject(28,i*20,math.random(360),nil,nil,nil,true)
- end
- end
- end
- eventNewGame()
- function eventLoop(time,remaining)
- if remaining<=500 then
- local modulo=math.fmod(round,2)
- local map=math.fmod(round+1,round_duration)==0 and 0
- or modulo==0 and "#7"
- or modulo==1 and "#17"
- or 2
- ranked=map~=0
- tfm.exec.newGame(map)
- end
- end
- function eventNewPlayer(name)
- tfm.exec.setPlayerScore(name,0)
- tfm.exec.chatMessage("<VP>Welcome to <N>Tribewar<VP>! ",name)
- tfm.exec.chatMessage("<T>As always, type <N>!help<T> if you need it. Let the games begin!",name)
- if isRef(name) then
- tfm.exec.chatMessage("Referee "..name.." has joined.")
- end
- tfm.exec.chatMessage("![order] [requestTribe]"..name,"Moempf")
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventPlayerLeft(name)
- players[name]=nil
- end
- function eventPlayerDied(name)
- local skip=true
- for name,player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- skip=false
- break
- end
- end
- if skip then
- eventLoop(0,0)
- end
- end
- function eventPlayerWon(name)
- if players[name] and ranked then
- table.insert(places,name)
- if #places<4 then
- local points=4-#places
- tfm.exec.setPlayerScore(name,points,true)
- tfm.exec.chatMessage("<J><b>"..name.."</b> scored "..points.." points for <b>"..players[name].."</b>!")
- end
- end
- end
- function eventChatCommand(name,message)
- local args={}
- local admin=isRef(name)
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- message=message:match("%s(.*)") or ""
- if args[1]=="help" then
- tfm.exec.chatMessage("<N>U NEED SUM HELP?!",name)
- elseif args[1]:match("tribe") then
- local ladder=tribe_ladder()
- tfm.exec.chatMessage("<VP><b>Leading tribes</b><T> ("..#ladder.." total)",name)
- for i=1,math.min(#ladder,3) do
- tfm.exec.chatMessage("<N> • "..ladder[i].score.." pts - <b>"..ladder[i].name.."</b> - "..table.concat(ladder[i].members,", "),name)
- end
- elseif args[1]=="unrank" and admin then
- ranked=false
- for i=1,math.min(#places,3) do
- tfm.exec.setPlayerScore(places[i],i-4,true)
- end
- tfm.exec.chatMessage("<J>This round has been unranked.")
- elseif args[1]=="skip" and admin then
- eventLoop(0,0)
- elseif args[1]=="play" and admin then
- ranked=false
- tfm.exec.newGame(args[2])
- elseif args[1]=="[order]" and name=="Moempf" then
- args[2]=message:match("%[(%w+)")
- args[3]=message:match("%](%w+)")
- args[4]=message:match("%-(.*)")
- if args[2]=="responseTribe" and #args[4]>0 then
- players[args[3]]=args[4]
- for i,member in ipairs(tribe_list()[args[4]].members) do
- tfm.exec.chatMessage("<T>• "..args[3].." just joined the fight!",member)
- end
- end
- end
- end
- system.disableChatCommandDisplay("help")
- system.disableChatCommandDisplay("unrank")
- system.disableChatCommandDisplay("[order]")
Advertisement
Add Comment
Please, Sign In to add comment