Changed folder name.
Changed folder name.
This commit is contained in:
71
_module/nss/se_inc_reset.nss
Normal file
71
_module/nss/se_inc_reset.nss
Normal file
@@ -0,0 +1,71 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// PROTOTYPES
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Send message to all players
|
||||
void SE_MessageToAllPC(string sMsg);
|
||||
|
||||
// Restart module timer message
|
||||
void SE_SendResetMsg();
|
||||
|
||||
// See the onmoduleload script to adjust the variables below.
|
||||
// Restart module on a certain game month/s
|
||||
// nMonth - game month to reset server
|
||||
// fDelay - check the current calender month interval
|
||||
// fTimer - count down timer prior to server reset
|
||||
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)
|
||||
{
|
||||
//If the current calender month is greater than the nMonth*
|
||||
//*see the onmoduleload script @ SE_NWNX_ResetModuleCheck( *, 30, 120);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user