#cooldown system not activating

1 messages · Page 1 of 1 (latest)

dark thorn
#

this is all it says when i activate it and the cooldown value does seem to change

    set {_uuid} to uuid of {_p}
    #broadcast getCooldownVar({_cooldown}) - System.currentTimeMillis()
    if {_bookab} is "enhanced_sharpness":
        if difference between now and {bookcd::%{_uuid}%} <= 90 seconds:
            return true
        else if difference between now and {bookcd::%{_uuid}%} = 90 seconds:
            return true
        else:
            return false

function setCooldown(cooldown: player, value: int, active: int):
    set {_uuid} to uuid of {_cooldown}
    set {_v} to seconds of {_value}
    set {_a} to seconds of {_active}
    set {activecd::%{_uuid}%} to now + {_a}
    set {bookcd::%{_uuid}%} to now + {_v} + {_a}
    broadcast "%{activecd::%{_uuid}%}% : this is acvtive cooldown :)"
    broadcast "%{bookcd::%{_uuid}%}% : this is actual cooldown :)"

function bookability(p: player, bookab: string):
    set {_uuid} to uuid of {_p}
    if canUsePower({_p},{_bookab}) is true:
        if {_bookab} is "enhanced_sharpness":    
            setCooldown({_p}, 90, 12)
            broadcast "%{bookcd::%{_uuid}%}% : this is cooldown part 2!"
            play sound "block.beacon.power_select" at volume 0.30 at pitch 1.50 at location of {_p}
            set attack damage attribute of {_p} to attack damage attribute of {_p} + 0.5
            wait 12 seconds
            set attack damage attribute of {_p} to 1
    else:
        if getActionBarCooldown({_p}) contains "!":
            message "&cYour book ability is on cooldown for %getActionBarCooldown({_p})%" to {_p}
        else:
            message "&cYour book ability is on cooldown for %getActionBarCooldown({_p})%!" to {_p}

#
    set {_uuid} to uuid of {_p}
    set {_c} to getBookColor({_p})
    if canUsePower({_p},{booka::%{_uuid}%}) is true:
        set {_v} to "&aReady!"
    else:
        set {_vs} to getCooldownSeconds({_p})
        set {_vm} to getCooldownMinutes({_p})
        set {_va} to getActiveSeconds({_p})
        
        if {_vm} > 0:
            if {_vs} < 1:
                set {_v} to "&b%{_vm}%m"
            else:
                set {_v} to "&b%{_vm}%m %{_vs}%s"

        if {_vm} < 1:
            if {_vs} > 0:
                if {_va} is set:
                    set {_v} to "&cActive..."
                else:
                    set {_v} to "&b%{_vs}%s"

        if {_v} is not set:
            set {_v} to "&aReady!"
        

    send action bar "%{_c}%&l📖 |&f %{_v}%" to {_p}

function getCooldownSeconds(cooldown: player) :: int:
    set {_uuid} to uuid of {_cooldown}
    add seconds of difference between {bookcd::%{_uuid}%} and now to {_co}
    #add timespan(difference between {bookcd::%{_uuid}%} and now ,milliseconds),seconds) to {_co} parsed as integer
    #add Duration.ofMillis({bookcd::%{_uuid}%} - System.currentTimeMillis()).toSecondsPart() to {_coo}
    if {_coo} is 60:
        set {_coo} to 0
    return {_coo}
    
function getActiveSeconds(cooldown: player) :: int:
    set {_uuid} to uuid of {_cooldown}
    add seconds of difference between {activecd::%{_uuid}%} and now to {_co}
    #add timespan(difference between {bookcd::%{_uuid}%} and now ,milliseconds),seconds) to {_co} parsed as integer
    #add timespan(timespan({activecd::%{_uuid}%} - {furthestdate},milliseconds),seconds) to {_coo}
    #add Duration.ofMillis({bookcd::%{_uuid}%} - System.currentTimeMillis()).toSecondsPart() to {_coo}
    if {_co} is 60 seconds:
        set {_co} to 0
    return {_co}
#
    set {_uuid} to uuid of {_cooldown}
    set {_coo} to minutes of difference between {bookcd::%{_uuid}%} and now
    if seconds of difference between {bookcd::%{_uuid}%} and now is 60:
        add 1 minute to {_coo}
    return {_coo}```
distant wigeon
#

i have no idea what this is ill tell you that

dark thorn
# distant wigeon i have no idea what this is ill tell you that

first message has the functions about if the power is off cooldown (canUsePower), setting the cooldown(setCooldown), and the ability part itself(bookability)

second one is action bar display(BookAction), getting the seconds of cooldown for action bar(getCooldownSeconds), getting active timer seconds(getActiveSeconds) and the last one gets the cooldown minutes(getCooldown Minutes)

#

srry if its hard to read

distant wigeon
dark thorn
distant wigeon
#

oh

#

i swear theres so many easier ways to do this

#

can u tell me what u r doing

#

because

#

you just set it to x seconds from now

#

and then to check it you can do if {_varCooldown} < now # not ready

#

this is in a on every 1 second event so it should work with action bars

dark thorn
# distant wigeon ```if seconds of (difference between x seconds ago and {_varCooldown}) <= 0: # r...
    set {_uuid} to uuid of {_p}
    #broadcast getCooldownVar({_cooldown}) - System.currentTimeMillis()
    if {_bookab} is "enhanced_sharpness":
        if seconds of (difference between 90 seconds ago and {bookcd::%{_uuid}%}) <= 0: # ready:
            return true
        else if seconds of (difference between 90 seconds ago and {bookcd::%{_uuid}%}) = 0:
            return true
        else if {bookcd::%{_uuid}%} < now:
            return false
        else:
            return false```

i used this and it returned false
#

should i have set the cd variable to now or somehting else?

distant wigeon
#

set it to now

dark thorn
#
    set {_uuid} to uuid of {_cooldown}
    set {_coo} to minutes of difference between {bookcd::%{_uuid}%} and now
    if seconds of difference between {bookcd::%{_uuid}%} and now is 60:
        add 1 minute to {_coo}
    return {_coo}
compact leaf
#

Just get the total remaining seconds, and then do math.

#

minutes = floor(seconds/60); newSeconds = seconds - 60*minutes

dark thorn
# compact leaf `minutes = floor(seconds/60)`; `newSeconds = seconds - 60*minutes`

okay i did that but it counts up instead of down and when it is off cooldown it activates

    set {_uuid} to uuid of {_cooldown}
    add seconds of difference between now and {bookcd::%{_uuid}%} to {_co}
    broadcast {_co}
    set {_coo} to {_co} - (60*getCooldownMinutes({_cooldown}))
    if {_coo} is 60:
        set {_coo} to 0
    broadcast {_coo}
    return {_coo}


function getCooldownMinutes(cooldown: player) :: int:
    set {_uuid} to uuid of {_cooldown}
    set {_sec} to seconds of difference between {bookcd::%{_uuid}%} and now
    broadcast {_sec}
    set {_coo} to floor({_sec}/60)
    #if seconds of difference between {bookcd::%{_uuid}%} and now is 60:
    #    add 1 minute to {_coo}
    broadcast {_coo}
    return {_coo}
compact leaf
#

I wouldnt have 2 functions, i would use one

#

That returns like “Xmin Ys”

dark thorn
#

okay

dark thorn
compact leaf
dark thorn
# compact leaf Do `difference between {_remainingTime} and {_cooldownDuration}`

okay so now the cooldown check always says false

    set {_uuid} to uuid of {_p}
    if {_bookab} is "enhanced_sharpness":
        if seconds of (difference between 102 seconds ago and {bookcd::%{_uuid}%}) <= 0: # ready:
            return true
        else if seconds of (difference between 102 seconds ago and {bookcd::%{_uuid}%}) = 0:
            return true
        else if {bookcd::%{_uuid}%} < now:
            return false
        else:
            return false

function getCooldownMinutes(cooldown: player) :: int:
    set {_uuid} to uuid of {_cooldown}
    set {_sec} to seconds of difference between {bookcd::%{_uuid}%} and 1 minute and 30 seconds
    set {_coo} to floor({_sec}/60)
    #if seconds of difference between {bookcd::%{_uuid}%} and now is 60:
    #    add 1 minute to {_coo}
    broadcast {_coo}
    return {_coo}
    
function getCooldownSeconds(cooldown: player) :: int:
    set {_uuid} to uuid of {_cooldown}
    add seconds of difference between {bookcd::%{_uuid}%} and 1 minute and 30 seconds to {_co}
    set {_coo} to {_co} - (60*getCooldownMinutes({_cooldown}))
    if {_coo} is 60:
        set {_coo} to 0
    broadcast {_coo}
    return {_coo}```
compact leaf
#

I would just on event: if (time since {lastUsed}) < {cooldownDuration}: send "no, you need to wait %difference bwteen (time since {lastUsed}) and {cooldownDuration}%" stop ability code here

dark thorn
compact leaf
#

dont get the seconds of, that returns a num

#

you are comparing a time to a number

#

just do (time since {}) > {_s}

#

where s itself is a timespan

#

either that, or seconds of x >= seconds of y

last holly
dark thorn
dark thorn
# compact leaf either that, or `seconds of x >= seconds of y`
    set {_uuid} to uuid of {_p}
    set {_s} to {bookval::%{_uuid}%}
    if seconds of {bookcd::%{_uuid}%} >= seconds of {bookval::%{_uuid}%}:
        return true
    else if seconds of {bookcd::%{_uuid}%} = seconds of {bookval::%{_uuid}%}:
        return true
    else if seconds of {bookcd::%{_uuid}%} < seconds of {bookval::%{_uuid}%}:
        return false
    else:
        return false```

i tried this but same issue
#

also does it matter that {bookcd::%{_uuid}%} is set to now and {bookval::%{_uuid}%} is set to now + the active and regular time

main cedar
#

Not gonna read all this but good on you for having the patience to work on 1 problem for this long, i wouldve scrapped it 50 times by now

tribal remnant
distant wigeon
dark thorn
#

bc for the first condition i did but for the ones after i didnt

distant wigeon
#

oh

dark thorn
#

bump

rancid scaffold
#
    set {_uuid} to uuid of {_p}
    if {_bookab} is "enhanced_sharpness":
        if {bookcd::%{_uuid}%} is not set:
            return true
        if now >= {bookcd::%{_uuid}%}:
            return true
        else:
            return false

function setCooldown(p: player, cooldown_sec: number, active_sec: number):
    set {_uuid} to uuid of {_p}
    set {_a} to "%{_active_sec}% seconds" parsed as timespan
    set {_c} to "%{_cooldown_sec} + {_active_sec}% seconds" parsed as timespan
    set {activecd::%{_uuid}%} to now + {_a}
    set {bookcd::%{_uuid}%} to now + {_c}

function bookability(p: player, bookab: string):
    set {_uuid} to uuid of {_p}
    if canUsePower({_p}, {_bookab}) is true:
        if {_bookab} is "enhanced_sharpness":    
            setCooldown({_p}, 90, 12)
            play sound "block.beacon.power_select" at volume 0.3 at pitch 1.5 at location of {_p}
            set attack damage attribute of {_p} to 2.5
            wait 12 seconds
            set attack damage attribute of {_p} to 2.0
            send "&cYour Enhanced Sharpness has expired!" to {_p}
    else:
        set {_waited} to difference between {bookcd::%{_uuid}%} and now
        message "&cYour book ability is on cooldown for %{_waited}%!" to {_p}
dark thorn
# rancid scaffold ```function canUsePower(p: player, bookab: string) :: boolean: set {_uuid} t...
    set {_uuid} to uuid of {_p}
    set {_c} to getBookColor({_p})
    if canUsePower({_p},{booka::%{_uuid}%}) is true:
        set {_v} to "&aReady!"
    else:
        set {_vs} to getCooldownSeconds({_p})
        set {_vm} to getCooldownMinutes({_p})
        set {_va} to getActiveSeconds({_p})
        
        if {_vm} > 0:
            if {_vs} < 1:
                set {_v} to "&b%{_vm}%m"
            else:
                set {_v} to "&b%{_vm}%m %{_vs}%s"

        if {_vm} < 1:
            if {_vs} > 0:
                if {_va} is set:
                    set {_v} to "&cActive..."
                else:
                    set {_v} to "&b%{_vs}%s"

        if {_v} is not set:
            set {_v} to "&aReady!"
        

    send action bar "%{_c}%&l📖 |&f %{_v}%" to {_p}```


this is the skript i use to show the cooldonw
#

it just shows the minute and the seconds are -60 for some reason

#

everything else on it works proplery which is the weird part

distant wigeon
#

why not user hypers lib for cooldowns

dark thorn
distant wigeon
#

skript lib that lets you use “cooldown "ability" for %player% to %timespan%”

dark thorn
#

oh

dark thorn
#

thx

bold relicBOT
# dark thorn thx

Consider increasing someone's reputation with </reputation increase:1458495875985969212> if you found them to be helpful!

#

You successfully increased @distant wigeon's reputation. They now have 16 skoints!