View previous topic :: View next topic |
Author |
Message |
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Mon Aug 11, 2008 1:30 Post subject: xp_srvadmin - script functions for ban/boot/shutdown/etc |
|
|
xp_srvadmin is an NWNX4 plugin that exposes the various options and functions contained on the server admin console GUI to the nwscript environment.
Current xp_srvadmin version: 0.0.4 for any NWN2 version (with NWNX hook support, i.e. all recent patch levels).
Release (0.0.4) Binaries: http://www.nynaeve.net/Skywing/nwn2/xp_srvadmin_004.zip (Temporary note: ERF not included due to toolset disagreeability; just copy and paste the .nss for now.)
Previous Release (0.0.3) Binaries: http://www.nynaeve.net/Skywing/nwn2/xp_srvadmin.zip
Previous Release (0.0.3) Source + binaries + symbols: http://www.nynaeve.net/Skywing/nwn2/xp_srvadmin_dist.zip
Future source releases: Available at virusman's NWNX4 repository (SVN http://nwn.virusman.ru/svn).
The Visual C++ 2005 SP1 x86 runtimes are required. You can download these here: http://www.microsoft.com/downloads/details.aspx?familyid=200b2fd9-ae1a-4a14-984d-389c36f85647&displaylang=en
Admin function usage is logged to the xp_srvadmin.txt log file. (You may want to add your own logging for a more complete audit trail.)
Change history:
0.0.4: Added SetPlayerPassword, SetDMPassword, SetAdminPassword (controls various server passwords).
0.0.3: Added ShutdownNwn2server.
0.0.2: First public release.
barfubaz has graciously contributed a nice demo module that shows one possible way to use xp_srvadmin (to create a DM control wand to access the admin GUI functions remotely in-game), which I have reposted here:
http://www.nynaeve.net/Skywing/nwn2/server_admin_demo.rar
This admin demo doesn't include the new functions added after version 0.0.3, so please copy the script wrappers from the zip and not the demo rar if you need the new functions.
nwscript functions added by this plugin are as listed below (these functions are expected to be future-compatible with new NWN2 versions without needing a new xp_srvadmin.dll module):
Code: | //
// **** New in 0.0.4 *****
//
//
// Set the player password required to join the server. Setting an empty
// password string disables the password requirement. This functions as
// changing the password via the server GUI and isn't persisted across
// restarts.
//
void SetPlayerPassword(string sPlayerPassword);
//
// Set the DM password required to join the server as a DM. Setting an
// empty password string disables the password requirement. This
// functions as changing the password via the server GUI and isn't
// persisted across restarts.
//
void SetDMPassword(string sDMPassword);
//
// Set the admin password required to use the server admin console.
// Setting an empty password string disables the server admin console.
// This functions as changing the password via the server GUI and isn't
// persisted across restarts.
//
void SetAdminPassword(string sAdminPassword);
//
// **** New in 0.0.3 ****
//
//
// Shutdown the server gracefully. The function returns to the scripting
// environment but the server will terminate gracefully (saving all characters) a
// short time after. Note that if you are using the NWNX watchdog functions, the
// server process may be automagically restarted by NWNX.
//
void ShutdownNwn2server();
//
// ** Present in all release versions **
//
//
// Send a broadcast server message, as per the administrative console input box.
//
void BroadcastServerMessage(string sServerMessage);
//
// Boot a player.
//
void BootPlayer(string sAccountName);
//
// Ban a player's account name. The player must be logged in.
//
void BanPlayerName(string sAccountName);
//
// Ban a player's IP address. The player must be logged in. You must supply the
// account name and not the IP address.
//
void BanPlayerIP(string sAccountName);
//
// Ban a player's CD-Key. The player must be logged in. You must supply the
// account name and not the CD-Key.
//
void BanPlayerCDKey(string sAccountName);
//
// Set the ELC state on the fly, as per the administrative console check box.
//
void SetELC(int nELCEnabled);
|
Note that there is no way to unban a player without shutting down the server after editing the .ini file right now. Also, these functions can boot/ban DM-privileged players, so if you want to prevent that, you should check for that in your script usage.
The shutdown server function provided by xp_srvadmin will save all server-side characters and disconnect all players gracefully, unlike a hard server process kill. This would typically be used to reboot the server cleanly, in conjuction with the NWNX watchdog (which would start the game server back up afterwards).
Like the administrative ban controls in the GUI, the ban functions do not implicitly disconnect a player, you need to call BootPlayer to do that if you would like that functionality. (Also, like the administrative ban controls in the GUI, the ban functions will only work on a player that is already logged in.)
Last edited by Skywing on Mon Jul 27, 2009 5:28; edited 8 times in total |
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Mon Aug 11, 2008 3:45 Post subject: |
|
|
Nice, i can finally simply reboot my servers from ingame.
Trying out! |
|
Back to top |
|
|
brockfanning
Joined: 01 Sep 2007 Posts: 15
|
Posted: Mon Sep 08, 2008 22:14 Post subject: |
|
|
First off, thanks for doing this!
IF there are plans for additions to this plugin, I'd have one request that would help our PW a lot: the ability to change the Player Password and/or the DM Password via Script. This would help PWs have "Free for All" days where anyone can log on, and/or "DM Recruiting" days where anyone can log on as a DM.
Also I could use some help getting the shut-down function to work. Our server runs in Windows XP, as a "service". I've got the plug-in in the game directory. However, when I call the shut-down function from script in-game, nothing happens. Is there any log-file I should look at, so I could provide more specific info? |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Tue Sep 09, 2008 1:55 Post subject: |
|
|
Those are probably doable, as long as you can edit those settings from the server GUI.
The shutdown server option ought to work, hrm. There is an xp_srvadmin.txt log file, do you not see anything at all in it when you call the shutdown function?
(The log should be in the same directory as all of the other NWNX plugin log files.)
And, btw, as a random aside, pleasantly surprised to hear that someone else made the Right Choice(tm) and used service mode. |
|
Back to top |
|
|
Undertowe
Joined: 03 Jan 2005 Posts: 33
|
Posted: Tue Sep 09, 2008 4:08 Post subject: |
|
|
If you wouldn't mind explaining, what is the advantage of running the server application as a service? I've never really understood the value of it, but I certainly don't know everything.
Also, wouldn't running as a service prevent you from changing settings on-the-fly via the GUI? |
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Mon Jul 20, 2009 19:02 Post subject: |
|
|
Hello Skywing, reboot server doesn't work with the 1.23 patch
Also could it be possible to set & unset server password ? |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Wed Jul 22, 2009 4:00 Post subject: |
|
|
PNJ wrote: | Hello Skywing, reboot server doesn't work with the 1.23 patch
Also could it be possible to set & unset server password ? |
That is unfortunate. Bet the control IDs changed. I will have to take a look.
If changing the server password works properly through the server admin GUI, then it's probably doable. |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Thu Jul 23, 2009 0:09 Post subject: |
|
|
Control IDs look the same. Do any other xp_srvadmin functions work? What's the xp_srvadmin.txt log file say?
Does there appear to be any visible effect on the GUI when you call ShutdownNwn2Server( ) ? |
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Thu Jul 23, 2009 22:30 Post subject: |
|
|
There isnt any effect on the server GUID when calling the shutdown function
the log say me that the restart seem to work properly :
xp_srvadmin.txt
17:02:45: * Plugin initialized.
But there is no message of reboot in the log
It's doesnt work since the 1.23 beta patch |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Fri Jul 24, 2009 4:39 Post subject: |
|
|
That doesn't look like the script function is really being called. Are you certain that there's nothing that has happened to the ShutdownNwn2server script wrapper in your module?
There should always be a "* Shutting down nwn2server..." line in the xp_srvadmin.txt log if the shutdown API is called by script:
Code: | if (function == wxT("SHUTDOWNNWN2SERVER"))
{
wxLogMessage( wxT( "* Shutting down nwn2server..." ) );
ShutdownNwn2server();
} |
|
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Fri Jul 24, 2009 19:49 Post subject: |
|
|
Well i didn't touch my scripts running it, i just noticed since we switch to 1.23 Beta, then 1.23, the Leto plugin and ServerAdmin function wasn't called anymore. I didn't touche NWNX version since 1.22 1.23 beta or 1.23
It could be an error with NWNXSetString command ?
Code: | NWNXSetString( "SRVADMIN", "SHUTDOWNNWN2SERVER", "", 0, "" ); |
|
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Fri Jul 24, 2009 20:21 Post subject: |
|
|
Can you post the contents of your nwnx.txt log file? |
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Fri Jul 24, 2009 21:22 Post subject: |
|
|
Quote: | NWN Extender 4 V.1.1.0-dev44
(c) 2008 by Ingmar Stieger (Papillon)
visit us at http://www.nwnx.org
* Loading plugins...
* Loading plugin xp_bugfix.dll: Successfully registered as class: BUGF
* Loading plugin xp_character.dll: Successfully registered as class: CHARACTER
* Loading plugin xp_chat.dll: Successfully registered as class: CHAT
* Loading plugin xp_clock.dll: Successfully registered as class: CLOCK
* Loading plugin xp_craft.dll: Successfully registered as class: CRAFTER
* Loading plugin xp_leto.dll: Successfully registered as class: LETO
* Loading plugin xp_mysql.dll: Successfully registered as class: SQL
* Loading plugin xp_srvadmin.dll: Successfully registered as class: SRVADMIN
* Loading plugin xp_time.dll: Successfully registered as class: TIME
* General protection fault error dialog disabled.
* NWNX4 activated.
|
I'm using a modified extender to enable old plugin based on local string. May it be? |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Sat Jul 25, 2009 1:20 Post subject: |
|
|
Depends on whether the new-style plugin interface still works properly. Can you try with the standard NWNX hook module first and make sure that it works?
Also, can you verify that NWNXSetString is really going to the NWN2 NWNXSetString and not being turned into a SetLocalString-style call?
If things work with the standard NWNX hook module, I would suspect that your problem is there.
From what I can see here, xp_srvadmin just isn't getting called at all, so I would focus troubleshooting on why that might be the case. (script wrappers and core NWNX hook module) |
|
Back to top |
|
|
PNJ
Joined: 30 Jun 2007 Posts: 67
|
Posted: Sat Jul 25, 2009 11:20 Post subject: |
|
|
I just check my wrapper, they are running fine (writetimelog) but yes, the plugins doesn't seem to catch the function.
It'is strange because the XP_craft plugin, is working fine.
I tryed using the original hook.dll, the Leto plugin then doesn't load, but the ServerAdmin plugin doesn't get the command better.
Quote: |
NWN Extender 4 V.1.0.9
(c) 2008 by Ingmar Stieger (Papillon)
visit us at http://www.nwnx.org
* Loading plugins...
* Loading plugin xp_bugfix.dll: Successfully registered as class: BUGF
* Loading plugin xp_character.dll: Successfully registered as class: CHARACTER
* Loading plugin xp_chat.dll: Successfully registered as class: CHAT
* Loading plugin xp_clock.dll: Successfully registered as class: CLOCK
* Loading plugin xp_craft.dll: Successfully registered as class: CRAFTER
* Loading plugin xp_leto.dll: Error. The plugin is not compatible with this version of NWNX.
* Loading plugin xp_mysql.dll: Successfully registered as class: SQL
* Loading plugin xp_srvadmin.dll: Successfully registered as class: SRVADMIN
* Loading plugin xp_time.dll: Successfully registered as class: TIME
* General protection fault error dialog disabled.
* NWNX4 activated.
|
|
|
Back to top |
|
|
|