/*--------------------------------------------------------

Script Name: dm_does_reset
----------------------------------------------------------
Created By: Genisys(Guile)
Created On: 2/09/09
----------------------------------------------------------

This script is excuted from chat commands when the DM "says"
to reset..

----------------------------------------------------------*/
void SendMessages();
void DoBoot();

void main()
{
 object oPC = OBJECT_SELF;
 object oMe = GetModule();

WriteTimestampedLogEntry("*****SERVER RESTART INITIALIZED***** by: " + GetName(oPC) + " / " + GetPCPlayerName(oPC));

//Send messages to all PCs..
SendMessages();

//Boot All PCs FIRST
DelayCommand(6.0, DoBoot());

//Do a NWNX2 Reset...(Make sure this happens no matter what!)
DelayCommand(9.0, SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"));

}

void SendMessages()
{
       object oObject;

       //Tell all PCs there is gonna be an emergency restart...
      oObject = GetFirstPC();
      while(GetIsObjectValid(oObject))
       {
        FloatingTextStringOnCreature("EMERGENCY RESTART INITIATED", oObject);
        FloatingTextStringOnCreature("EMERGENCY RESTART INITIATED", oObject);
        FloatingTextStringOnCreature("EMERGENCY RESTART INITIATED", oObject);
        FloatingTextStringOnCreature("EMERGENCY RESTART INITIATED", oObject);
        FloatingTextStringOnCreature("EMERGENCY RESTART INITIATED", oObject);

        oObject = GetNextPC();
       }

}
void DoBoot()
{

   object oObject = GetFirstPC();
      while(GetIsObjectValid(oObject))
       {

        //AssignCommand(oObject, ActionSpeakString("Bye everyone, see you later!!", TALKVOLUME_SHOUT));
        BootPC(oObject);

        oObject = GetNextPC();
       }


}