Bin4ry Posted September 3, 2012 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
Euphy Posted September 3, 2012 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
Aerie Posted September 3, 2012 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
clydelion Posted September 4, 2012 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
Bin4ry Posted September 4, 2012 Author 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
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?
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.