Author Topic: How to delete a player character?  (Read 921 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« on: January 30, 2015, 04:10:58 pm »


               

Hello scripters, 


 


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



               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
How to delete a player character?
« Reply #1 on: January 30, 2015, 05:43:21 pm »


               

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 + "/");

}



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #2 on: January 30, 2015, 05:59:51 pm »


               


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?


               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
How to delete a player character?
« Reply #3 on: January 31, 2015, 02:07:17 am »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #4 on: January 31, 2015, 02:54:01 am »


               Thank you helping me anyway.


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

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to delete a player character?
« Reply #5 on: January 31, 2015, 02:35:42 pm »


               

try this nwnx plugin



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
How to delete a player character?
« Reply #6 on: January 31, 2015, 04:45:13 pm »


               

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


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #7 on: January 31, 2015, 08:50:30 pm »


               

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));

}


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to delete a player character?
« Reply #8 on: January 31, 2015, 09:08:13 pm »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #9 on: January 31, 2015, 09:59:28 pm »


               

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!


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to delete a player character?
« Reply #10 on: January 31, 2015, 10:39:55 pm »


               

Yes thats it. You can even use my plugin for renaming textures or portraits '<img'>



               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
How to delete a player character?
« Reply #11 on: February 01, 2015, 04:32:51 pm »


               


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.


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #12 on: February 01, 2015, 06:14:10 pm »


               

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.



               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
How to delete a player character?
« Reply #13 on: February 01, 2015, 07:01:36 pm »


               

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



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to delete a player character?
« Reply #14 on: February 01, 2015, 07:50:52 pm »


               

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