Bin4ry Posted September 3, 2012 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 782 Reputation: 82 Joined: 01/01/12 Last Seen: September 21, 2015 Share Posted September 3, 2012 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? Quote Link to comment Share on other sites More sharing options...
Euphy Posted September 3, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted September 3, 2012 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; 2 Quote Link to comment Share on other sites More sharing options...
Aerie Posted September 3, 2012 Group: Members Topic Count: 11 Topics Per Day: 0.00 Content Count: 383 Reputation: 110 Joined: 11/11/11 Last Seen: August 2, 2017 Share Posted September 3, 2012 Maybe something like this : OnInit: if (isday()==1) { disablenpc "XXX";} if (isnight()==1) { enablenpc "XXX";} sleep2 60000; donpcevent "XXX::OnInit"; end; Quote Link to comment Share on other sites More sharing options...
clydelion Posted September 4, 2012 Group: Members Topic Count: 17 Topics Per Day: 0.00 Content Count: 754 Reputation: 186 Joined: 05/22/12 Last Seen: October 15, 2022 Share Posted September 4, 2012 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; 2 Quote Link to comment Share on other sites More sharing options...
Bin4ry Posted September 4, 2012 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 782 Reputation: 82 Joined: 01/01/12 Last Seen: September 21, 2015 Author Share Posted September 4, 2012 (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 September 4, 2012 by darristan Quote Link to comment Share on other sites More sharing options...
Question
Bin4ry
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.