Prevent going into "spawn" region if user was hit in the last 30 seconds

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

ChikensBox

Member
Sep 30, 2023
3
0
1
i want to prevent going into "spawn" region if user was hit in the last 30 seconds
(i do have skbee and worldgaurd installed)
here is some mocup code (doesnt work its simply a explanation of how i want it to work)
code_language.skript:
on enter region "spawn":
    if player has been hit in the last 30 seconds:
        teleport player to (location outside of spawn)
 
Code:
on damage:
    if {hitted::%victim%} is not true:
        set {hitted::%victim%} to true
        set {hitted::cooldown::%victim%} to 30
        while {hitted::cooldown::%victim%} > 0:
            wait 1 second
            remove 1 from {hitted::cooldown::%victim%}
            if {hitted::cooldown::%victim%} <= 0:
                stop loop
        
        if {hitted::%victim%} is true:
            set {hitted::%victim%} to false
            send "&aYou can go spawn now!" to victim
        
on load:
    loop {hitted::*}:
        delete {hitted::%loop-index%}
        delete {hitted::cooldown::%player%}

on region enter:
    if "%event-region%" contains "REGIONNAME":
        if {hitted::%player%} is true:
            cancel event
            send "&c&l(!) &r&cYou need to wait &4{hitted::cooldown::%player%} &cseconds to go spawn!"

if i helped to you, please like my message :emoji_slight_smile: good luck.

Send bugs with error message.