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 
 
Batch File Request - Server Name

 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
BelowTheBelt



Joined: 28 Jul 2010
Posts: 29

PostPosted: Fri Jan 07, 2011 21:00    Post subject: Batch File Request - Server Name Reply with quote

Hey,

So I auto-reboot my server every six hours and use a small batch file that runs on startup to restart NWNX about 10 seconds after the reboot (I've read that this amount of time seems to be the "right" amount to give the server name the best chance of being recognized)

What I've seen is that it is unreliable to recognize and input the Server Name at any number of different time delay settings (10 seconds seems to be the minimum time required on my machine - if less, the server name is almost always missed). Sometimes the server name is there...sometimes not, resulting in an "unnamed" server in the server name slot in gamespy. Very annoying.

What I'd like your thoughts/help on is whether or not a batch file like the one I use to launch NWNX can be written to auto-write in the text of the server name as NWNX launches NWServer and the game is loading.

Below is the text of the batch file that i auto-run when the server starts up:

:: Insert delay of 10=11-1 seconds
ping -n 10 127.0.0.1 >NUL
start C:\NeverwinterNights\NWN\NWNX2.exe

What I'm envisioning is another batch file that could also fire at startup (possibly with a delay of 20 secs or so) that says...
1) Find the Server Name text field in NWServer
2) Input some text into that field...

Hey, if you wanted to get crazy with it, you could also make it set some of the settings allowable in NWServer or announce a text field in the Server Message field, but my specific need is to reliably make sure the Server Name gets put in.

I figured if anyone could create something like this, it was the brilliant minds who brought us the NWNX and the plugins.

What do you think?
Thanks!
_________________
www.arenthyor.com
Back to top
View user's profile Send private message Visit poster's website
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Jan 08, 2011 22:08    Post subject: this is do able via Reply with quote

this is doable via vb script using some of the windows api functions, or someone could make a function that works via nwnx to set the server name.


The latter would be the easiest choice.

I too use a reboot script, and have my server set to something like 30seconds delay before starting nwnx, which then starts nwn.

Note - nwn servers typically get the unnamed 'name' if there is alot of things going on at the same time.

Eg - other programs starting up.
Windows might be capable of running lots of programs concurrently, but nwn is starting up, if another program starts up at the same time, or takes the foreground, before the name is set, then nwn server wnt get the name set.

Try increasing your delay time, 10 seconds is a little too quick for a windows machine in my opinion.

Also - I think 6 hours is a bit too frequent for Server Machine reboots. Your server could likely go a day or two without needing a reboot.

I personally reboot the server machine once a week, and the nwnserver auto reboots every 72 hours.
Back to top
View user's profile Send private message
BelowTheBelt



Joined: 28 Jul 2010
Posts: 29

PostPosted: Tue Jan 11, 2011 23:39    Post subject: Reply with quote

Thanks for the reply, Baaleos.

I'll try increasing the delay time, but I was hoping someone could try the vb option, which could eliminate the need for a delay of anyt amount of time, which would allow NWNX to start immediately and thereby reduce the overall reboot time.

Would anyone be willing to give this a try? I know this "unnamed server" effect is something that many PWs have had to work around, so the value to the community would be pretty high.

Personally, I'd rather have an option that sits outside of NWN/NWNX so as to limit any additional overhead in the game (rather than a plugin), but I'd be willing to use anything that someone would be willing to create.

Thanks!
_________________
www.arenthyor.com
Back to top
View user's profile Send private message Visit poster's website
Q



Joined: 01 Aug 2009
Posts: 3

PostPosted: Wed Jan 12, 2011 5:43    Post subject: Reply with quote

You should be able to forcefully set the server name from the same batch file using the -servername parameter on NWNX2.exe (which is automatically passed to nwserver.exe). Depending on where you have placed the batch file, you may also want to specify the working directory. This will ensure that NWN loads files from its proper directory rather than the batch file's current directory or a system directory.

e.g:
Code:

:: Insert delay of 10=11-1 seconds
ping -n 10 127.0.0.1 >NUL
start /D C:\NeverwinterNights\NWN C:\NeverwinterNights\NWN\NWNX2.exe -servername "Your Server Name"

The /D switch there ensures that the program is launched from the correct directory. It may cause some problems if omitted.

Of course, you'd need to replace "Your Server Name" with..uh...your server name. If you needed to change server names, you'd need to update the batch file as well as the INI.

Better yet, just change it in the batch file; the INI setting will be completely ignored with this method, anyway.

I tested the code only briefly -- my NWN installation is in a different path and quite a bit more complicated -- but it should work the same way.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Page 1 of 1

 
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