![](templates/Classic/images/spacer.gif) |
mesla Beginner
Joined: 21 Dec 2010 Posts: 11
|
Posted: Sun Aug 28, 2011 11:26 am
Buff timer could someone help me |
I read a page on buff timees but I just did not seem to get it. Lets say I need to make a buff timer that Starts on "You create a subdimensional rift around you, speeding up the universe inside it."
trig "p say Haste on" when buff goes off it says "You feel slower as the strange subdimensional rift disappears." "p say Haste off"
How would i go about making a timer on this that would come up on the "p say haste off (time here)" like that when the buff drops.
I need some help i suck at this. |
|
Last edited by mesla on Sun Aug 28, 2011 6:15 pm; edited 1 time in total |
|
|
![](templates/Classic/images/spacer.gif) |
geniusclown Magician
![](images/avatars/20731695274100366dc4c2e.jpg)
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Sun Aug 28, 2011 3:03 pm |
I devised a method to track and compare times, hopefully it will help you. I use my computer's clock with the %time function to track such things. I created a variable functions to convert times between standard notation and milliseconds:
Code: |
#VAR timecode {%eval(%time(d)*86400000+%time(h)*3600000+%time(n)*60000+%time(s)*1000+%time(z))}
#VAR timedecode {%if(%int(%1/86400000)>0,%int(%1/86400000)" days, ")%int(%mod(%1,864000000)/3600000):%if(%int(%mod(%1,36000000)/60000)<10,0)%int(%mod(%1,36000000)/60000):%if(%int(%mod(%1,60000)/1000)<10,0)%int(%mod(%1,60000)/1000).%if(%mod(%1,1000)<100,0)%if(%mod(%1,1000)<10,0)%mod(%1,1000)} |
With that, it's easy to track times, as such:
Code: |
#TR {You create a subdimensional rift around you, speeding up the universe inside it.} {hastestart=@timecode}
#TR {You feel slower as the strange subdimensional rift disappears.} {#ECHO Haste lasted @timedecode(%eval(@timecode-@hastestart))} |
Note that calculating differences in time will work as long as the start and end times are in the same month (the code is way more complex to consider spanning months). |
|
_________________ .geniusclown
Last edited by geniusclown on Sun Aug 28, 2011 8:59 pm; edited 1 time in total |
|
|
![](templates/Classic/images/spacer.gif) |
mesla Beginner
Joined: 21 Dec 2010 Posts: 11
|
Posted: Sun Aug 28, 2011 5:59 pm |
Yes it works but it says Haste lasted 0:00:00.000
Ok wow not sure what that does ok. So lets say all I want is when buffs drop for it to say how long the buff was on in party chat its called p say |
|
|
![](templates/Classic/images/spacer.gif) |
geniusclown Magician
![](images/avatars/20731695274100366dc4c2e.jpg)
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Sun Aug 28, 2011 8:58 pm |
There's no built-in buff timers in CMUD that I know of. That's why I devised this method. I'm not sure why you got 0:00, but I suspect you saved the new value before comparing to the old value, so you just subtracted the current time from itself. To get it to send to your party instead of just echoing on your screen, change my code from "#ECHO" to "p say".
The first variable function, @timecode, turns the current time according to your computer clock into the number of milliseconds since the month started. This number is typically huge (one second after midnight on the 1st has a timecode of 1000, while one minute after midnight on the 1st of the month is 60000, or 60 seconds times 1000 milliseconds in each second). So, when you do "hastestart=@timecode", hastestart is now how many seconds since the first. If in 5 minutes, you do "#ECHO %eval(@timecode-@hastestart)", it will show 300000, which is 5 minutes * 60 seconds/minute * 1000 milliseconds/second = 300000 milliseconds.
The second function does the exact opposite. Given a number of milliseconds, it will return the number of days (if more than 24 hours), hours:minutes:seconds.milliseconds. So, if you type in #ECHO @timedecode(300000) it will show "0:05:00.000", or 5 minutes. @timedecode can be modified to be courser if you're only interested in minutes and seconds:
Code: |
#VAR timedecode {%int(%1/3600000) minutes and %int(%mod(%1,60000)/1000) seconds} |
I hope this clarifies things!
(note: my previous post in this thread had a typo in the code, which has been edited and fixed.) |
|
_________________ .geniusclown |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|