ID:530878   Mar 16 2012, 10:31 pm (See the best response by DarkCampainger.) Code: ``` Cool_Down(obj/Technique/T, n) while(n) T.cooldown = n T.suffix = "Cool-Down: [T.cooldown]" sleep(10) n -- if(!n) T.cooldown = 0 T.suffix = "Ready" 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
 <-> Mar 16 2012, 10:44 pm 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).
 <-> Mar 16 2012, 10:55 pm 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
 <-> Mar 17 2012, 12:03 am 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.
 <-> Mar 17 2012, 5:42 pm Check out this tutorial by JtGibson known as Action Locks here.
 <-> Mar 18 2012, 9:45 am (Edited on Mar 18 2012, 9:56 am) ``` Cool_Down(obj/Technique/T, n=0) if(isnull(n) || !isnum(n)) return n = max(0,n) do T.suffix = "[n>0 ? "Cool-Down: [T.cooldown]" : "Ready"]" 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 ? "Cool-Down: [T.cooldown]" : "Ready"]" T.cooldown = n n-=0.1 sleep(1) ..() ```
 <-> Mar 18 2012, 9:56 am 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
 <-> Mar 18 2012, 10:01 am Just use round(T.cooldown,1) in your suffix.
 <-> Mar 18 2012, 10:08 am Well once i use ```T.suffix = "[n>0 ? "Cool-Down [round(T.cooldown,1)]" : "Ready"]" ``` it just display 9,8,7 with out ticks :/
 <-> Mar 18 2012, 10:10 am Oh I missed the end of your post. round(T.cooldown, 0.1)
 <-> Mar 18 2012, 10:13 am 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)
 <-> Mar 18 2012, 10:27 am 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?
 <-> Mar 18 2012, 10:30 am 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<<"This technique is not ready yet, you must wait [round(T.cooldown,0.1)] seconds" return ``` so ty so much for helping me out :)
 <-> Mar 18 2012, 10:33 am Okay, to let you know if T.cooldown is ever negative, that statement will still execute. Could save you a hassle in the future.
 <-> Mar 18 2012, 10:36 am 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!