Quote:
Originally Posted by pro4never
My server is using full C# syntax stored as .npc files which are debugged and executed at runtime when requested (that way if there are errors it's not executed which would cause crashing/issues)
|
I'm using the .npc file idea

I will have it like 12111.npc 12111 = npc id
the structure inside is just
Code:
case 0:
{
Text("Testing..");
Link("Hi", 255);
break;
}
Then I still need to write the hardest part which is read the npc dialog for now I will have npc dialog in database as follows:
Code:
case 12111:
{
switch(npcRequest.optionID)
{
File.FindAndRead(12111);
}
break;
}
then eventually ill change the whole system so all of it is in the .npc file.
so when clicking an npc it does
Code:
File.FindAndRead(npcrequest.ID);
=]
However I need abit of help in the FindAndRead void

will post problems later.
btw .npc is just text file.
#edit
Need help!

So my void is as follows
Code:
public static void FindAndRead(uint NpcID, GameState client)
{
Console.WriteLine("NPC Being accessed: {0}", NpcID);
string DialogPath = Constants.NpcDialogs + NpcID;
if (File.Exists(DialogPath))
{
Dialogs dialog = new Dialogs();
dialog.Client = client;
dialog.Replies = new List<NpcReply>();
File.Open(DialogPath, FileMode.Open);
string[] Dialog = File.ReadAllLines(DialogPath);
if (Dialog.Contains("case 0:"))
{
}
}
}
But have NO idea how to read a file like this:
Code:
switch(NpcRequest.OptionID)
{
case 0:
{
Text("Testing..");
Link("Hi", 255);
break;
}
}
I just need to read a line and take action
Code:
File.ReadLine("switch(Npcrequest.optionID))
{" { ((Npc.Add "switch(Npcrequest.optionID))"{))
int case;
if case = 0 { if File.Contains("case " + case") Npc.Add "case 0:");
something like that but have no idea. ;s