Affordable Neverwinter Nights Hosting Contact Support
Server & Module Setup Guides
Terms & Conditions
Automating Server Restarts Using NWNx
Share this...


Depending on your module, how many items or monsters there are, if there encounters that don't reset, then you might wish your server to restart automatically on a set time schedule. This can be useful to do regardless of your server size. Restarting your server clears the cached files of the server, frees up memory and clears the logs. Simply put; leaving your server running for weeks at a time without restarting it is bad!

In this guide we'll explain how to implement an automatic server restart every few hours. With this your server will keep running smoothly and will remain lag free.

Things you will need

Neverwinter Nights Toolset
Basic Scripting Knowledge

The Process

First, you will need the nwnx_resetplugin.dll uploaded to your server's root directory. You can upload it through FTP. Click here for a quick FTP Upload Tutorial.

You can download the plugin here: Download NWNx_ResetPlugin.dll (RAR Archive,37KB)

Now we can start to integrate this plugin into your module.

Open up your module file in the Neverwinter Nights Toolset

Add the following somewhere in your OnModuleLoad

//------------------------------a_restart-----------------------------// 
void main() 

    DelayCommand(3600.0, SpeakString("! Server will reload in apx 5 hours !", TALKVOLUME_SHOUT )); 
    DelayCommand(7200.0, SpeakString("! Server will reload in apx 4 hours !", TALKVOLUME_SHOUT )); 
    DelayCommand(10800.0, SpeakString("! Server will reload in apx 3 hours !", TALKVOLUME_SHOUT )); 
    DelayCommand(14400.0, SpeakString("! Server will reload in apx 2 hours !", TALKVOLUME_SHOUT )); 
    DelayCommand(18000.0, SpeakString("! Server will reload in apx 1 hour !", TALKVOLUME_SHOUT )); 
    DelayCommand(19800.0, SpeakString("! Server will reload in apx 30 minutes !", TALKVOLUME_SHOUT )); 
    DelayCommand(20700.0, SpeakString("! Server will reload in apx 15 minutes !", TALKVOLUME_SHOUT )); 
    DelayCommand(21300.0, SpeakString("! Server will reload in apx 5 minutes !  Please find a safe spot to log off!!", TALKVOLUME_SHOUT )); 
    DelayCommand(21480.0, SpeakString("! Server will reload in apx 2 minutes ! Please find a safe spot to log off!!", TALKVOLUME_SHOUT )); 
    DelayCommand(21540.0, SpeakString("! Server will reload in apx 1 minute ! Please find a safe spot to log off!!", TALKVOLUME_SHOUT )); 

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

//------------------------------a_restart-----------------------------//


As you can see, this will restart your server every 6 hours (21600 seconds). You can alter this to however often you want. If you are not sure how to successfully implement this into your OnModuleLoad then there is an easier to follow tutorial: Manual NWN Server Restarts