logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Function idea: Shutdown server
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Drakken05



Joined: 12 Jun 2006
Posts: 3

PostPosted: Mon Aug 28, 2006 5:37    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Mon Aug 28, 2006 7:47    Post subject: Reply with quote

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
View user's profile Send private message
Last_Yuzong



Joined: 01 Apr 2007
Posts: 11
Location: Germany

PostPosted: Thu Apr 05, 2007 19:11    Post subject: Reply with quote

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
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Apr 07, 2007 11:30    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Last_Yuzong



Joined: 01 Apr 2007
Posts: 11
Location: Germany

PostPosted: Sat Apr 07, 2007 15:31    Post subject: Reply with quote

I have NWNX4 but I do not have any of these NWNX4 folders and files.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Apr 09, 2007 22:25    Post subject: Reply with quote

Did you get the stuff from the subversion repository ?

http://www.nwnx.org/phpBB2/viewtopic.php?t=620
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
KamaZer0



Joined: 04 Jul 2007
Posts: 2

PostPosted: Thu Jul 05, 2007 0:14    Post subject: Reply with quote

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 Smile

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 Very Happy
Back to top
View user's profile Send private message
JohnB



Joined: 11 Jul 2007
Posts: 10

PostPosted: Mon Jul 30, 2007 11:05    Post subject: Reply with quote

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.

Smile
Back to top
View user's profile Send private message
william_hunter



Joined: 31 Jan 2007
Posts: 149

PostPosted: Wed Aug 01, 2007 2:41    Post subject: Reply with quote

Yeah! What he said!

I just like NWN1 better, thanks.
_________________
The Realm of Tharagon NWN PW
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Wed Aug 01, 2007 2:53    Post subject: Reply with quote

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
View user's profile Send private message
OnyxEye



Joined: 07 Sep 2007
Posts: 2

PostPosted: Fri Sep 07, 2007 16:34    Post subject: Reply with quote

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
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Mon Sep 10, 2007 0:05    Post subject: Reply with quote

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
View user's profile Send private message
OnyxEye



Joined: 07 Sep 2007
Posts: 2

PostPosted: Wed Sep 12, 2007 15:56    Post subject: Reply with quote

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
View user's profile Send private message
Clisair



Joined: 27 Jun 2006
Posts: 9

PostPosted: Tue Jan 08, 2008 0:27    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Thu Mar 20, 2008 4:16    Post subject: Reply with quote

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. Very Happy
_________________
Nepenthe - An NWN2 Persistant World, coming to a planet near you. http://www.nepentheonline.com
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 5 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group