[Release]Fixed Delete Character

10/03/2010 23:15 ryuchetval#1
Ok. As title says here's a fixed delete character (I used the one that didn't allow you to remake the character and made it so that you can make another character) (5165)

go to Database.cs and search for
Code:
        public static void Dispose()
above / under that void put this
Code:
 public static void DeleteCharacter(string Charname, string AccName)
        {
            if (File.Exists(@"C:\OldCODB\Users\Characters\" + Charname + ".chr"))
                File.Delete(@"C:\OldCODB\Users\Characters\" + Charname + ".chr");
            if (File.Exists(@"C:\OldCODB\Users\" + AccName + ".usr"))
            {
                FileStream FS = new FileStream(@"C:\OldCODB\Users\" + AccName + ".usr", FileMode.Open);
                BinaryReader BR = new BinaryReader(FS);
                string RealPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                string status = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                BR.Close();
                FS.Close();
                File.Delete(@"C:\OldCODB\Users\" + AccName + ".usr");
                FS = new FileStream(@"C:\OldCODB\Users\" + AccName + ".usr", FileMode.CreateNew);
                BinaryWriter BW = new BinaryWriter(FS);
                BW.Write(RealPassword);
                BW.Write(status);
                BW.Close();
                FS.Close();
            }
            
        }
go to PacketHandler.cs and search for
Code:
                                    case 99:
under / above that put this :
Code:
                                    case 95: //Delete Character
                                        {
                                            GC.Disconnect();
                                            Database.DeleteCharacter(GC.MyChar.Name, GC.AuthInfo.Account);
                                            break;
                                        }
+Thanks to me :)
10/03/2010 23:53 _Vodka#2
Nice, but I guess this should have been posted in the release section (:

so #reported to request move
10/04/2010 11:48 12tails#3
you forgot to make it read the Pasword data.... but nice ^^
10/04/2010 11:51 ryuchetval#4
Quote:
Originally Posted by 12tails View Post
you forgot to make it read the Pasword data.... but nice ^^
what do you mean?
it reads it....and you can't delete the character if your not logged in :)
10/04/2010 15:32 pro4never#5
Quote:
Originally Posted by ryuchetval View Post
what do you mean?
it reads it....and you can't delete the character if your not logged in :)
he means warehouse password: Aka what you have to enter when deleting the character.
10/04/2010 16:21 ryuchetval#6
yes well that idk about that...i'm still a begginer at coding


EDIT: here is a possible solution (didn't test)

go to NPCDialog.cs and searc for
Code:
static string ReadString(byte[] Data)
make it
Code:
        public static string ReadString(byte[] Data)
then at packethandler.cs at case 95 put this
Code:
                                            string pass = PacketHandling.NPCDialog.ReadString(Data);
                                            if (pass == GC.MyChar.WHPassword)
                                            {
                                                GC.Disconnect();
                                                Database.DeleteCharacter(GC.MyChar.Name, GC.AuthInfo.Account);
                                            }
                                            else
                                                GC.LocalMessage(2005, "Wrong password!");
I didn't test it so idk if it works
10/04/2010 17:39 _DreadNought_#7
uh why are u removing the account? It's a delete character :p
10/04/2010 20:34 ryuchetval#8
couldn't make it replace the character with "" (as the client crashed) so i removed the acc and remade it
10/04/2010 20:39 _Vodka#9
just disconnect, then delete file.
10/04/2010 20:50 ryuchetval#10
if you just delete the character file then you wouldn't be able to login
the info in the account files is pass, status, character and character file is missing
by writing into the account file pass, status, "" it crashed the client idk why...as in the authenticate place if the character is "" it would take you to make a new character....but it crashes the client
10/04/2010 21:29 _Vodka#11
I meant.
Quote:
1. find wich char to delete + get info
2. disconnect
3. delete char + account file
4. create new acc
10/05/2010 01:26 copz1337#12
I released something similar to this but this one is more advanced I guess because it disconnects the character lol.
10/05/2010 03:15 Arcо#13
Quote:
Originally Posted by copz1337 View Post
I released something similar to this but this one is more advanced I guess because it disconnects the character lol.
Yours didn't work :p
It deleted the character file, but inside the account file, the character still existed.
10/05/2010 03:23 copz1337#14
Quote:
Originally Posted by Аrco View Post
Yours didn't work :p
It deleted the character file, but inside the account file, the character still existed.
And that is why I had also had an ACCOUNT cmd. So lol?
10/05/2010 06:39 ryuchetval#15
this is useful for a public server not a server where you play by yourself and can make easily an account for you...