ID:530878
 
(See the best response by DarkCampainger.)
Code:
        Cool_Down(obj/Technique/T, n)
while(n)
T.cooldown = n
T.suffix = "<font color=red>Cool-Down: [T.cooldown]"
sleep(10)
n --
if(!n)
T.cooldown = 0
T.suffix = "<font color=yellow>Ready</font color>"
break
if(!n)
..()


Problem description:
Thats my way of doing Cool Down. But i want to display mini second.I dont know how to do it so please help :P

Best response
If by "mini second" you mean ticks, you could reduce the sleep() to a single tick and either A) increase all cooldown times by a factor of 10 or B) reduce n by 0.1 each iteration instead of 1.0.

Also, the if(!n) is a little redundant, as that condition is assumed once the while() loop terminates (so you might as well move that block outside of the loop).
Sry but i really dont know what do you mean. Can you do a example please so i can see what do you mean. Ty
If you want the suffix to update more frequently, you'll have to reduce the sleep() within the while() loop. To then compensate for that change, you'll have to increase the value of 'n' or reduce the rate at which you subtract from it.
Check out this tutorial by JtGibson known as Action Locks here.
    Cool_Down(obj/Technique/T, n=0)
if(isnull(n) || !isnum(n)) return
n = max(0,n)

do
T.suffix = "[n>0 ? "<font color=red>Cool-Down: [T.cooldown]" : "<font color=yellow>Ready</font color>"]"
T.cooldown = n

n-=0.1
sleep(1)
while(n>=0)

..()


Ahh that's better. Pretty self-explanatory. I don't like if(n) because that assumes n is NOT zero. If n was 1 or -1, that statement would return true. For your case, I assume that's what you don't want.

Or we can create a thread so you don't hold up the program on a long cool down. (Assuming you haven't created a thread for this method already)

Cool_Down(obj/Technique/T, n=0)
if(isnull(n) || !isnum(n)) return
n = max(0,n)

spawn()
while(n>=0)
T.suffix = "[n>0 ? "<font color=red>Cool-Down: [T.cooldown]" : "<font color=yellow>Ready</font color>"]"
T.cooldown = n

n-=0.1
sleep(1)
..()
Sometime it displays example: 1.1999 ...And I dont want to see those 999. And timer is jumping if you use it in stats. I want cooldown like 2, 1.9, 1.8 atc
Just use round(T.cooldown,1) in your suffix.
Well once i use
T.suffix = "[n>0 ? "<font color=red>Cool-Down [round(T.cooldown,1)]" : "<font color=yellow>Ready</font color>"]"

it just display 9,8,7 with out ticks :/
Oh I missed the end of your post. round(T.cooldown, 0.1)
Yea i figured out and still it displays like this :
10, 9.5, 8.9 atc ... i want ticked to be displayed every sec like 10, 9.9, 9.8.
I am guessing i have to do something with sleep(1)
It is happening too quickly to be visually aesthetic. In the cooldown method, try multiplying n by 10 before you enter the loop.

change to n-=1

Change to sleep(10) and use round(T.cooldown,10)

What does that do?
Nvm man its cool. I used normal cooldown for stats and once you tried click on tech it displays text that it sas even ticking :)
                if(T.cooldown)
usr<<"<font color=silver>This technique is not ready yet, you must wait [round(T.cooldown,0.1)] seconds"
return

so ty so much for helping me out :)
Okay, to let you know if T.cooldown is ever negative, that statement will still execute. Could save you a hassle in the future.
Yea I saw it. Ty so much for fixing my code :) I am new in DM so I am still learning it :P People do mistakes but I belive with a lot of practice I will become a great coder one day ^^. So thank you so much for help!