pajodex Posted February 12, 2018 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
1 Secrets Posted February 13, 2018 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
0 Sehrentos Posted February 12, 2018 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
0 pajodex Posted February 13, 2018 Author 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
0 pajodex Posted February 13, 2018 Author 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
0 drupi Posted March 9, 2018 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
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 pajodex5 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.