Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Capture the flag - with Command Computers!
- redTeamPlayers and blueTeamPlayers are tables,
- the names of the players on each team should be entered into them, like so:
- local redTeamPlayers = {
- ["ilikepie"] = true,
- ["demhydraz"] = true,
- }
- local blueTeamPlayers = {
- ["KingofGamesYami"] = true,
- ["BombBloke"] = true,
- }
- ]]--
- local redTeamPlayers = {
- }
- local blueTeamPlayers = {
- }
- --[[DO NOT EDIT BEYOND THIS POINT!!]]--
- os.loadAPI( "commandsPlus" )
- os.loadAPI( "partTerm" )
- local x, y, z = commands.getBlockPosition()
- local blueTeamFlag = partTerm.createWindow( x, y, z + 100, 25, 10 )
- local redTeamFlag = partTerm.createWindow( x, y, z - 100, 25, 10 )
- blueTeamFlag.setBackgroundColor( colors.blue )
- blueTeamFlag.clear()
- blueTeamFlag.setParticle( "mobSpell" )
- redTeamFlag.setBackgroundColor( colors.red )
- redTeamFlag.clear()
- redTeamFlag.setParticle( "mobSpell" )
- local redFlagHolder, blueFlagHolder
- local function blueFlagCheck()
- while true do
- if blueFlagHolder then
- local a, b = commandsPlus.getPlayerRotation( blueFlagHolder )
- local x, y, z = commandsPlus.getPlayerPosition( blueFlagHolder )
- blueTeamFlag.reposition( x, y + 2, z )
- blueTeamFlag.setAngles( a + 90 )
- else
- local x, y, z = blueTeamFlag.getPosition()
- local ok, result = commands.testfor( "@a["..tostring(x)..","..tostring(y)..","..tostring(z)..",5]" )
- for k, v in pairs( result ) do
- local name = v:match( "Found (.+)" )
- if redTeamPlayers[ name ] then
- blueFlagHolder = name
- blueTeamFlag.center( false )
- break
- end
- end
- end
- end
- end
- local function redFlagCheck()
- while true do
- if redFlagHolder then
- local a, b = commandsPlus.getPlayerRotation( redFlagHolder )
- local x, y, z = commandsPlus.getPlayerPosition( redFlagHolder )
- redTeamFlag.reposition( x, y + 2, z )
- redTeamFlag.setAngles( a + 90 )
- else
- local x, y, z = redTeamFlag.getPosition()
- local ok, result = commands.testfor( "@a["..tostring(x)..","..tostring(y)..","..tostring(z)..",5]" )
- for k, v in pairs( result ) do
- local name = v:match( "Found (.+)" )
- if blueTeamPlayers[ name ] then
- redFlagHolder = name
- redTeamFlag.center( false )
- break
- end
- end
- end
- end
- end
- local winner
- local function endGameChecker()
- while true do
- for k, v in pairs( commandsPlus.getNearbyPlayers( 2 ) ) do
- if v == redFlagHolder then
- winner = "Blue Team"
- return
- elseif v == blueFlagHolder then
- winner = "Red Team"
- return
- end
- end
- end
- end
- parallel.waitForAny( blueFlagCheck, redFlagCheck, partTerm.render, endGameChecker )
- commands.say( "The " .. winner .. " Wins!" )
Advertisement
Add Comment
Please, Sign In to add comment