#Need help with displaying cooldown that is counting up as a countdown

1 messages · Page 1 of 1 (latest)

tight ginkgo
#

I need this to display on an actionbar.

#

Currently it is counting up in chat, but I need it to count down.

#

Example screenshot:

#

Also if it would show only the amount of seconds / minutes and not the decimals that would be nice

#

This is what using an ability looks like:

#

Here is an example of a condition in each ability: if difference between now and {cooldown::%player's uuid%} is not less than 5 seconds:

#

Here is the code that displays the time as of right now:

    loop all players:
        set {cooldownyeah::%loop-player's uuid%} to difference between {cooldown::%loop-player's uuid%} and now
        send "%{cooldownyeah::%loop-player's uuid%}%" to loop-player ```
#

If i could get some help soon that would be nice thanks

#

(Please ping me)

junior fossil
#

if you want to count down, set the time to a date in the future, such as 4 minutes from now
if you want to get rid of the decimals, change the number accuracy setting in the skript config to 0

wicked raft
#

There’s also a bunch of timespan formatting snippets

tight ginkgo
#

he's offline so could u help me @wicked raft

wicked raft
#
  1. be patient and dont ping please
  2. send_code
tight ginkgo
#

sowwy

#

literally all i changed from the above code is i changed making the time now to set {cooldown::%player's uuid%} to 5 seconds from now
and changed the condition to if {cooldown::%player's uuid%} is 0 seconds:

#

and i'm trying to write smth that checks for the time being 0 and then stops counting but idk how to make it stop

#

i could prob just make a loop that changes it but idk

wicked raft
#

just check now > {}

tight ginkgo
#

wdym

#

what i'm doing rn is i'm making it check for the time being 0 seconds every tick then waiting 10 and if it's more than 0 it should stop counting but idk how to make it do that

#
    loop all players:
        if {cooldown::%loop-player's uuid%} is 0 seconds:
            wait 10 ticks
            if {cooldown::%loop-player's uuid%} is more than 0 seconds:
                uhhh like stop counting????? ```
#

wrong variable hold on

#

there we go

tight ginkgo
#

i did that yes

tight ginkgo
#

but it starts counting up after going to 0

wicked raft
#

because then you only ever need 1 variable--the timestamp at which the cooldown is ended
then you can use the difference between t1 and t2 to get the tim until then

wicked raft
#

thats how math owrks

tight ginkgo
#

yeah but how do i make it stop bc after it goes past 0 the abilities don't work

wicked raft
#

just delete the variable

tight ginkgo
#

how i didn't know u could do that lol

#

delete variable {cooldown::%loop-player's uuid%}

wicked raft
# wicked raft thats how math owrks

difference between 08:00 and 12:00 is 4 hours
difference between 16:00 and 12:00 is also 4 hours (technically -4 hours but skript takes the absolute value, you need to check if a time is > or < than now to get the sign)

tight ginkgo
#

like that?

wicked raft
#

delete {}

tight ginkgo
#

ah alr

wicked raft
#

I would delete it in the same place you set it, checking if the cooldown is expired,set COOLDOWN to DURATION from now wait DURATION + 1 tick #: (1 tick just in case) if now > COOLDOWN: #:check cooldown is in the past (expired) delete COOLDOWN

tight ginkgo
#

what i'm trying to do is this every 1 tick: loop all players: if {cooldown::%loop-player's uuid%} is less than 1 second: wait 20 ticks if {cooldown::%loop-player's uuid%} is more than 0 seconds: delete {cooldown::%loop-player's uuid%}

#

it isn't working

#

it just counts up again

#

idk why it should delete it

#

i've messed with it a ton and it still won't do it

#

i made a command that deletes it and does work tho

wicked raft
#

dont loop all players every tick

tight ginkgo
#

why not

wicked raft
#

very inefficient

tight ginkgo
#

my server is good enough it's alr

#

idrc abt resources tbh

wicked raft
#

thats not a good attitude to have

wicked raft
tight ginkgo
#

well my max playercount is like 15 or so at once and my server is 32gb ddr5 ram

#

and some threadripper cpu lol

wicked raft
tight ginkgo
#

i'm stupid can u plz tell me how do do that o-o

wicked raft
#

make a function or custom effect that accepts

  • an ID (cooldown name)
  • a timespan (cooldown duration)
    and apply the cooldown there
#

because those can be asynchronous without affecting main code

tight ginkgo
#

idk how to define the id and timespana

#

timespan

#

found this but how do i change the parameters

wicked raft
tight ginkgo
#

how

#

there is no documentation i can find

#

how do i format it

#

just keeps saying it doesn't understand

wicked raft
tight ginkgo
#

function cooldown(id, timespan):
broadcast "yes"

#

like idk how it's supposed to be formatted

#

there is no documentation

#

there is this

wicked raft
#

you need to specify the parameter type, not just the parameter name

tight ginkgo
#
    broadcast "yes"```
wicked raft
#

its a name

#

a string

#

cooldown isnt a type

tight ginkgo
#
    broadcast "yes" ```
wicked raft
#

the type of id should be string

tight ginkgo
#
    broadcast "yes" ```
#

doesn't work still

wicked raft
#

you changed the wrong thing

tight ginkgo
#

ohhh nvm

#

i'm slow sry xd

#

k so now i just put the stuff from before into this

#

what do i change cooldown and duration to

#

just timespan and id?

#

or do i create variables or smth

wicked raft
tight ginkgo
#

ah

#

so like this?

    set {_id} to {_timespan} from now
    wait {_timespan} + 1 tick
    if now > {_id}:
        delete {_id} ```
wicked raft
#

no

tight ginkgo
#

what then i did what it said in the ss

#

do i use string instead of id

wicked raft
#

you dont want to set the id

#

you want to use the ID as an index in a cooldown variable

#

so you can tell cooldowns appart

#

oh and you need to pass in the player obviously

tight ginkgo
#

i'm new to this idk what you are talking abt 😭

#

i didn't even know u could make functions

#

ig i will just go back to what i was using before and just use item cooldowns like ender pearls n stuff

#

bc idk how to do this

#

-_-