Fight Timer

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

Benno812

Member
Mar 1, 2017
13
0
1
31
Hi, i'm trying to create a timer that turn on when you do or receive damage, count from 20 to 0 seconds and then turn off. If you do or receive other damage during that 20 seconds period the timer restarts. The purpose of this is to let you enter in some sort of "fight mode" in which you cannot tp, open menus etc. If 20 seconds pass without damage events you exit the fight mode.

code_language.skript:
on damage:
    victim is a player:
        send "&c You are in a fight" to victim

i tried by adding a "loop 20 times" thing but didn't work as expected.
 
Last edited:
code_language.skript:
on damage:
    victim is a player
    {RageQuit::%attacker%} is not victim:
        set {RageQuit::%attacker%} to victim
        set {CoolDown::%attacker%} to 20       
        while {CoolDown::%attacker%} is not 0:
            wait a seconds
            subtract 1 from {CoolDown::%attacker%}
            send "CombatLog: %{CoolDown::%attacker%}%"
 
This may not be the most efficient way of doing it, but this is part of my pvp combat log skript
code_language.skript:
on damage of player:
    attacker is a player
    if {combat.tag::%attacker%} is false:
        send "Tagged in combat for 15 seconds. Don't log out" to attacker
        set {combat.tag::%attacker%} to true
    if {combat.tag::%victim%} is false:
        send "Tagged in combat for 15 seconds. Don't log out" to victim
        set {combat.tag::%victim%} to true
    wait 15 seconds
    set {combat.tag::%attacker%} to false
    set {combat.tag::%victim%} to false
   
on command:
    command is equal to "spawn", "back", "tpa" or "home"
    if {combat.tag::%player%} is true:
        message "You can't teleport while tagged in combat"
        cancel event
       
On quit:
    if {combat.tag::%player%} is true:
        kill player
        broadcast "%player% was killed for combat logging."