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 
 
Character deletion plugin
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Thu Jan 20, 2005 7:30    Post subject: Character deletion plugin Reply with quote

I put together my own plugin for nwnx2 to delete character files. If you want to take a look and/or give some feedback you can grab the .zip here:
http://home.comcast.net/~xildjian/Deletechar.zip

The plugin looks for the most recent file written to in a players directory. If you export the single character file and then boot the player before calling the script it works pretty well. After the plugin finds the most recent file written it verifys the character name in the file with the one passed to the plugin from nwn. I provided the following options through an ini file.
Ability to log or not log
Ability to move or delete the the character file
Ability to specify the location of the server vault and move to directory, deletevault as I call it, that mirrors the servervault structure.

Any feedback would be appreciated as I'm not much of a windows programmer, and spent most of the time browsing through the MSDN web pages.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
Den_CarpeTerra



Joined: 11 Feb 2005
Posts: 9

PostPosted: Fri Feb 11, 2005 6:24    Post subject: Reply with quote

Couldn't sleep so tested it tonight... Wink

The Delete mode works perfectly. I created a number of character bics with the same long name but a different endings so that there is no correlation between the chaacter name and the bic name (other than the order of creation). Worked perfectly everytime...

The MoveTo mode didn't work for me at all.

I made a few minor adjustments to your script for testing. Feel free to incorporate or not.

Code:
// wrapper for deleting character file from the server vault
void removeCharBIC(object oPC);

void removeCharBIC(object oPC) {
    object oMod = GetModule();
    string sPlayerName = GetPCPlayerName(oPC),
           sCharName = GetName(oPC);
    if (!GetIsPC(oPC)) return;
    ExportSingleCharacter(oPC);
    BootPC(oPC);
    if (GetStringLength(sPlayerName) < 1) return;
    AssignCommand(oMod, DelayCommand(0.2, SetLocalString(oMod, "NWNX!DELETECHAR!DELETE", sPlayerName + "?" + sCharName)));
Back to top
View user's profile Send private message Visit poster's website
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Fri Feb 18, 2005 19:21    Post subject: Reply with quote

Den_CarpeTerra wrote:
The MoveTo mode didn't work for me at all.


How did it not work for you? Did you create the top level moveTo directory before hand? example \nwn\deletevault

The code is setup to only create the player name directory below the moveTo directory. It will not create the toplevel moveTo directory.

Thanks for playing with this. Sorry, I just noticed your post. I reinstalled my system, and have been (still am) trying to find out why NWN keeps crashing my system within 15 minutes of game play.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
princewally



Joined: 29 Dec 2004
Posts: 9

PostPosted: Tue Feb 22, 2005 16:12    Post subject: Reply with quote

Feedback:

I love it, my players love it. I do have 1 suggestion/request, though. If you don't set the NWNX.ini serverpath, this will crash the server. I'd suggest a two part fix.

First, maybe a default server path in the dll. If the path isn't found in nwnx.ini, or the ini doesn't exist, attempt to use .\servervault.

Second, trap the error to avoid the crash. Deal with the error, write it to the log file, and move on.

I could make the change for the first part, myself, but I have no clue on errortrapping here. I haven't taught myself c, yet.
Back to top
View user's profile Send private message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Tue Feb 22, 2005 17:48    Post subject: Reply with quote

princewally wrote:
Feedback:

I love it, my players love it. I do have 1 suggestion/request, though. If you don't set the NWNX.ini serverpath, this will crash the server. I'd suggest a two part fix.

First, maybe a default server path in the dll. If the path isn't found in nwnx.ini, or the ini doesn't exist, attempt to use .\servervault.

Second, trap the error to avoid the crash. Deal with the error, write it to the log file, and move on.

I could make the change for the first part, myself, but I have no clue on errortrapping here. I haven't taught myself c, yet.


Nice thanks for the feedback!
Sure, I can add defaults for the paths.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
Lanthar D'Alton



Joined: 10 Feb 2005
Posts: 100

PostPosted: Wed Feb 23, 2005 1:31    Post subject: code Reply with quote

code for that... just because I have it easily at hand...

Code:

char inifile[MAX_PATH+64];
_getcwd(inifile, MAX_PATH+64);
strcat(inifile, "\\filename.ini");


okay, so really that's just some code I use to figure out where my dll's ini file should be, but it gets the current working directory... so I thought I'd slap it in here in case you looked before trying to remember the function name to do that... Smile

I left a hook in my nwscript files for the speech system for a speech command that calls an external character deletion command, half because I have my own function to do it (mostly successful), and half because I figured people would want to take advantage of this one (probably more successful). Smile

-Lanthar
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Wed Feb 23, 2005 5:49    Post subject: Reply with quote

Actually I'm just going to add it to the default for the GetPrivateProfileString command. Right now I have it set to "Not Found" if it can't find an entry in the .ini file. I thought that might be more useful for trouble shooting since you would know right away something wasn't set up correctly instead of setting default directories.

Ok, I updated the modules with default paths

http://home.comcast.net/~xildjian/Wings.zip
http://home.comcast.net/~xildjian/Deletechar.zip

I also added a default path to the wings plugin I did.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
Den_CarpeTerra



Joined: 11 Feb 2005
Posts: 9

PostPosted: Fri Feb 25, 2005 21:21    Post subject: Reply with quote

Xildjian wrote:
Den_CarpeTerra wrote:
The MoveTo mode didn't work for me at all.


How did it not work for you? Did you create the top level moveTo directory before hand? example \nwn\deletevault

The code is setup to only create the player name directory below the moveTo directory. It will not create the toplevel moveTo directory.


Yes, I created the top level directory. NWN is installed on a different drive from WIN if that matters. The logs report that it has moved the BIC, but there is no new player directory created and the BIC file is not moved.

No big deal, I prefer the outright delete mode anyways. Smile
Back to top
View user's profile Send private message Visit poster's website
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Sat Feb 26, 2005 2:10    Post subject: Reply with quote

Den_CarpeTerra wrote:
Yes, I created the top level directory. NWN is installed on a different drive from WIN if that matters. The logs report that it has moved the BIC, but there is no new player directory created and the BIC file is not moved.

No big deal, I prefer the outright delete mode anyways. Smile


Here is the MSDN web page. Might want to check it out and see if you are causing the MoveFile function to fail. Looks like the only way to make it fail is if you excede the character limit for the path or try to move the file across a volume. I have not see an error in any of my tests, it's worked as expected.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/movefile.asp
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
JeroenB



Joined: 31 Dec 2004
Posts: 228
Location: Netherlands

PostPosted: Sat Feb 26, 2005 11:06    Post subject: Reply with quote

I see you don't use the default CIniFile class. Do you have a reason for not using it? Using that class you don't have to figure out the complete directory anymore, plus the interface functions are much easier to use.

Also, for moving/copying files the Shell functions are a better tool than the MoveFile function.

Further the plugin looks nice Smile
Back to top
View user's profile Send private message Visit poster's website
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Sat Feb 26, 2005 19:08    Post subject: Reply with quote

JeroenB wrote:
I see you don't use the default CIniFile class. Do you have a reason for not using it? Using that class you don't have to figure out the complete directory anymore, plus the interface functions are much easier to use.

Also, for moving/copying files the Shell functions are a better tool than the MoveFile function.

Further the plugin looks nice Smile


Thanks!

The only reason for not using the CInitFile class is it was added with the v2.6.1 release of NWNX2, and I had started doing the plugin with v2.5.1. Altho, I did reference it because I originally thought it was a windows thing. I spend most of my time programming embedded systems and matlab so I'm not familiar with all these windows things.

What shell tools? The only reason for using MoveFile is that is what popped up when I did a search for file moving at the MSDN web site.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
JeroenB



Joined: 31 Dec 2004
Posts: 228
Location: Netherlands

PostPosted: Sun Feb 27, 2005 10:45    Post subject: Reply with quote

It's no problem using MoveFile, and forget about the shell functions Smile

I just looked in the MSDN documentation about MoveFile, and saw that you can move a file with MoveFile to another drive as long as the directory existed, so that was my thinking error Embarassed
Back to top
View user's profile Send private message Visit poster's website
Trimme



Joined: 05 Nov 2005
Posts: 11

PostPosted: Sat Nov 05, 2005 4:33    Post subject: Reply with quote

Can anyone post a script here,
that can be used to set in a NPC´s conversation
because the include i dunno how to use.. Crying or Very sad
Back to top
View user's profile Send private message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Tue Nov 08, 2005 20:15    Post subject: Reply with quote

Trimme wrote:
Can anyone post a script here,
that can be used to set in a NPC´s conversation
because the include i dunno how to use.. Crying or Very sad


Not sure I understand the question.
Can you give a little more detail.
Thanks
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
Trimme



Joined: 05 Nov 2005
Posts: 11

PostPosted: Sat Nov 12, 2005 16:37    Post subject: Reply with quote

the erf. only have a include script.
so what im looking for is a script that uses the include
and the script i wanna put into a conversation, on a npc
then you can go to the npc and ask him to delete your char.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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