Skip to content
home/templates/capture the flag (basics)
minigameAdvancedmc 1.20.x – 1.21.x70 lines

capture the flag (basics)

two teams (red/blue), flag at each base, steal opponent's flag and return to base to score. first to 3 wins.

vanilla Skriptno addons required.
ctf-basics.sk70 lines
# Setup commands — admin sets the four key locations.
command /ctfsetup <text>:
    permission: ctf.admin
    trigger:
        if arg-1 is "redspawn":
            set {ctf.red.spawn} to location of player
            send "&aRed spawn set." to player
        else if arg-1 is "bluespawn":
            set {ctf.blue.spawn} to location of player
            send "&aBlue spawn set." to player
        else if arg-1 is "redflag":
            set {ctf.red.flag} to location of player
            send "&aRed flag location set. Place red wool here." to player
        else if arg-1 is "blueflag":
            set {ctf.blue.flag} to location of player
            send "&aBlue flag location set. Place blue wool here." to player
        else:
            send "&7Usage: /ctfsetup <redspawn|bluespawn|redflag|blueflag>" to player

command /ctf <text>:
    trigger:
        if arg-1 is "red":
            add player to {ctf.red::*}
            teleport player to {ctf.red.spawn}
            send "&cYou joined the RED team!" to player
        else if arg-1 is "blue":
            add player to {ctf.blue::*}
            teleport player to {ctf.blue.spawn}
            send "&9You joined the BLUE team!" to player
        else:
            send "&7Usage: /ctf <red|blue>" to player

# Flag pickup — vanilla on-right-click, then check the clicked block type.
on right click:
    if event-block is red wool:
        if player is in {ctf.blue::*}:
            cancel event
            set event-block to air
            give 1 red wool named "&cRed Flag" to player
            broadcast "&9%player% &fhas the &cRed Flag!"
    else if event-block is blue wool:
        if player is in {ctf.red::*}:
            cancel event
            set event-block to air
            give 1 blue wool named "&9Blue Flag" to player
            broadcast "&c%player% &fhas the &9Blue Flag!"

# Capture check — runs periodically and tests proximity to each base.
every 1 second:
    loop {ctf.red::*}:
        if distance between loop-value and {ctf.red.spawn} is less than 3:
            if loop-value's inventory contains blue wool:
                add 1 to {ctf.score.red}
                remove all blue wool from loop-value's inventory
                broadcast "&c%loop-value% &fcaptured the flag! &cRed: &f%{ctf.score.red} ? 0%"
                if {ctf.score.red} >= 3:
                    broadcast "&c&l===== RED TEAM WINS ====="
                    delete {ctf.score.red}
                    delete {ctf.score.blue}
    loop {ctf.blue::*}:
        if distance between loop-value and {ctf.blue.spawn} is less than 3:
            if loop-value's inventory contains red wool:
                add 1 to {ctf.score.blue}
                remove all red wool from loop-value's inventory
                broadcast "&9%loop-value% &fcaptured the flag! &9Blue: &f%{ctf.score.blue} ? 0%"
                if {ctf.score.blue} >= 3:
                    broadcast "&9&l===== BLUE TEAM WINS ====="
                    delete {ctf.score.red}
                    delete {ctf.score.blue}

get it running

ctf-basics.sk · 70 lines · vanilla Skript
  1. 1

    copy or download

    grab the .sk file with the buttons up top.

    ctf-basics.sk· ready to drop in
  2. 2

    drop it in your scripts folder

    save it exactly here on your server — no typos, just copy the path:

    …/plugins/Skript/scripts/ctf-basics.sk
  3. 3

    reload in-game

    run this in chat or console — your script goes live instantly:

    /sk reload ctf-basics
that's it — your script is live. hop in-game to try it.
/ related templates

more minigame templates

comments