logo logo

Installing NWNX4

Here are some easy to follow instructions on how to get a basic NWNX4 setup with a SQLite database up and running.

1. Download NWNX4

You can download NWNX4 here: http://www.nwnx.org/index.php?id=nwnx4

Picture 47

Note: At the time of writing , NWNX Prototype 1.06 was current.

Download and save the ZIP file somewhere. Now create a new directory for NWNX4 on your harddisk, we will use


in this example installation. Extract the contents of the ZIP file to this directory.


2. What is inside the NWNX4 package

Picture 52

Here is a list of files that now should be in your NWNX4 directory, and a small description of what they are for:

Note: This tutorial only deals with the SQLite database option. We will therefore disable MySQL in the next step.


3. Configuring NWNX

Next, we need to do some file shuffling and messing up the configuration files.

3.1 Installation of NWNX4 files

First thing to do: Copy the file “MadCHook.dll” into the root directory of your NWN2 installation (where your nwn2server.exe file is). Make sure you copy the file, do not move it ! (picture 53)

Picture 53

3.2 Edit NWNX.INI file

The NWNX.INI contains descriptions for every setting, so these will not be explained in detail here. There is one setting which absolutely needs to be set, however:

# Path to NWN2 installation (where nwn2server.exe is located)
# no default. You really have to specify it, currently.
nwn2 = C:\Program Files\Atari\Neverwinter Nights 2

Replace "C:\Program Files\Atari\Neverwinter Nights 2" (the default location) with the root directory of NWN2 on your computer, e.g. "D:\Games\NWN2".

Since we will want to run the included NWNX4 demo module later on, we can as well set the module's name right now:

# Command line parameters to start the server with
# default: no parameters
parameters = -module NWNX4Demo 

Note: If your module name contains spaces, be sure to quote it like this: -module "My Very Long Module Name"


The SQLite plugin is the default database provider.

You can control which database plugin will be used by specifying the plugin class in the INI file:

# The function class that is provided by this plugin
class = SQL

Make sure that the class in xp_sqlite.ini is set to SQL and the class in xp_mysql.ini is set to SQLoff (or something else, doesn't matter). This is the default, so if you are working with the original files, everything should be peachy.

Now set the path where the internal SQLite database will store its data file:

# The database file that the SQLite engines stores its data in
file = C:\NWNX4\sqlite.db

If you are using the recommended installation path C:\NWNX4, you can leave this value as it is. The file size will depend on how much data you put into it, but generally, it will stay relatively small.

Save the file if you made any changes, and close your text editor.

3.4 Copy the demo modules

NWNX4 comes with three demo modules, which are a nice way of exploring NWNX , testing if the installation is working, and setting up basic data structures in new databases.

These modules are in the demo folder:

Copy all four files into your module folder, e.g. C:\Program Files\Atari\Neverwinter Nights 2\Modules.


4. Starting NWNX

Hold your breath, it's time to start NWNX and see how easy it was to set it up.

Double-click on NWNX4_GUI.exe in your NWNX4 installation directory, and the fun should begin.

4.1 The NWNX4 GUI

Although NWNX4 can be run from the command line, most people will want to start with the friendly GUI version. If you have set up everything correctly, a window like this will open:

Shortly after that, the dedicated NWN2 server window will come up. Make sure that the NWNX4Demo module was loaded succesfully. If the Module Name box stays empty, double check the path where you copied the demo modules into, and make sure you have set the parameter option in NWNX.INI like described above.

NWNX4 creates two different kinds of log files. The first, nwnx.txt, contains messages for the main program, which is loaded into nwn2server.exe. It should look like this:

NWN Extender 4 V.0.0.7
(c) 2007 by Ingmar Stieger (Papillon)
visit us at www.nwnx.org

* Loading plugins...
* Loading plugin xp_mysql.dll: Error during plugin initialization.
* Loading plugin xp_sqlite.dll: Successfully registered as class: SQL
* Loading plugin xp_time.dll: Successfully registered as class: TIME
* Disabling general protection fault error dialog.
* NWNX4 activated.

Note: The error during xp_mysql initialization is ok. During the creation of this tutorial, my MySQL server was not running, so the plugin could not connect to it. You will probably receive the same message. If you want to disable the plugin entirely, rename the DLL to something like disabled_xp_mysql.dll.

The other kind of log file is generated by each plugin individually, e.g. xp_sqlite.txt:

NWNX SQLite Plugin V.0.0.7
(c) 2007 by Ingmar Stieger (Papillon)
visit us at www.nwnx.org
(built using SQLite 3.3.11)

* Log level set to 2 (everything)
* SQLite database file is C:\NWNX4\sqlite.db
* Plugin initialized.
* Registering under function class SQL

Make sure you do not get any error messages (except the one mentioned above) in your log files.

5. Using the demo modules

Now we will check whether NWN2 and NWNX4 can communicate properly. The demo modules included in NWNX provide a great starting point, and we will try two of them in the next steps.

5.1 NWNX4Demo

Connect to your server using the NWN2 client, and you will enter the main demo module, NWNX4Demo. Here you will find a talkative, small dragon, and a couple of portals, some of them lit.

First, talk to the dragon. He will explain what this is all about. In short, each portal leads to another demo module. The portals are activated dynamically, depending on the installed plugins.

Next, click on the portal that leads to the SQLite demo module and answer "Yes" to proceed.

5.2 The SQLite demo module

The first thing when you enter this module for the first time, is that you get to meet a bald guy who tells you either...

  1. that SQLite has been configured and works fine, or
  2. that an error occured during the initialization.

If you get an error, you need to go through the earlier steps again and double check you have made no mistake along the way. If nothing else helps, please register on the NWNX forums and post your problem, and a sample of the log files mentioned above. People over there are really friendly and usually help you to solve the problem quickly.

Now pull the trigger "Pull me to save text to the database" and enter some text. Next, pull the other trigger to retrieve the text back from the database. It should come back exactly as you typed it. If nothing comes back, you will need to recheck your setup (see above).

Note: The other two triggers and their associated chests currently do nothing. Object storage functionality is not yet included in NWNX4 at the time of writing, so don't worry if those chests do not work.

If you received the text correctly, you have made it ! Congratulations on setting NWNX up.

The SQLite database has been created and is ready for action.

Now have a look at our forums to see what else is possible, and to find out what other plugins are available !