pajodex Posted February 12, 2018 Group: Members Topic Count: 79 Topics Per Day: 0.03 Content Count: 439 Reputation: 173 Joined: 12/12/17 Last Seen: April 14 Share Posted February 12, 2018 (edited) hi, how do i make an npc continue doing a certain event even server is being reset? to further explain: <code> npc x = trigger an event where event will last for 1 hr. after an hour, event will end. if server is being reset or shutdown while event is being triggered, the NPC timer will pause and will resume after server is up again <code> i already tried OnTimerXXXX codes but it terminates the event after server is reset. any other available options for me? tia im on mobile, dont know how to make codebox x.x update: i added initnpctimer at OnInit label. however, it restarts the timer to 0. Edited February 12, 2018 by pajodex Quote Link to comment Share on other sites More sharing options...
1 Secrets Posted February 13, 2018 Group: Developer Topic Count: 36 Topics Per Day: 0.01 Content Count: 588 Reputation: 437 Joined: 01/26/16 Last Seen: Wednesday at 03:00 PM Share Posted February 13, 2018 Pseudocode, but I think you can get what I want to show here - script secret -1,{ OnFoo: $evt_tick = gettimetick(2); addtimer "somenpc::someevent",.delay_tick; end; OnInit: .delay_tick = youreventdelay; .@difftick = gettimetick(2) - $evt_tick; if(.@difftick < 0) { // timer still not elapsed addtimer "somenpc::someevent",.@difftick; } else { donpcevent "somenpc::someevent"; } 1 Quote Link to comment Share on other sites More sharing options...
0 Sehrentos Posted February 12, 2018 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 91 Reputation: 22 Joined: 10/24/14 Last Seen: November 1, 2024 Share Posted February 12, 2018 (edited) 8 hours ago, pajodex said: i added initnpctimer at OnInit label. however, it restarts the timer to 0 I don't think there is a way to continue npc timer after a reload. Maby OnClock event or other workaround ? - script DayNight -1,{ OnClock0600: day; end; OnInit: // setting correct mode upon server start-up if (gettime(DT_HOUR)>=6 && gettime(DT_HOUR)<18) end; OnClock1800: night; end; } Edited February 12, 2018 by Sehrentos Fix 1 Quote Link to comment Share on other sites More sharing options...
0 pajodex Posted February 13, 2018 Group: Members Topic Count: 79 Topics Per Day: 0.03 Content Count: 439 Reputation: 173 Joined: 12/12/17 Last Seen: April 14 Author Share Posted February 13, 2018 12 hours ago, Sehrentos said: I don't think there is a way to continue npc timer after a reload. Maby OnClock event or other workaround ? - script DayNight -1,{ OnClock0600: day; end; OnInit: // setting correct mode upon server start-up if (gettime(DT_HOUR)>=6 && gettime(DT_HOUR)<18) end; OnClock1800: night; end; } i have thought of this already. it doesn't really fit the need of the script i'm currently working on with. maybe i should just work around with my idea and use OnClock. thanks anyways Quote Link to comment Share on other sites More sharing options...
0 pajodex Posted February 13, 2018 Group: Members Topic Count: 79 Topics Per Day: 0.03 Content Count: 439 Reputation: 173 Joined: 12/12/17 Last Seen: April 14 Author Share Posted February 13, 2018 9 hours ago, Secrets said: Pseudocode, but I think you can get what I want to show here - script secret -1,{ OnFoo: $evt_tick = gettimetick(2); addtimer "somenpc::someevent",.delay_tick; end; OnInit: .delay_tick = youreventdelay; .@difftick = gettimetick(2) - $evt_tick; if(.@difftick < 0) { // timer still not elapsed addtimer "somenpc::someevent",.@difftick; } else { donpcevent "somenpc::someevent"; } i will try my best to comprehend thanks ???? Quote Link to comment Share on other sites More sharing options...
0 drupi Posted March 9, 2018 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 6 Reputation: 2 Joined: 02/10/18 Last Seen: May 4, 2021 Share Posted March 9, 2018 have you tried putting checkpoints on your script? *pseudocode* script{ #checkpoint =0; if (checkpoint==0) { //do something //since this part of the script is done, checkpoint+=; } if(checkpoint==1) { //do something //since this part of the script is done, checkpoint+=; } } this way, if your server is done with a part of the script, after you reset your server, the script will resume to the last part it has completed. Quote Link to comment Share on other sites More sharing options...
Question
pajodex
hi,
how do i make an npc continue doing a certain event even server is being reset?
to further explain:
<code>
npc x = trigger an event where event will last for 1 hr.
after an hour, event will end.
if server is being reset or shutdown while event is being triggered, the NPC timer will pause and will resume after server is up again
<code>
i already tried OnTimerXXXX codes but it terminates the event after server is reset.
any other available options for me? tia
im on mobile, dont know how to make codebox x.x
update:
i added initnpctimer at OnInit label. however, it restarts the timer to 0.
Edited by pajodexLink to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.