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 
 
NWNX Administrator Help
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
lluewhyn



Joined: 20 Jul 2008
Posts: 4

PostPosted: Sun Jul 20, 2008 19:14    Post subject: NWNX Administrator Help Reply with quote

I've been having problems with my standard module reload causing the server the crash. The serverhost I use has NWNX installed, and he recommended THIS page for trying an alternate restart method:
http://nwvault.ign.com/View.php?view=Other.Detail&id=1307

The thing is, I know NOTHING about NWNX, and don't know how to bring up the console as they are speaking about to enter the different commands. Is it the same as the ~ console? I looked at the demo module on the page, but it doesn't really have much there to help, and there was no Readme. Can someone please give me step-by-step instructions as to what to do to get to the point where I would type in the reset command?
Back to top
View user's profile Send private message
lluewhyn



Joined: 20 Jul 2008
Posts: 4

PostPosted: Wed Jul 23, 2008 2:31    Post subject: Reply with quote

Is there no one here who knows the answer to this very basic question, or is it too complex to do without having a full understanding of how NWNx operates?
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Wed Jul 23, 2008 3:51    Post subject: Reply with quote

What is your 'standard' module reload? If you want, SIMTools (on the Vault) has a reset command, and comes with the reset plugin, and step-by-step installation instructions. It has yet to be updated to 1.69, however. Not really sure if that'd help though, without knowing more.

Funky
Back to top
View user's profile Send private message
lluewhyn



Joined: 20 Jul 2008
Posts: 4

PostPosted: Wed Jul 23, 2008 3:54    Post subject: Reply with quote

Just the typical GetNameOfModule/StartNewModule reset. However, this often causes the module to crash, and NWNx won't detect the crash. I can ask my serverhost to reset the module, but I'd prefer to be independent. He posted the link that I referenced above, but didn't know anything about it.
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Wed Jul 23, 2008 16:55    Post subject: Reply with quote

I wouldn't worry about that plugin - it seems more like for remote server administration. As Funky suggested, you should try using the nwnx_reset plugin - it's very easy to use. To reset the module, simply have the plugin installed and use the following line in a script somewhere:

SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1");

This line, when run, will instantly take the server down cleanly. The NWNX watchdog will then detect a crash and put it back up again.

If your server is a Linux server, you will have to make your own watchdog (a bash script checking for ps -A | grep nwserver being non-empty on a cron job is my solution).
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Wed Jul 23, 2008 19:57    Post subject: Reply with quote

lluewhyn wrote:
Just the typical GetNameOfModule/StartNewModule reset. However, this often causes the module to crash, and NWNx won't detect the crash. I can ask my serverhost to reset the module, but I'd prefer to be independent. He posted the link that I referenced above, but didn't know anything about it.


That doesn't stop the nwserver process, and doesn't clear up any memory leaks. You really want to use the reset plugin instead - it's one of the major benefits of nwnx.

Funky
Back to top
View user's profile Send private message
lluewhyn



Joined: 20 Jul 2008
Posts: 4

PostPosted: Thu Jul 24, 2008 2:13    Post subject: Reply with quote

I thank you for the suggestion. Question: How is that different from a regular crash? I know that normal crashes from mis-written scripts(a direct script that made an NPC talk and put in the OnConversation event which caused multiple NPCs to all "talk the server to death") will make the NWNx on this host tell there was a crash and reboot the server. It just seems like trying to reload the module while the module is running can cause it to go down and *not* have NWNx determine that there was a crash.

If I hadn't received a reply here, I was thinking about using a script which simply just did x function and then used the ExecuteScript function to call itself, thus causing a crash from the infinite looping, and a reboot. Is there an advantage to the NWNx method that you suggested?
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Thu Jul 24, 2008 7:24    Post subject: Reply with quote

Yes, it's a 'clean' shutdown, meaning all character's are saved.
Funky
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Thu Jul 24, 2008 11:34    Post subject: Reply with quote

Think of the NWNX Reset Plugin as a way of pressing the "Exit" button on the NWServer program if you're using Windows, or typing "exit" into the terminal if you're using Linux.
Back to top
View user's profile Send private message
Jimmy_Buffit



Joined: 11 Jun 2008
Posts: 2

PostPosted: Thu Jul 24, 2008 22:03    Post subject: Does this still work in 1.69? Reply with quote

Hi Guys,

I had some problems with the reset plugin recently after converting my server to 1.69. Everything seemed to work fine after patching from 1.68 to 1.69 but a few days later after re-installing NWN Diamond and patching from 1.66 to 1.69, the restart function stopped working.

SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"); is no longer killing the server.

My local PC and the remote server are running Windows XP, SP2.
I've tried both my NWN DVD's (Platinum/Diamond) and all the updates virusman has listed as of last night but still can't get it to work. I even reverted back to a beta 10 install and still can't get it working.

Does anyone have a suggestion for what the problem might be?

Thanks
Back to top
View user's profile Send private message Send e-mail
Jimmy_Buffit



Joined: 11 Jun 2008
Posts: 2

PostPosted: Fri Jul 25, 2008 13:42    Post subject: Re: Does this still work in 1.69? Reply with quote

Jimmy_Buffit wrote:
Hi Guys,

I had some problems with the reset plugin recently after converting my server to 1.69. Everything seemed to work fine after patching from 1.68 to 1.69 but a few days later after re-installing NWN Diamond and patching from 1.66 to 1.69, the restart function stopped working.


After several more experiments with re-installing and export/import I was able to get a clean update from my Platinum DVD and resolve this issue today. The restart plugin does take considerably longer to kill the server now but it does still work:) Corrupt files I guess?
Back to top
View user's profile Send private message Send e-mail
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Sun Dec 14, 2008 18:58    Post subject: Reply with quote

It's not like cheat console.If u got dm priviliges (by logging into the game with dm client), u can digit the commands on standard game chat and press enter, after this u will have your cmd executed by the plugin.

It's only for windows, because i used the win API to simulate mouse and key press on nwserver's window.

To shutdown the server i use the TerminateProcess API, i know isn't good for a clean logoff, but it was only an experiment.

Sorry for reupping an old post, but i saw it now Razz.

Holavez
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Mon Dec 15, 2008 4:56    Post subject: Reply with quote

While you're around: source, please? Smile
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Mon Dec 15, 2008 21:38    Post subject: Reply with quote

Zebranky wrote:
While you're around: source, please? Smile


Will post the sources when i come back home from work (in the week-end).

I have them on the home pc Razz.

Holavez
Back to top
View user's profile Send private message
Cyan Bloodbane



Joined: 25 Nov 2005
Posts: 23
Location: Somewhere in Italy

PostPosted: Thu Jan 29, 2009 21:13    Post subject: Source Code Reply with quote

Finally i found my sources.

NOTE : Comments are in italian

nwnx_admintool.cpp
Code:

// nwnx_admintool.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "NWNXAdminTool.h"

CNWNXAdminTool Admintool;

extern "C" __declspec(dllexport) CNWNXBase* GetClassObject()
{
   return &Admintool;
}

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
    return TRUE;
}




Code:

// NWNXAdminTool.cpp: implementation of the NWNXAdminTool class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "NWNXAdminTool.h"
#include <string>

using namespace std;

#define BAN_TYPE_NAME  0x0000
#define BAN_TYPE_KEY   0x0001
#define BAN_TYPE_IP    0x0002

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CNWNXAdminTool::CNWNXAdminTool()
{
}

CNWNXAdminTool::~CNWNXAdminTool()
{
   this->OnRelease();
}

HWND CNWNXAdminTool::f_get_nwserverHwnd(DWORD procID, char *wClass){
   // * Prima finestra in lista
   HWND hwServer = FindWindow((LPCTSTR)wClass, NULL);
       hwServer = GetWindow(hwServer, GW_HWNDFIRST);

   DWORD wProc;

   while( hwServer != NULL ){
      // * Ottiene id processo
      GetWindowThreadProcessId(hwServer, &wProc);

      // * Controlla il nome della finestra
      if( procID == wProc ){
         // * Confronta il nome
         string wName;
         char cwName[512];
         
         if( GetWindowText(hwServer, cwName, 512) == 0 ){
            // * Salta iterazione
            hwServer = GetWindow(hwServer, GW_HWNDNEXT);

            // * Exit
            continue;
         }

         wName = cwName;

         if( wName.find("NWServer") == 0 ){

            // * Interrompe il ciclo
            break;
         }
      }

      // * Prossima finestra
      hwServer = GetWindow(hwServer, GW_HWNDNEXT);
   }

   // * Exit
   return hwServer;
}

BOOL CNWNXAdminTool::f_kill_nwnserver(DWORD procID){
   BOOL bRet = FALSE;
   // * Handle del processo
   HANDLE hProc = ::OpenProcess(PROCESS_TERMINATE, FALSE, procID);

   if( hProc != NULL ){
      // * Delay 5 seconds
      Sleep(5000);
      // * Terminate Process
      bRet = TerminateProcess(hProc, 0);
   }

   CloseHandle(hProc);

   // * Exit
   return bRet;
}

BOOL CNWNXAdminTool::f_nwserver_setName(HWND hwServer, const char *szName){
   // * Controlla che la finestra sia valida
   if( hwServer == NULL ){
      // * Exit
      return FALSE;
   }

   // * Valore di ritorno
   BOOL bRet = FALSE;

   // * Contatore finestre
   unsigned int nWindows = 0;
   // * Prima finestra figlio in lista
   HWND hwFirst = GetWindow(hwServer, GW_CHILD);

   // * Scorre le finestre
   while( hwFirst != NULL ){
      // * Controlla l'indice della finestra
      if( nWindows == 5 ){
         // * Imposta il nome
         bRet = SetWindowText(hwFirst, (LPCTSTR)szName);

         // * Simula il click del mouse
         SendMessage(hwFirst, WM_KEYDOWN, 13, NULL);
         SendMessage(hwFirst, WM_KEYUP, 13, NULL);

         // * Esce dal ciclo
         break;
      }

      // * Incrementa il contatore
      nWindows++;
 
      // * Cambia l'handle
      hwServer = GetWindow(hwServer, GW_HWNDNEXT);
   }

   // * Exit
   return bRet;
}

BOOL CNWNXAdminTool::f_nwserver_setDMPass(HWND hwServer, const char *Password){
   // * If null window
   if( hwServer == NULL )
      // * Exit
      return FALSE;

   BOOL bRet = FALSE;

   unsigned int nWindows = 0;
   HWND hwFirst = GetWindow(hwServer, GW_CHILD);
       hwFirst = GetWindow(hwFirst, GW_HWNDFIRST);

   while( hwFirst != NULL ){
      if( nWindows == 0x24 ){
         bRet = SetWindowText(hwFirst, (LPCTSTR)Password);

         SendMessage(hwFirst, WM_KEYDOWN, 13, NULL);
         SendMessage(hwFirst, WM_KEYUP, 13, NULL);

         // * Esce dal ciclo
         break;
      }

      nWindows++;
 
      hwFirst = GetWindow(hwFirst, GW_HWNDNEXT);
   }

   // * Exit
   return bRet;
}

BOOL CNWNXAdminTool::f_nwserver_setPCPass(HWND hwServer, const char *Password){
   // * If null window
   if( hwServer == NULL )
      return FALSE;

   BOOL bRet = FALSE;

   unsigned int nWindows = 0;
   HWND hwFirst = GetWindow(hwServer, GW_CHILD);
       hwFirst = GetWindow(hwFirst, GW_HWNDFIRST);

   while( hwFirst != NULL ){
      if( nWindows == 0x20 ){
         bRet = SetWindowText(hwFirst, (LPCTSTR)Password);

         SendMessage(hwFirst, WM_KEYDOWN, 13, NULL);
         SendMessage(hwFirst, WM_KEYUP, 13, NULL);

         break;
      }

      nWindows++;
 
      hwFirst = GetWindow(hwFirst, GW_HWNDNEXT);
   }

   // * Exit
   return bRet;
}

BOOL CNWNXAdminTool::f_nwserver_sendMessage(HWND hwServer, const char *szMessage){
   // * If null window
   if( hwServer == NULL )
      // * Exit
      return FALSE;

   BOOL bRet = FALSE;

   unsigned int nWindows = 0;
   HWND hwFirst = GetWindow(hwServer, GW_CHILD);
       hwFirst = GetWindow(hwFirst, GW_HWNDFIRST);

   while( hwFirst != NULL ){
      if( nWindows == 45 ){
         bRet = SetWindowText(hwFirst, (LPCTSTR)szMessage);

         SendMessage(hwFirst, WM_KEYDOWN, 13, NULL);
         SendMessage(hwFirst, WM_KEYUP, 13, NULL);

         break;
      }

      nWindows++;
      hwFirst = GetWindow(hwFirst, GW_HWNDNEXT);
   }

   // * Exit
   return bRet;
}

BOOL CNWNXAdminTool::f_nwserver_banPlayer(HWND hwServer, const char *szName, int nBanType){
   if( hwServer == NULL )
      // * Exit
      return FALSE;

   BOOL bRet = FALSE;

   unsigned int nWindows = 0x0000;
   HWND hwFirst = GetWindow(hwServer, GW_CHILD);
       hwFirst = GetWindow(hwFirst, GW_HWNDFIRST);

   while( hwFirst != NULL ){
      if( nWindows == 0x30 ){
         long int nElement = SendMessage(hwFirst, LB_FINDSTRINGEXACT, -1, (LPARAM)(LPCTSTR)szName);

         if( nElement != LB_ERR ){
            long int nSel = SendMessage(hwFirst, LB_SETCURSEL, nElement, NULL);

            // * Ban Button
            unsigned int nBan_button, nBwin = nWindows;

            // * Ban Type
            switch ( nBanType ){
               case BAN_TYPE_NAME : nBan_button = 0x32; break;
               case BAN_TYPE_KEY  : nBan_button = 0x33; break;
               case BAN_TYPE_IP   : nBan_button = 0x34; break;
               default            : nBan_button = 0x32; break;
            }

            HWND hwButton = hwFirst;

            while( nBwin < 0x36 ){
               if( nBwin == nBan_button ){
                  SendMessage(hwButton, WM_LBUTTONDOWN, 0, 0);
                  SendMessage(hwButton, WM_LBUTTONUP, 0, 0);

                  bRet = TRUE;
                  break;
               }

               hwButton = GetWindow(hwButton, GW_HWNDNEXT);
               nBwin++;
            }
         }
         
         // * Exit while
         break;
      }
      nWindows++;
      hwFirst = GetWindow(hwFirst, GW_HWNDNEXT);
   }

   // * Exit
   return bRet;

}

char *CNWNXAdminTool::OnRequest(char *gameObject, char *Request, char *Parameters){
   HWND hwServer = this->f_get_nwserverHwnd(GetCurrentProcessId(), "Exo - BioWare Corp., (c) 1999 - Generic Blank Application");

   if( stricmp(Request, "RESTART") == 0 ){
      if( !this->f_kill_nwnserver(GetCurrentProcessId()) ){
         strncpy(Parameters, "NULL", strlen(Parameters));
      }
   }
   else if( stricmp(Request, "SETNAME") == 0 ){
      if( !this->f_nwserver_setName(hwServer, Parameters) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "SETDMPASSWORD") == 0 ){
      if( !this->f_nwserver_setDMPass(hwServer, Parameters) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "SETPCPASSWORD") == 0 ){
      if( !this->f_nwserver_setPCPass(hwServer, Parameters) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "SENDMESSAGE") == 0 ){
      if( !this->f_nwserver_sendMessage(hwServer, Parameters) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "BANUSERNAME") == 0 ){
      if( !this->f_nwserver_banPlayer(hwServer, Parameters, BAN_TYPE_NAME) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "BANUSERKEY") == 0 ){
      if( !this->f_nwserver_banPlayer(hwServer, Parameters, BAN_TYPE_KEY) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }
   else if( stricmp(Request, "BANUSERIP") == 0 ){
      if( !this->f_nwserver_banPlayer(hwServer, Parameters, BAN_TYPE_IP) )
         strncpy(Parameters, "0", strlen(Parameters));
      else
         strncpy(Parameters, "1", strlen(Parameters));
   }

   // * Exit
   return NULL;
}

BOOL CNWNXAdminTool::OnCreate(const char *LogFile){
   char log[MAX_PATH];
   sprintf (log, "%s\\nwnx_admintool.txt", LogFile);

   if(!CNWNXBase::OnCreate(log))
      return FALSE;

   return TRUE;
}

BOOL CNWNXAdminTool::OnRelease(){
   return CNWNXBase::OnRelease();
}



Holavez
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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