Jump to content
  • 0

Question regarding to *isnight()


Bin4ry

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  782
  • Reputation:   82
  • Joined:  01/01/12
  • Last Seen:  

Like title, I'd like to create a shop NPC who only appears at night. My server day/night duration is 7200000/1200000.

Is there any alternative way instead to use a timer loop every mins to check isnight and enable the NPC?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

You can control day/night cycles using a script instead of through conf.

OnClockXXXX:
   day;
   disablenpc "Your NPC";
   end;
OnClockXXXX:
   night;
   enablenpc "Your NPC";
   end;

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  383
  • Reputation:   109
  • Joined:  11/11/11
  • Last Seen:  

Maybe something like this :

OnInit:
if (isday()==1) {
disablenpc "XXX";}
if (isnight()==1) {
enablenpc "XXX";}
sleep2 60000;
donpcevent "XXX::OnInit";
end;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

or call a label from within the source..

Index: pc.c
===================================================================
--- pc.c (revision 16138)
+++ pc.c (working copy)
@@ -8399,6 +8399,7 @@
 night_flag = 0; // 0=day, 1=night [Yor]
 map_foreachpc(pc_daynight_timer_sub);
 strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived!
+ npc_event_doall("OnDay");
 intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0);
 return 0;
}
@@ -8420,6 +8421,7 @@
 night_flag = 1; // 0=day, 1=night [Yor]
 map_foreachpc(pc_daynight_timer_sub);
 strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen...
+ npc_event_doall("OnNight");
 intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0);
 return 0;
}

then based on Euphy's script, you can use..

OnDay:
disablenpc "Your NPC";
end;

OnNight:
enablenpc "Your NPC";
end;

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  782
  • Reputation:   82
  • Joined:  01/01/12
  • Last Seen:  

Thank you everyone. @cyldelion, why is that wasn't implemented into svn yet. convenient indeed!

Edit: Do I need an OnInit to trigger the NPC first? Not sure if OnDay will trigger when server start..

Edit 2: Confirmed working without OnInit, thank you again.

Edited by darristan
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...