Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chatbox = peripheral.wrap("top")
- local MAXPLAYERS = 4
- local redteam = 0
- local blueteam = 0
- function initTeams()
- commands.exec("/scoreboard teams add RED")
- commands.exec("/scoreboard teams option RED color red")
- commands.exec("/scoreboard teams option RED friendlyfire false")
- commands.exec("/scoreboard teams add BLUE")
- commands.exec("/scoreboard teams option BLUE color blue")
- commands.exec("/scoreboard teams option BLUE friendlyfire blue")
- commands.exec("/scoreboard objectives add Bloodrace totalKillCount")
- commands.exec("/scoreboard objectives setdisplay sidebar Bloodrace")
- end
- function killTeams()
- commands.exec("/scoreboard teams remove RED")
- commands.exec("/scoreboard teams remove BLUE")
- commands.exec("/scoreboard objectives remove Bloodrace")
- commands.exec("/scoreboard objectives setdisplay sidebar Bloodrace")
- end
- function needsTeam(list, player)
- for i,v in ipairs(list) do
- if v == player then
- print(v.." is equal to "..player)
- return false
- end
- end
- print("Returning true.")
- return true
- end
- local teamed = {"test"}
- initTeams()
- while true do
- event, direction, player, message = os.pullEvent("chat_message")
- if string.lower(message) == "red" and redteam < MAXPLAYERS and needsTeam(teamed, player) == true then
- redteam = redteam + 1
- table.insert(teamed, player)
- chatbox.say("Placing "..player.." on Red Team ("..redteam.."/"..MAXPLAYERS..")")
- commands.exec("/scoreboard teams join RED "..player)
- elseif string.lower(message) == "blue" and blueteam < MAXPLAYERS and needsTeam(teamed, player) == true then
- blueteam = blueteam + 1
- table.insert(teamed, player)
- chatbox.say("Placing "..player.." on Blue Team ("..blueteam.."/"..MAXPLAYERS..")")
- commands.exec("/scoreboard teams join BLUE "..player)
- elseif message == "?" then
- for i,v in ipairs(teamed) do
- chatbox.say(v)
- end
- elseif needsTeam(teamed, player) == false then
- chatbox.say(player.." already has a team.")
- elseif message == "STOPEVENT" and player == "Pangolen" then
- killTeams()
- break
- else
- chatbox.say("Invalid team. Check for typos/full teams.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement