Solved Combat log skript

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

  • LOOKING FOR A VERSION OF SKRIPT?

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

Remo

Member
Mar 20, 2024
41
3
8
Hello, I am trying to make a combat log like skript. For some reason this always crash my game when i get damaged by someone, and doesnt even work how it should be (if you get damaged twice, or if you get damaged while the "while blabla" system is working the "while" system get doubled or happen again), can someone help me please ? this is my code, Thank you !
Code:
on damage:
    attacker is player
    victim is player
    set metadata tag "damaged" of victim to true
    set {cb.time.%victim's uuid%} to 10
    while {cb.time.%victim's uuid%} is higher than 0:
        if metadata tag "damaged" of victim is false:
            send action bar "Combat %{cb.time.%victim's uuid%}%" to victim
            wait 1 second
            subtract 1 from {cb.time.%victim's uuid%}
 
You are setting
Code:
metadata tag "damaged" of victim

to true and doing a while loop that's ok but you are using:
code_language.skript:
        if metadata tag "damaged" of victim is false:
            send action bar "Combat %{cb.time.%victim's uuid%}%" to victim
            wait 1 second
            subtract 1 from {cb.time.%victim's uuid%}


if metadata tag "damaged" of victim is false:

This condition will always not work. Because you just set it to true.
 
Ooh i get it thanks, and can you help me with this ? I want to do that if someone get hit, the countdown starts until the variable is 0. But when someone get hit while the countdown, the countdown happen again and i have 2 countdowns at once and final number is not 0 but -1. I want to make that if you get hit the previous countdown stops and a new one starts so the countdown is reseted. Sorry for my english, if you dont understand something then tell me.
 
Python:
on damage:
    if attacker is a player:
        if victim is a player:
            if {combatTimer::%victim%} isn't set:
                set {combatTimer::%victim%} to 10
                while {combatTimer::%victim%} >= 0:
                    send action bar "&fYou are in combat for &b%{combatTimer::%victim%}%" to victim
                    remove 1 from {combatTimer::%victim%}
                    wait 1 second
                delete {combatTimer::%victim%}


on quit:
    if {combatTimer::%player%} is set:
        delete {combatTimer::%player%}
        # do something if player is in combat

on load:
    delete {combatTimer::*}

here it is.

sry, updated.
 
Thanks very much, it doesnt double this time, but still theres a problem. When I get hit during the countdown it doesnt reset the countdown and it just continue
 
Python:
on damage:
    if attacker is a player:
        if victim is a player:
            if {combatTimer::%victim%} isn't set:
                set {combatTimer::%victim%} to 10
                while {combatTimer::%victim%} >= 0:
                    send action bar "&fYou are in combat for &b%{combatTimer::%victim%}% seconds" to victim
                    remove 1 from {combatTimer::%victim%}
                    wait 1 second
                delete {combatTimer::%victim%}

            else:
                set {combatTimer::%victim%} to 10


on quit:
    if {combatTimer::%player%} is set:
        delete {combatTimer::%player%}
        # do something if player is in combat

on load:
    delete {combatTimer::*}

Fixed!
 
Maaan cant tell you how thankful I am. You will go to heaven for this. Thanks dude