DM client module restart
From NWNWiki
Contents |
[edit] What it does
Restarts the module after all players leave when running the DMClient. Couldn't find a way to do it setting up the game (it's a checkbox on the dedicated server) so here.
Be sure to note that this WILL RESTART THE MODULE after the players leave, so if you're a DM and you're doing things, then after the players leave it is going to restart on you. You shouldn't be doing anything after a player leaves anyway.
You're going to need to create an NPC (I call my Feaf) somewhere inaccessible to the players.
[edit] The Scripts
[edit] Modules OnClientEnter
void main()
{
SignalEvent(GetObjectByTag("Feaf"), EventUserDefined(101));
}
[edit] ModulesOnClientLeave
void main()
{
SignalEvent(GetObjectByTag("Feaf"), EventUserDefined 201));
}
[edit] NPC's OnUserDefined
void main()
{
int iNumber;
string sCount;
int nUser = GetUserDefinedEventNumber();
switch(nUser)
{
case 101:
SpeakString("Someone is Coming");
iNumber = GetLocalInt(OBJECT_SELF,sCount);
iNumber = iNumber + 1;
SpeakString("The Count is now"); //Debugging purposes only
SpeakString(IntToString(iNumber)); //Debugging purposes only
SetLocalInt(OBJECT_SELF,sCount,iNumber);
return;
break;
case 201:
SpeakString("Someone is Leaving");
iNumber = GetLocalInt(OBJECT_SELF,sCount);
iNumber = iNumber - 1;
SpeakString("The count is now"); //Debugging purposes only
SpeakString(IntToString(iNumber)); //Debugging purposes only
SetLocalInt(OBJECT_SELF,sCount,iNumber);
if (GetLocalInt(OBJECT_SELF,sCount) == 1)
{
string sSelf = "HiddenAgenda"; //Replace with your module name here, this seems to be the FILENAME rather than the module name
StartNewModule(sSelf);
}
return;
break;
}
}
[edit] Notes
- The script shouldn't have any problems, tested it quite a few times, but email tenedos@brug.org if you have anything to say.
