Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admins = {"pighead10","Player"}
- teams = {}
- rounds = {
- "Group stage", --1
- "Quarter final", --2
- "Semi final", --3
- "Final", --4
- }
- stages = {3,5,7,15,9}
- h = Instance.new("Hint",workspace)
- tourneytext = "Sword Tournament"
- h.Text = tourneytext
- round = 1
- bluedeaths = 0
- reddeaths = 0
- function isAdmin(name)
- for _,v in pairs(admins) do
- if name:lower() == v:lower() then
- return true
- end
- end
- end
- function getTeam(name)
- local t = 1
- for _,v in pairs(teams) do
- print("name:",name,"taking:",v[1])
- if v[1]:sub(1,name:len()):lower() == name:lower() then
- print("sub:",v[1]:sub(1,name:len()))
- t = t == 1 and v or 2
- end
- end
- if t ~= 1 and t ~= 2 then
- print("team found")
- return t
- else
- return nil
- end
- end
- function addTeam(team,player1,player2,player3,name)
- if team then
- table.insert(teams,team)
- else
- local t = {name,player1,player2,player3}
- table.insert(teams,t)
- end
- print("Team",name,"added")
- end
- function blueDied()
- bluedeaths = bluedeaths + 1
- end
- function redDied()
- reddeaths = reddeaths + 1
- end
- function onChatted(msg, rec,speaker)
- --/add player1 player2 player3
- if msg:lower():sub(1,4) == "/add" then
- print("ADMIN SAID /ADD")
- local n = 6
- local name = ""
- local team = {}
- local success = true
- local space1
- local space2
- local space3
- for i = n,500 do
- n = i
- if i > msg:len() then success = false break end
- if msg:sub(i,i) == " " then
- space1 = i
- break
- end
- end
- for i = n+1,500 do
- n = i
- if i > msg:len() then success = false break end
- if msg:sub(i,i) == " " then
- space2 = i
- break
- end
- end
- for i = n+1,500 do
- n = i
- if i > msg:len() then success = false break end
- if msg:sub(i,i) == " " then
- space3 = i
- break
- end
- end
- if success then
- print("space numbers:",space1,space2,space3)
- print(msg:sub(6,space1),msg:sub(space1,space2),msg:sub(space2,space3),msg:sub(space3))
- addTeam(nil,msg:sub(6,space1),msg:sub(space1,space2),msg:sub(space2,space3),msg:sub(space3))
- end
- elseif msg:lower() == "/showteams" then
- print("showteams")
- local m = Instance.new("Message",speaker.PlayerGui)
- print("message created")
- for _,v in pairs(teams) do
- m.Text = table.concat(v,", ")
- print(table.concat(v," "))
- wait(4)
- end
- m:remove()
- print("message removed")
- elseif msg:sub(1,5) == "/duel" then
- print("ADMIN SAID /DUEL!!!")
- local n
- for i=6,500 do
- if msg:sub(i,i) == "/" then
- n = i
- break
- end
- end
- local team1 = getTeam(msg:sub(6,n))
- local team2 = getTeam(msg:sub(n))
- if team1 and team2 then
- --create player variables
- local sr = 0
- local r1 = game.Players[team1[2]]
- local r2 = game.Players[team1[3]]
- local r3 = game.Players[team1[4]]
- local rname = team1[1]
- local sb = 0
- local b1 = game.Players[team2[2]]
- local b2 = game.Players[team2[3]]
- local b3 = game.Players[team2[4]]
- local bname = team2[1]
- if r1 and r2 and r3 and b1 and b2 and b3 then
- while sr < (rounds[round]+1)/2 and sb < (rounds[round]+1)/2 do
- local scoretext = rname.." - Red: "..sr.." | "..bname.." - Blue: "..sb.." (Best of "..rounds[round]..")"
- h.Text = scoretext
- --colour characters
- b1.Torso.BrickColor = BrickColor.new("Bright blue")
- b2.Torso.BrickColor = BrickColor.new("Bright blue")
- b3.Torso.BrickColor = BrickColor.new("Bright blue")
- r1.Torso.BrickColor = BrickColor.new("Bright red")
- r2.Torso.BrickColor = BrickColor.new("Bright red")
- r3.Torso.BrickColor = BrickColor.new("Bright red")
- --teleport characters
- r1:TranslateBy(script.Parent.RedBase.comb1.Position - r1:GetCFrame().p)
- r2:TranslateBy(script.Parent.RedBase.comb2.Position - r2:GetCFrame().p)
- r3:TranslateBy(script.Parent.RedBase.comb3.Position - r3:GetCFrame().p)
- b1:TranslateBy(script.Parent.BlueBase.comb1.Position - b1:GetCFrame().p)
- b2:TranslateBy(script.Parent.BlueBase.comb2.Position - b2:GetCFrame().p)
- b3:TranslateBy(script.Parent.BlueBase.comb3.Position - b3:GetCFrame().p)
- --give swords
- local sword = game.Lighting.LinkedSword
- sword:clone().Parent = r1
- sword:clone().Parent = r2
- sword:clone().Parent = r3
- sword:clone().Parent = b1
- sword:clone().Parent = b2
- sword:clone().Parent = b3
- --register on death
- local con1 = r1.Humanoid.Died:connect(redDied)
- local con2 = r2.Humanoid.Died:connect(redDied)
- local con3 = r3.Humanoid.Died:connect(redDied)
- local con4 = b1.Humanoid.Died:connect(blueDied)
- local con5 = b2.Humanoid.Died:connect(blueDied)
- local con6 = b3.Humanoid.Died:connect(blueDied)
- --wait until a team loses
- repeat wait() until bluedeaths == 3 or reddeaths == 3
- local mtext = ""
- if bluedeaths == 3 and reddeaths ~= 3 then
- mtext = bname.." (Blue) won the duel."
- bs = bs + 1
- elseif reddeaths == 3 and bluedeaths ~= 3 then
- mtext = rname.." (Red) won the duel."
- rs = rs + 1
- else
- mtext = "There was a tie! There must be a rematch."
- end
- local scoretext = rname.." - Red: "..sr.." | "..bname.." - Blue: "..sb.." (Best of "..rounds[round]..")"
- h.Text = scoretext
- local ms = Instance.new("Message",workspace)
- m.Text = mtext
- wait(5)
- ms:remove()
- con1:disconnect()
- con2:disconnect()
- con3:disconnect()
- con4:disconnect()
- con5:disconnect()
- con6:disconnect()
- bluedeaths = 0
- reddeaths = 0
- end
- if sb > sr then
- local ms = Instance.new("Message",workspace)
- ms.Text = bname.." won this round in the "..tourneytext.."!"
- wait(4)
- ms:remove()
- b1.Humanoid.Health = 0
- b2.Humanoid.Health = 0
- b3.Humanoid.Health = 0
- elseif sr > sb then
- local ms = Instance.new("Message",workspace)
- ms.Text = rname.." won this round in the "..tourneytext.."!"
- wait(4)
- ms:remove()
- r1.Humanoid.Health = 0
- r2.Humanoid.Health = 0
- r3.Humanoid.Health = 0
- end
- h.Text = tourneytext
- else
- local m = Instance.new("Message",workspace)
- m.Text = "Player missing! Maybe he left, or the name was typed into the team incorrectly!"
- wait(4)
- m:remove()
- end
- else
- print("Team is nil! It may be ambiguous!")
- local m = Instance.new("Message",speaker.PlayerGui)
- m.Text = "Team is nil! It may be ambiguous!"
- wait(3)
- m:remove()
- end
- elseif msg:sub(1,8):lower() == "/tourney" then
- local m = msg:sub(9)
- if m then
- tourneytext = m
- h.Text = tourneytext
- end
- elseif msg:sub(1,6):lower() == "/round" then
- local m = tonumber(msg:sub(7))
- if m then
- round = m
- end
- elseif msg:sub(1,8):lower() == "/getteam" then
- local m = msg:sub(9)
- if m then
- local t = getTeam(m)
- if t then
- local h = Instance.new("Message",speaker.PlayerGui)
- h.Text = table.concat(t," ")
- wait(4)
- h:remove()
- end
- end
- end
- end
- game.Players.PlayerAdded:connect(function(player)
- if isAdmin(player.Name) then
- print("PLAYER ISH ADMIN")
- player.Chatted:connect(function(msg,r) onChatted(msg,r,player) end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement