PoA_PRC8/_module/nss/se_inc_reset3.nss
Jaysyn904 8d97886c3f Changed folder name.
Changed folder name.
2022-10-07 21:08:37 -04:00

69 lines
2.2 KiB
Plaintext

// -----------------------------------------------------------------------------
// PROTOTYPES
// -----------------------------------------------------------------------------
// Send message to all players
void SE_MessageToAllPC(string sMsg);
// Restart module timer message
void SE_SendResetMsg();
//(Adjust the Advanced Module Properties (Minutes / Hour & Starting Day)
// Restart module on a certain game month/s (Already set up)
// nMonth - game month to reset server (Must be 1 Higher than Current!)
// fDelay - check the current calender month interval(In Seconds)
// fTimer - count down timer prior to server reset (In Seconds)
void SE_NWNX_ResetModuleCheck(int nMonth, float fDelay, float fTimer);
// -----------------------------------------------------------------------------
// FUNCTIONS
// -----------------------------------------------------------------------------
void SE_MessageToAllPC(string sMsg)
{
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
SendMessageToPC(oPC, sMsg);
oPC = GetNextPC();
}
}
void SE_SendResetMsg()
{
float fMsgTimer = GetLocalFloat(GetModule(), "ResetTimer");
SetLocalFloat(GetModule(), "ResetTimer", fMsgTimer - 1.0);
SE_MessageToAllPC("Server reset in " + FloatToString(fMsgTimer, 0, 0) + " seconds.");
if(fMsgTimer != 0.0)
{
DelayCommand(1.0, SE_SendResetMsg());
}
else
{
object oPC = GetFirstPC();
ExportSingleCharacter(oPC);
oPC = GetNextPC();
while (GetIsObjectValid(oPC))
{
BootPC(oPC);
oPC = GetNextPC();
}
}
}
void SE_NWNX_ResetModuleCheck(int nMonth, float fDelay, float fTimer)
{
int aMonth = GetCalendarMonth();
if( aMonth >= nMonth)
{
SE_MessageToAllPC(IntToString(nMonth) + " game months reached - Automated server reset initiated.");
SetLocalFloat(GetModule(), "ResetTimer", fTimer);
DelayCommand(GetLocalFloat(GetModule(), "ResetTimer") + 4.0, SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"));
SE_SendResetMsg();
}
else
{
DelayCommand(fDelay, SE_NWNX_ResetModuleCheck(nMonth, fDelay, fTimer));
}
}