[Release] Extremely basic (but working/bugless) C# Source

05/13/2009 16:39 taushif#106
Thnx for the reply xD

Quote:
public static void SaveProf(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Profs\" + Client.Username + ".ini");

sbyte i = 0;
foreach (ISkill Prof in Client.Profs)
{
wrtr.Write("Proficiencys", "Prof[" + i.ToString() + "]", Prof.ToString());
i++;
}
wrtr.Write("Proficiencys", "Count", i.ToString());
}
private static void LoadProf(GameClient Client)
{
IniFile rdr = new IniFile(DatabasePath + @"\Profs\" + Client.Username + ".ini");
sbyte count = rdr.ReadSByte("Proficiencys", "Count", 0);
for (sbyte i = 0; i < count; i++)
{
string[] Prof = (rdr.ReadString("Proficiencys", "Prof[" + i.ToString() + "]", String.Empty)).Split(' ');
ProfPacket LoadedProf = new ProfPacket(true);
LoadedProf.ID = ushort.Parse(Prof[0]);
LoadedProf.Level = ushort.Parse(Prof[1]);
LoadedProf.Experience = uint.Parse(Prof[2]);
Client.LearnProf(LoadedProf);
}
}
This is what I got for saving and loading (i watched how SaveInventory and LoadInventory was done I added SaveProf(Client); under SaveInventory in the SaveCharacter method and i also put LoadProf(Client); under LoadInventory in the LoadCharacter method.

I got this in GameClient:

public Dictionary<ushort, ISkill> m_Profs = new Dictionary<ushort, ISkill>(50);
public ISkill[] Profs;

When i use the command @prof 480 5 it says: [Command Error] Object reference not set to an instance of an object.

Do you know what I did wrong? :P
05/13/2009 19:54 alexbigfoot#107
when adding a skill/prof you add it in the m_Profs or Profs? adding it in m_Profs wouldnt give any error, but adding it in Profs ( ISkill[] Profs; ) should... anyway I use the dictionary because its more easy to handle it(as for me)...
05/13/2009 21:04 lostsolder05#108
Quote:
Originally Posted by kinshi88 View Post
Anyone still developing this like me?
nope, just working on my own source still :cool:
05/14/2009 07:38 alexbigfoot#109
Quote:
Originally Posted by lostsolder05 View Post
nope, just working on my own source still :cool:
Well, I dont either now, started my own source yesterday and its going to be 5018+ from its first start.
05/14/2009 13:46 taushif#110
Quote:
Originally Posted by alexbigfoot View Post
when adding a skill/prof you add it in the m_Profs or Profs? adding it in m_Profs wouldnt give any error, but adding it in Profs ( ISkill[] Profs; ) should... anyway I use the dictionary because its more easy to handle it(as for me)...
uhm i add it in m_Profs like this:

Quote:
private void CreateProfInstance()
{
ISkill[] temp = new ISkill[m_Profs.Count];
m_Profs.Values.CopyTo(temp, 0);
Profs = temp;
}

/* Returns false if already contained, true if it is added */
public bool LearnProf(ISkill Prof)
{
if (m_Profs.ContainsKey(Prof.ID))
{
m_Profs[Prof.ID] = Prof;
Prof.Send(this);
CreateProfInstance();
return false;
}
else
{
this.m_Profs.Add(Prof.ID, Prof);
Prof.Send(this);
CreateProfInstance();
return true;
}
}
This is how I let a prof be learned :P
So I add the Profs to m_Profs and the values from m_Profs go
into Profs and it saves with a foreach ISkill Prof in Profs.
I think thats wrong?

Quote:
public static void SaveProf(GameClient Client)
{
IniFile wrtr = new IniFile(DatabasePath + @"\Profs\" + Client.Username + ".ini");

sbyte i = 0;
int numberOfProfs = Client.m_Profs.Count;
for (ushort num=0; num <= numberOfProfs; num++)
{
wrtr.Write("Proficiencys", "Prof[" + i.ToString() + "]", Client.m_Profs[num].ToString());
}
wrtr.Write("Proficiencys", "Count", i.ToString());
}
Is this a better way of saving?
05/14/2009 17:37 alexbigfoot#111
Quote:
Originally Posted by taushif View Post
Is this a better way of saving?
Well, if it works it is... anyway it would work faster i think with

Code:
IniFile wrtr = new IniFile(DatabasePath + @"\Profs\" + Client.Username + ".ini");

sbyte profscount = 0;
foreach(ISkill prof in Client.m_Profs.Values)
{
wrtr.Write("Proficiencys", "Prof[" + profscount.ToString() + "]", prof.ToString());
profscount++;
}
wrtr.Write("Proficiencys", "Count", profscount.ToString());
05/14/2009 20:57 taushif#112
Uhm it works same as ur save what u posted.
But it doesnt save good like mine did.
It only save:
Quote:
[Proficiencys]
Count=0
It doesnt save the prof's so I think maybe its a Null pointer exception or something?
Means that the m_Profs is empty :P and that means that @prof ID Level
doesnt work that good or LearnProf works not good?
Or must I code something that will display the Prof in the client?
because when i use @prof 480 2 i dont see anything in the prof section in the client
but it has to display a club image with lvl 2 :P
05/14/2009 23:27 alexbigfoot#113
I dont really know.
05/15/2009 01:36 scottdavey#114
Can someone give me a download link to a 5017 client? Can only find some spanish thing.
05/15/2009 06:12 ShockSoft#115
Here it is : [Only registered and activated users can see links. Click Here To Register...]
05/15/2009 11:26 Michael Emil#116
Nice dude
05/15/2009 12:54 taushif#117
Quote:
Originally Posted by alexbigfoot View Post
I dont really know.
So you mean that if I use @prof 480 2, then the client knows
what 480 is?
05/15/2009 13:15 tao4229#118
Quote:
Originally Posted by taushif View Post
So you mean that if I use @prof 480 2, then the client knows
what 480 is?
Yes.
05/15/2009 18:53 taushif#119
Quote:
Originally Posted by tao4229 View Post
Yes.
Lmfao I just tested Alex his prof version and it works :P
Tao's prof version doesn't work with me xD
05/15/2009 19:56 LordSesshomaru#120
Quote:
Originally Posted by kinshi88 View Post
Anyone still developing this like me?
I am! Well not really i am helping out my friend who is developing on the server that we will run together while i teach him C# i continue with my source in vb.net. I am Semi-Pro vb.net user and can make a server in C# but i am not great at it (guess u could said it would turn out worse then loft). I got out C# server along with my VB server working with newest patch yet again. But this time i dint use the Manged OpenSSL. I will post some codes later on for some things if i can get around to it . Right now i cant be bothered to fix some of my mistakes and post it i guess i am lazy right now. But i hope everyone that is still developing a server under this marvelous release will have some curtsy and help keep it alive.