Advertisement
jarantfos

Untitled

Jul 31st, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. chatbox = peripheral.wrap("top")
  2.  
  3. local MAXPLAYERS = 4
  4. local redteam = 0
  5. local blueteam = 0
  6.  
  7. function initTeams()
  8. commands.exec("/scoreboard teams add RED")
  9. commands.exec("/scoreboard teams option RED color red")
  10. commands.exec("/scoreboard teams option RED friendlyfire false")
  11. commands.exec("/scoreboard teams add BLUE")
  12. commands.exec("/scoreboard teams option BLUE color blue")
  13. commands.exec("/scoreboard teams option BLUE friendlyfire blue")
  14. commands.exec("/scoreboard objectives add Bloodrace totalKillCount")
  15. commands.exec("/scoreboard objectives setdisplay sidebar Bloodrace")
  16. end
  17. function killTeams()
  18. commands.exec("/scoreboard teams remove RED")
  19. commands.exec("/scoreboard teams remove BLUE")
  20. commands.exec("/scoreboard objectives remove Bloodrace")
  21. commands.exec("/scoreboard objectives setdisplay sidebar Bloodrace")
  22. end
  23.  
  24. function needsTeam(list, player)
  25. for i,v in ipairs(list) do
  26. if v == player then
  27. print(v.." is equal to "..player)
  28. return false
  29. end
  30. end
  31. print("Returning true.")
  32. return true
  33. end
  34.  
  35. local teamed = {"test"}
  36.  
  37. initTeams()
  38. while true do
  39. event, direction, player, message = os.pullEvent("chat_message")
  40.  
  41. if string.lower(message) == "red" and redteam < MAXPLAYERS and needsTeam(teamed, player) == true then
  42. redteam = redteam + 1
  43. table.insert(teamed, player)
  44. chatbox.say("Placing "..player.." on Red Team ("..redteam.."/"..MAXPLAYERS..")")
  45. commands.exec("/scoreboard teams join RED "..player)
  46.  
  47. elseif string.lower(message) == "blue" and blueteam < MAXPLAYERS and needsTeam(teamed, player) == true then
  48. blueteam = blueteam + 1
  49. table.insert(teamed, player)
  50. chatbox.say("Placing "..player.." on Blue Team ("..blueteam.."/"..MAXPLAYERS..")")
  51. commands.exec("/scoreboard teams join BLUE "..player)
  52. elseif message == "?" then
  53. for i,v in ipairs(teamed) do
  54. chatbox.say(v)
  55. end
  56. elseif needsTeam(teamed, player) == false then
  57. chatbox.say(player.." already has a team.")
  58. elseif message == "STOPEVENT" and player == "Pangolen" then
  59. killTeams()
  60. break
  61. else
  62. chatbox.say("Invalid team. Check for typos/full teams.")
  63. end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement