Jump to content
  • 0

Question regarding to *isnight()


Question

Posted

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?

4 answers to this question

Recommended Posts

Posted

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
Posted

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
Posted (edited)

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...