Account Switcher

Hints and Guidelines, How To's on Registration, Activation, NWN, etc.

Moderators: Active DMs, Forum Moderators

Post Reply
Bato
Posts: 3
Joined: Fri May 06, 2016 5:41 am

Account Switcher

Post by Bato » Sun May 22, 2016 1:58 am

A while ago I made a batch file that switches your NWN accounts out for you super easy-like. I am going to share this now.

Disclamer: Make a backup copy of your nwnplayer.ini player before using this.
Since it does a find and replace method, it might mess something up. Haven't had problems, but good to be safe.


Most people use a batch file to direct connect to their NWN servers. You can slot this into your current setup:

Code: Select all

:start
cls 
@echo off  
C: 
cd %~dp0
if not exist nwnvar.cmd (set expacc=blank
goto varset)
call nwnvar.cmd
echo.
echo Current Account: %preacc% 
echo. 
rem ^ Goes at the very start of the file. The rest can be put anywhere and called with "goto Account"

:Account 
cls 
echo. 
echo 1. blank
echo 0. Back 
set /p accvar= Account: 
	if %accvar% == 1 set expacc=blank

	if %accvar% == 0 goto start 
call :setaccount 
goto start
exit

:setaccount
setLocal EnableDelayedExpansion 
if exist nwnplayer.tmp del nwnplayer.tmp 
for /f "tokens=* delims= " %%a in (nwnplayer.ini) do ( 
set str=%%a 
set str=!str:%preacc%=%expacc%!
echo !str! >> nwnplayer.tmp
) 
del nwnplayer.ini
rename nwnplayer.tmp nwnplayer.ini 
call :varset
goto start
exit

:varset
(echo set preacc=%expacc%) > nwnvar.tmp
del nwnvar.cmd
rename nwnvar.tmp nwnvar.cmd
goto start
exit
Change the blank in both "if %accvar% == 1 set expacc=blank" and "echo 1. blank" to your account.
And to add more accounts you just add in "if %accvar% == 2 set expacc=wew" and a corresponding echo up above.

For anyone who doesn't use batch files right now, I made a cleaned up version of what I have should you like.
Set it in your nwn folder and set up a shortcut.

Code: Select all

:start
cls 
@echo off  
C: 
cd %~dp0
if not exist nwnvar.cmd (set expacc=blank
goto varset)
call nwnvar.cmd
echo.
echo Current Account: %preacc% 
echo. 
echo Select a Thing 
echo 1. Servers 
echo 2. Accounts 
echo 3. NWN 
echo 4. Toolset
echo 5. DMClient
echo 6. NWServer
set /p menu= What do: 
	if %menu% == 1 goto Menuserv
	if %menu% == 2 goto Account 
	if %menu% == 3 start nwmain.exe  
	if %menu% == 4 start nwtoolset.exe 
	if %menu% == 5 start nwmain.exe -dmc
	if %menu% == 6 start nwserver.exe
exit 


:Menuserv 
cls 
echo.
echo 1. Cordor
echo 2. Surface
echo 3. Fixed Level
echo.
set /p servervar= Server Number: 

	if %servervar% == 11 start nwmain.exe +connect 138.201.20.77:5123
	if %servervar% == 12 start nwmain.exe +connect 138.201.20.77:5124
	if %servervar% == 13 start nwmain.exe +connect 138.201.20.77:5126
exit 

:IPs
set /p ipvar= Enter the IP:
start nwmain.exe +connect %ipvar%
exit


:Account 
cls 
echo. 
echo 1. blank
echo 0. Back 				00. New Account
set /p accvar= Account: 
	if %accvar% == 1 set expacc=blank

	if %accvar% == 00 goto Names
	if %accvar% == 0 goto start 
call :setaccount 
goto start
exit

:Names
echo.
echo This will not be saved to your list of accounts.
set /p expacc= Enter the Account:
call :setaccount
goto start


:setaccount
setLocal EnableDelayedExpansion 
if exist nwnplayer.tmp del nwnplayer.tmp 
for /f "tokens=* delims= " %%a in (nwnplayer.ini) do ( 
set str=%%a 
set str=!str:%preacc%=%expacc%!
echo !str! >> nwnplayer.tmp
) 
del nwnplayer.ini
rename nwnplayer.tmp nwnplayer.ini 
call :varset
goto start
exit

:varset
(echo set preacc=%expacc%) > nwnvar.tmp
del nwnvar.cmd
rename nwnvar.tmp nwnvar.cmd
goto start
exit

User avatar
Tashalar
Posts: 664
Joined: Mon Sep 08, 2014 2:26 am
Location: At the Mountains of Madness (England)

Re: Account Switcher

Post by Tashalar » Sun May 22, 2016 12:39 pm

Is it possible to mix this batch file with the batch file for logging? A lot of people (myself included) use the .bat for the logger...
#2: Archmage Swift's Spellduel Rules
#3: "But I'm An Abjurer, I Can't Conjure!"
#4: This Spellbook Is Fire
#5: Think For Once, Archmage Amana
#6: Cor, What A Stunner
#8: Sigermane Special
#9: What Is This, Cordor In The Fifties?

User avatar
Kreydis
Posts: 422
Joined: Sun Dec 21, 2014 3:42 am

Re: Account Switcher

Post by Kreydis » Sun May 22, 2016 3:05 pm

If I'm reading it correctly, he provided instructions on what to edit in the batch. If you're looking for more a more detailed answer though I.E. Step by step, it might be helpful to the non code wizards that will look at this.

Edit:

Actually he did 1 + (except for people like me who have customized their Bat a bit.)

He added a whole new coding in the 2nd code box which will function as both the account switcher and as a server connector. So if you use the logger you'll just need to plug the code in before the function completes it's task and ends.
It's a Dwarf, no it's a Dragon, no it's a Halfling! I think.

Post Reply