View previous topic :: View next topic |
Author |
Message |
Valgav
Joined: 28 Aug 2010 Posts: 53
|
Posted: Sat Apr 18, 2015 19:25 Post subject: Timer, timer event and logout |
|
|
I need some counter not very accurate, probably not shorter than one minute but it would be great if it could.
Currently I'm using something like that:
-setting local variable with current timestamp on PC
-DelayCommand function
-function checks variable and removes it then do the stuff
-another function check variable on enter and if it exists and if current timestamp is later than that in variable, it applies the function if not and server was restarted it applies new delay.
But it's somehow messy and there are delays going even when player logs out so is there any other nice way to do that better? I thought about global function checking some array of current timers. But it's like going through list each time. |
|
Back to top |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Sun Apr 19, 2015 12:23 Post subject: |
|
|
Instead of using DelayCommand, you could just use the Module Heartbeat to check for timer expiry on each PC (with GetFirst/NextPC). That HB runs every 6 seconds. _________________ silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Apr 29, 2015 14:02 Post subject: |
|
|
Heartbeat or even pseudo HB's are more reliable than a single DelayCommand.
DelayCommand can be impacted by the Set time methods in nwscript.
Eg: Advancing the time by 1 hour, will advance the DelayCommand by RoundToSeconds(HourToRound(1)) ; or something like that.
On occasion I have found that by doing SetTime commands incorrectly, could actually trigger a 72 hour reboot timer instantly. |
|
Back to top |
|
|
|