Jump to content
  • 0

NPC timer unaffected by server reset


pajodex

Question


  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

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 pajodex
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

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";
  }

 

  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

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 by Sehrentos
Fix
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

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 ????

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   2
  • Joined:  02/10/18
  • Last Seen:  

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...