View previous topic :: View next topic |
Author |
Message |
Drakken05
Joined: 12 Jun 2006 Posts: 3
|
Posted: Mon Aug 28, 2006 5:37 Post subject: |
|
|
Does anyone have a script that they are using to automatically restart the server after 'nn' hours or minutes? I am looking at doing this on the heartbeat, but would gladly take any advice that is given!
Drakken
www.wrathofzero.com |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Aug 28, 2006 7:47 Post subject: |
|
|
Heartbeat is probably the best wy to do it, with a few reservations. First, compartmentalize your code so very little runs every hearbeat. Here's an example of HG's heartbeat, which is only used to calculate uptime and to poll the database for interserver messages:
Code: |
#include "aps_include"
object FindAddressee(string sPlayername)
{
string sCheck;
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
sCheck = GetPCPlayerName(oPC);
if (sCheck == sPlayername) return oPC;
oPC = GetNextPC();
}
return OBJECT_INVALID;
}
void main()
{
int nTime = GetLocalInt(OBJECT_SELF,"uptime");
nTime = nTime + 5;//changed from 6 because server firing hb every 5.012 seconds
SetLocalInt(OBJECT_SELF,"uptime", nTime);
if (!(nTime%60))
{
string sServer = GetLocalString(OBJECT_SELF, "ServerNumber");
string sSQL = "SELECT name, sender, message FROM messages WHERE server = '" + sServer + "'";
string sMessage, sName, sLocalString;
object oAddressee, oPC;
string sSender;
int nCount = 1;
int nX;
object oMod = GetModule();
SQLExecDirect(sSQL);
while(SQLFetch() != SQL_ERROR)
{
sMessage = SQLDecodeSpecialChars(SQLGetData(3));
sName = SQLDecodeSpecialChars(SQLGetData(1));
sSender = SQLDecodeSpecialChars(SQLGetData(2));
PrintString(sMessage+sName+sSender);
if (sName == "None") AssignCommand(oMod, SpeakString(sMessage, TALKVOLUME_SHOUT));
else
{
oAddressee = FindAddressee(sName);
if (GetIsObjectValid(oAddressee))
{
FloatingTextStringOnCreature("<c þ >Interserver message received from " + sSender + "!</c>", oAddressee, FALSE);
SendMessageToPC(oAddressee, "<c þ >" + sMessage + "</c>");
}
}
}
sSQL = "DELETE FROM messages WHERE server = '" + sServer + "'";
SQLExecDirect(sSQL);
}
} |
NOTE: the heartbeat increments by 5 rather than by 6 because for some reason my Lin boxes run it more often. YMMV, I would recommend timing your heartbeats by comparing actual uptime with the above 'seconds' counter as tracked above, to get a more accurate accounting. You could even use a float if you wanterd to get REAL accurate, or use SQL for exact uptime, but this has worked out to be very accurate for uptime, surprisingly.
As you can tell, the above check fires a longer segment of code every 60 'seconds'. The easiest way to set up a timer for reset would be to pick the number of secondfs tyou want the first warning to fire at, and do your furst remainder 0 check there, though there are a few ways to set it up depending on the number of checks you want to use.
Funky
Funky |
|
Back to top |
|
|
Last_Yuzong
Joined: 01 Apr 2007 Posts: 11 Location: Germany
|
Posted: Thu Apr 05, 2007 19:11 Post subject: |
|
|
Hi,
were could i get these includes from:
Code: | // Includes.
#include "windows.h"
#include "../plugin.h"
#include "../../misc/log.h"
#include "wx/tokenzr.h"
#include "wx/hashset.h"
#include "strsafe.h" |
Or is there a way to make a plugin without? |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Sat Apr 07, 2007 11:30 Post subject: |
|
|
I answered this in a PM, maybe someone else will stumble onto the same problem:
#include "windows.h"
-> default windows 32 API, you should already have it
#include "../plugin.h"
-> nwnx4\src\plugins folder
#include "../../misc/log.h"
-> nwnx4\src\misc folder
#include "wx/tokenzr.h"
#include "wx/hashset.h"
-> nwnx4\lib\wxwidgets folder. If you do not have this one, please check out the wxWidgets branch from my Subversion repository. It's a precompiled version that should offer everything you need.
Hope this helps! _________________ Papillon |
|
Back to top |
|
|
Last_Yuzong
Joined: 01 Apr 2007 Posts: 11 Location: Germany
|
Posted: Sat Apr 07, 2007 15:31 Post subject: |
|
|
I have NWNX4 but I do not have any of these NWNX4 folders and files. |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
|
Back to top |
|
|
KamaZer0
Joined: 04 Jul 2007 Posts: 2
|
Posted: Thu Jul 05, 2007 0:14 Post subject: |
|
|
i know this thread is old but,...as one who just this past week started trying to use NWNX2 instead of the FastFrench,...this thread has been very helpful to me
I AM SOoo glad that this community has kept its nwn1 boards in place instead of dumping it all for just nwn2. There are those of us still loving our nwn1 and still out here creating stuff for it |
|
Back to top |
|
|
JohnB
Joined: 11 Jul 2007 Posts: 10
|
Posted: Mon Jul 30, 2007 11:05 Post subject: |
|
|
And then there are those of us who get frustrated with NWN2 and need some respite, as well as a whole community of developers who just can't get on with NWN2 at all.
|
|
Back to top |
|
|
william_hunter
Joined: 31 Jan 2007 Posts: 149
|
Posted: Wed Aug 01, 2007 2:41 Post subject: |
|
|
Yeah! What he said!
I just like NWN1 better, thanks. _________________ The Realm of Tharagon NWN PW |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Wed Aug 01, 2007 2:53 Post subject: |
|
|
Ugh don't even mention NWN2 to me >.>
I just learned how to script well in NWN1 and I plan on staying here a long time. Surprisingly, there's still a lot of players around too! |
|
Back to top |
|
|
OnyxEye
Joined: 07 Sep 2007 Posts: 2
|
Posted: Fri Sep 07, 2007 16:34 Post subject: |
|
|
Am I understanding correctly that if we write a script to export all characters and boot players one by one and then terminate the server process, then all info should be saved just as if they logged out? _________________ OnyxEye, Lead Admin
The Realms of Ghamede PW
http://www.ghamede.com |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Sep 10, 2007 0:05 Post subject: |
|
|
Character info is already saved when they logout or are booted. It is also saved when the server is shut down normally (doesn't crash). I've noticed that this fails, but only EXTREMELY rarely, too rarely to track down a cause, and so rare that I don't bother with a scripted Export in attempt to compensate.
Funky |
|
Back to top |
|
|
OnyxEye
Joined: 07 Sep 2007 Posts: 2
|
Posted: Wed Sep 12, 2007 15:56 Post subject: |
|
|
Thanks, Funky. I thought booting saved the characters, but just wanted to be safe and head off a catastrophe! _________________ OnyxEye, Lead Admin
The Realms of Ghamede PW
http://www.ghamede.com |
|
Back to top |
|
|
Clisair
Joined: 27 Jun 2006 Posts: 9
|
Posted: Tue Jan 08, 2008 0:27 Post subject: |
|
|
Ran into something interesting with the plugin. I run 3 instences of nwnx2 on one box and when I did a reset on one it terminated the other instead of the one I wanted.
Any clues on what to do? Crashes boot the right mod back up, but this is something totally new, teminate on one killed the wroing mod.
Is there any way to diferentiate? They are all in their own directories. _________________ Firinn Of Elisair
http://www.elisair.com/ |
|
Back to top |
|
|
Asmodae
Joined: 07 Jan 2005 Posts: 55
|
Posted: Thu Mar 20, 2008 4:16 Post subject: |
|
|
HI, I'm surprised people are still using and talking about this plugin and I apologize for not checking here earlier. (other things and all)
The reset plugin that I hacked together (with mostly other people's code) doesn't know or do anything about multiple server instances on a single machine. If it gets the right one it's probably chance.
If you're talking about the NWNX4 reset plugin, then that was done by someone else and I don't know anything about it. _________________ Nepenthe - An NWN2 Persistant World, coming to a planet near you. http://www.nepentheonline.com |
|
Back to top |
|
|
|