Aller au contenu

Photo

How to delete a player character?


  • Veuillez vous connecter pour répondre
21 réponses à ce sujet

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Hello scripters, 

 

I would like to delete the character file from servervault scripting, do you know if thats possible?



#2
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages

I am not a scripter, but yes it is possible. We use an NPC with a convo. Here is the script. It deletes the bic, but not the bak.

 

void main()
{
  object oPC = GetPCSpeaker();
  string sAcc = GetPCPlayerName(oPC);
  ExportSingleCharacter(oPC);
  AssignCommand(oPC, SpeakString("Goodbye cruel world!", TALKVOLUME_SHOUT));

  UnregisterToon(oPC);
  BootPC(oPC);
  DelBic(NWNVAULTPATH + sAcc + "/");
}


  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I am not a scripter, but yes it is possible. We use an NPC with a convo. Here is the script. It deletes the bic, but not the bak.

 

void main()
{
  object oPC = GetPCSpeaker();
  string sAcc = GetPCPlayerName(oPC);
  ExportSingleCharacter(oPC);
  AssignCommand(oPC, SpeakString("Goodbye cruel world!", TALKVOLUME_SHOUT));

  UnregisterToon(oPC);
  BootPC(oPC);
  DelBic(NWNVAULTPATH + sAcc + "/");
}

 

 

Sorry I was not able to find DelBic() function... do you have a custom include?



#4
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages

Hmm... Hunting down the include within an include... not easy for me.

 

I am guessing leto, or nwnx_funcs from my digging.

 

The include we have, points to another include, each of which have multiple others.

 

Sorry I can't be more help, if I find the specific before you I will let you know.

 

Alternatively our mod is open source, so you are welcome to take a look, and see if you can find it for yourself to use.



#5
WhiteTiger

WhiteTiger
  • Members
  • 479 messages
Thank you helping me anyway.

Yes, I would love to have a look in your module, could you send me the download url please?

#6
Shadooow

Shadooow
  • Members
  • 4 470 messages

try this nwnx plugin


  • WhiteTiger aime ceci

#7
Kato -

Kato -
  • Members
  • 392 messages

Nwnx_files or nwnx_systemdata2. A quick example with the latter, probably not perfect but never failed so far:

 

#include "nwnx_systamdata2"
 
void DelPC(object oPC)
{
   ExportSingleCharacter(oPC);
   string sDir = "E:/NeverwinterNights/NWN/servervault/" + GetPCPlayerName(oPC)+"/";  // set the path as you need
   string sBic = NWNX_GetLatestUsedFile(sDir+"*.bic");
   SendMessageToPC(oPC, "You will be booted in 5 seconds in order to delete your character");
   DelayCommand(5.0, BootPC(oPC));
   DelayCommand(12.0, DeleteFile(sDir+sBic));
}
 
 
Kato


#8
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Is not working for me with nwnx_files

 

Am I doing something wrong? (the account name is 'teste')

 

void DeletingChar(object oPC)
{
    string sPath = "D:/NWN/Dedicated Server/servervault/teste/";
    string sBic = GetNewestBic(oPC);
    BootPC(oPC);
    int iCharBic = FileDeleteFile(sBic, sPath);
    if(iCharBic == TRUE) PrintString("[Training Area] Char deleted successfully ("+ GetName(oPC) +").");
    else PrintString("[Training Area] Char was not deleted.");
}
 
void main()
{
    object oPC = GetPCSpeaker();
    ExportSingleCharacter(oPC);
    DelayCommand(3.0, DeletingChar(oPC));
}


#9
Shadooow

Shadooow
  • Members
  • 4 470 messages

The above code is for nwnx_systemdata2 plugin, mine plugin has totally different functions and syntax. Look into nwnx_files include, what you need is a function to get newest bic file in vault of player's account and a function to delete file / copy file. I definitely suggest to create a new directory backup, copy it there and delete original. All doable from script.

 

Also look here.


  • WhiteTiger aime ceci

#10
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Thanks for reply Shadooow.

 

I got success creating a backup of the chars and deleting it in 'teste' account

 

void DeleteTestingChars()
{
    int iFire;
    string path = "servervault/teste";
    iFire = FileCreateDirectory("backup",path);
    string newpath = path+"/backup";
    string filter = "*.bic";
    string file = FileGetFirst(path,filter);
    while(file != "")
    {
        iFire = FileCopy(file,path,newpath,"",TRUE);
        iFire = FileDeleteFile(file,path);
        file = FileGetNext(path,filter);
    }
    filter = "*.bak";
    file = FileGetFirst(path,filter);
    while(file != "")
    {
        iFire = FileCopy(file,path,newpath,"",TRUE);
        iFire = FileDeleteFile(file,path);
        file = FileGetNext(path,filter);
    }
}
 
Thank you again!


#11
Shadooow

Shadooow
  • Members
  • 4 470 messages

Yes thats it. You can even use my plugin for renaming textures or portraits :)


  • WhiteTiger aime ceci

#12
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages

Thank you helping me anyway.

Yes, I would love to have a look in your module, could you send me the download url please?

 

Just to follow up, although looks like you got this sorted, our forums listed in my sig, explain how to get a copy of the module.



#13
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Oh, god! My server is crashing all the time I suspect the problem is nwnx_files! I have to remove it to see if that resolves the problem, I looked in the logs and found nothing.



#14
Kato -

Kato -
  • Members
  • 392 messages

Most likely a conflict with another plugin or ini setting. Personally I have used nwnx_files for quite some time in the past and it never crashed the server, if it may help.

 

 

Kato



#15
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

After adding 'ExportSingleCharacter' to the script oncliententer the server crash. It seems that is no longer server crashing after removing export single character from on client enter



#16
Shadooow

Shadooow
  • Members
  • 4 470 messages

After adding 'ExportSingleCharacter' to the script oncliententer the server crash. It seems that is no longer server crashing after removing export single character from on client enter

Thats really weird, NWNX_Files cant be reponsible for this it doesnt modify nwn memory in any way it doesnt work like other plugins and it cant make conflict with any other plugin its 100% safe due to the way it works.

 

It must be different plugin causing this, nwnx_events modifies ExportSingleCharacter so I would try that one, at any rate, you have two options.

1) don't use ExportSingleCharacter at OnClientEnter (btw for others: I suggest this to him as it makes searching for newest bic file in folder more reliable)

2) keep it there and then find which plugin it is by a "removal of the single plugin at the time" method, then if it will be nwnx_files or nwnx_patch causing this I can and I will offer support for this issue, if it will be nwnx_events the only solution would be probably to check if there isn't newer version (or switch to nwnx_cool completely)


  • WhiteTiger aime ceci

#17
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

The server is online since 6 hours ago and nothing happened. No more crash. This may have been a nwnx_events crisis or even caused by ExportSingleCharacter () that I deleted it from on client enter event

 

There was a few crashes and I dont know if it comes from nwnx_events or nwnx_patch or even nwnx_files

 

Right now is everything ok! Anymore crashes I post here and thanks for support Shadooow and Kato



#18
Knight_Shield

Knight_Shield
  • Members
  • 444 messages

I haven't been able to keep a server up using nwnx .Probably just me. There is a way to delete without out the use of nwnx..It is not instant but it does work.



#19
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I hate when the server crashes. It is necessary someone manually restart the server, because the windows do not let the nwnx do (the program stopped responding and need  someone to click close program). There is a week with the online server and we got three crashes.This is the standard amount of crashes per week that we had before the nwnx_files, so I guess the problem is not nwnx_files. I would like no more crash per week and one per month. That's what I wish most. 

 

Our server is subscribed on http://www.nwnlist.com/ and you can acess our site http://www.amnesia-nwn.info/ meeting Amnésia :) (new english version)



#20
Shadooow

Shadooow
  • Members
  • 4 470 messages

I hate when the server crashes. It is necessary someone manually restart the server, because the windows do not let the nwnx do (the program stopped responding and need  someone to click close program). There is a week with the online server and we got three crashes.This is the standard amount of crashes per week that we had before the nwnx_files, so I guess the problem is not nwnx_files. I would like no more crash per week and one per month. That's what I wish most. 

 

Our server is subscribed on http://www.nwnlist.com/ and you can acess our site http://www.amnesia-nwn.info/ meeting Amnésia :) (new english version)

Backup logs in NWN/logs.0/ everytime server crashes, also enable these options in nwnplayer.ini

 

Death Logging=1

Enable Profiling=1
Enable Logging=1

 

And then send me one you gather from 3 crashes.

 

Alternatively, try disable my nwnx_patch plugin (delete or rename to _nwnx_patch) for some time. If crashes disappear its caused by it. I will definitely add some debugging into next version.

 

 

Anyway. I know there is a way to disable those error messages. I dont remember how and it might be different over XP/7/8 (I was hosting on XPs always), but it should be possible. Maybe someone else knows?


  • WhiteTiger aime ceci

#21
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Great! I already have activated all three logs options. Once we have crashes on my Persistent World I will create backups. 



#22
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Backup logs in NWN/logs.0/ everytime server crashes, also enable these options in nwnplayer.ini
 
Death Logging=1
Enable Profiling=1
Enable Logging=1
 
And then send me one you gather from 3 crashes.

 
The server crashed today. Will send you the logs