Tag (sorta)

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

nrostochel

New Member
Apr 6, 2025
6
1
3
Category:Skript,minigame ig


Suggested name:Tag

Spigot/Skript Version:I don't know what it means

What I want:I want a mini game where host runs from people and past one to hit the host is dead
A proper description.I want to make a minigame on start of which host will run and Normal people will get teleported to a box (in a wall) and after 5 seconds wall from the box to the arena will cut and players will run to the host host will have glowing effect and people will run to host when people hit host(I want it to work with pvp plugin off) they will get teleported to waiting area and last one will get eliminated then players in waiting arena get teleported to the box with the wall closed (its in glass) after 5 seconds its cut and yeah last to hit the host dies btw it should get broadcasted who died and last one standing wins! This should be also broadcasted

Ideas for commands:
/startgame: is to start the game
/wallpos1: position 1 of wall which will be cut and then placed back
/wallpos2: position 2 of wall which will be cut and then placed back
/setwaitingarena: position players will get teleported to when they hit the host
/setgameposition: position players will get teleported to when the game is started or round is finished
/timerlength: length of the timer which opens the box
/sethost: by default the host is who executed command /startgame but this one will change the host

Ideas for permissions:
op

When I'd like it by:
I'd like asap but yall can take as long as ya want
 
i have a skript but I need to play test if first to see if it works, so give me a week or so to debug it.
 
sorry I got a bit busy and didn't have time to test it, but here it is.
Code:
options:
  timerlength: 5 # Default seconds before wall opens

# Game Commands

command /startgame:
    permission: op
    trigger:
        if {cth.host} is not set:
            set {cth.host} to player
        broadcast "&e[ChaseTheHost] &fGame started! Host is &b%{cth.host}%&f!"
        apply potion of glowing of tier 1 to {cth.host} for 999 days

        delete {cth.players::*}
        loop all players:
            if loop-player is not {cth.host}:
                add loop-player to {cth.players::*}
                teleport loop-player to {cth.gameposition}
        wait {@timerlength} seconds
        cut_wall()
        start_tracking()

command /sethost <offlineplayer>:
    permission: op
    trigger:
        set {cth.host} to arg-1
        send "&aHost set to &b%arg-1%&a."

command /wallpos1:
    permission: op
    trigger:
        set {cth.wall.1} to location of player
        send "&aWall position 1 set."

command /wallpos2:
    permission: op
    trigger:
        set {cth.wall.2} to location of player
        send "&aWall position 2 set."

command /setwaitingarena:
    permission: op
    trigger:
        set {cth.waiting} to location of player
        send "&aWaiting area set."

command /setgameposition:
    permission: op
    trigger:
        set {cth.gameposition} to location of player
        send "&aGame start/box position set."

command /timerlength <number>:
    permission: op
    trigger:
        set {cth.timerlength} to arg-1
        send "&aWall timer set to &b%arg-1% seconds."

# Functions

function cut_wall():
    if {cth.wall.1} and {cth.wall.2}:
        set {cth.oldwall::*} to blocks between {cth.wall.1} and {cth.wall.2}
        loop blocks between {cth.wall.1} and {cth.wall.2}:
            set loop-block to air
        broadcast "&aWall opened!"

function close_wall():
    loop {cth.oldwall::*}:
        set {cht.oldwall::loop-value} to glass
    clear {cth.oldwall::*}
    broadcast "&cWall closed."

function start_tracking():
    clear {cth.tagged::*}
    clear {cth.remaining::*}
    loop {cth.players::*}:
        add loop-value to {cth.remaining::*}
    broadcast "&fRound started! Tag the &bHOST&f!"

function check_end_condition():
    if size of {cth.remaining::*} is 1:
        set {_last} to {cth.remaining::1}
        broadcast "&c%{_last}% was the last to tag and is eliminated!"
        remove {_last} from {cth.players::*}
        teleport {_last} to location(0, 10, 0)
        if size of {cth.players::*} is 1:
            broadcast "&6%{cth.players::1}% &awon the game!"
            stop_game()
        else:
            next_round()

function next_round():
    wait 2 seconds
    loop {cth.tagged::*}:
        teleport loop-value to {cth.gameposition}
    clear {cth.tagged::*}
    wait {@timerlength} seconds
    cut_wall()
    start_tracking()

function stop_game():
    clear {cth.host}
    clear {cth.players::*}
    clear {cth.tagged::*}
    clear {cth.remaining::*}
    close_wall()

# Tagging Logic (Damage Detection)

on damage:
    attacker is a player
    victim is a player
    victim is {cth.host}
    attacker is in {cth.players::*}
    cancel event
    if attacker is in {cth.tagged::*}:
        stop
    add attacker to {cth.tagged::*}
    teleport attacker to {cth.waiting}
    broadcast "&b%attacker% &atagged the host!"
    remove attacker from {cth.remaining::*}
    check_end_condition()