Example : You want to create an account with the username "Peter".
Then you do:
Quote:
NEWPeter
Okay, hope you know what I mean. As some of you know, I encourage people to go INI for accounts/characters instead of MySQL, so this is for INI files, just so you know, but its easy to convert to MySQL.
So first, we go to the place in your source (Probably LOTF) where it all happens, Authenticate.
To get there, search for :
Quote:
public static byte Authenticate(string UserName, string Password)
Now, find a good spot to put this funcion in. Found it? Okay, good!
First we have to make a check to see if the username starts with "NEW".
Okay, now this is REALLY fimiluar with the english spelling. We do this :
Now, we have to make it remove the actual "NEW". We can do that by this:Quote:
if (UserName.StartsWith("NEW"))
{
The reason why we put 0, 3 , is because 0 is for the start of the name, and 3 is for the amount of letters we are going to remove. NEW is 3 letters, therefore we put a 3.Quote:
string RealUserName = UserName.Remove(0, 3);
Now, we'll have to make a check if the accountname already exist. As I said earlier, I use INI, so you'll have to convert this to MySQL ( Not that hard really.. )
Quote:
if (!File.Exists(StartupPath + "Accounts\\" + RealUserName + ".acc"))
{
Okay, so that checks if an file with the current username exist. Hopefully it doesnt.
Now its time for all the easy job, write a line to an INI. Not many people know how to do this, so I will guide you through.
First we have to create a new INI, with the name of the username. We do that like this:
Now, lets write the password, status, logtype and character lines.Quote:
IniFile I = new IniFile(StartupPath + "Accounts\\" + RealUserName + ".acc");
Quote:
I.IniWriteValue("UserName", "Password", "");
I.IniWriteValue("UserName", "Status", "");
I.IniWriteValue("UserName", "LogType", "2");
I.IniWriteValue("UserName", "Character", "");
}
}
The "" or "2" after the , is the default value for each line.
So,I hope I have taught you something new today. Have a good weekend and goodluck!
Emme






