[Request] How to make a wishes tree

06/05/2010 21:11 .Summer#16
Code:
bool someEventIsTriggered = true;
if (someEventIsTriggered)
       {
	foreach(Game.Character Char in Game.World.H_Chars)
{
	Char.MyClient.DialogNPC = 666111;
	PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
	Char.MyClient.EndSend();
	}
}
fixed the brackets
06/05/2010 21:12 Arcо#17
Quote:
Originally Posted by .Summer View Post
Code:
bool someEventIsTriggered = true;
if (someEventIsTriggered)
       {
	foreach(Game.Character Char in Game.World.H_Chars)
{
	Char.MyClient.DialogNPC = 666111;
	PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
	Char.MyClient.EndSend();
	}
}
fixed the brackets
When he pastes it in C# it's going to fix the brackets automatically.
That was just a waste of a post.
06/05/2010 21:57 dragon89928#18
Quote:
Originally Posted by .Summer View Post
Code:
bool someEventIsTriggered = true;
if (someEventIsTriggered)
       {
	foreach(Game.Character Char in Game.World.H_Chars)
{
	Char.MyClient.DialogNPC = 666111;
	PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
	Char.MyClient.EndSend();
	}
}
fixed the brackets
what's wrong with the brackets? o.0 You can code all that in 1 line and it'd still work.
06/05/2010 22:12 .Summer#19
Quote:
Originally Posted by dragon89928 View Post
what's wrong with the brackets? o.0 You can code all that in 1 line and it'd still work.
looking better.
but whatever XD
06/05/2010 22:19 s.bat#20
Quote:
Originally Posted by .Summer View Post
looking better.
but whatever XD
It's all a matter of style. Unless you're working for a company that strictly enforcing certain coding conventions...
06/05/2010 22:33 dragon89928#21
Quote:
Originally Posted by s.bat View Post
It's all a matter of style. Unless you're working for a company that strictly enforcing certain coding conventions...
Personally I don't like how C# express does the brackets. IMO its a waste of space to have the starting "{" on its own line :p
06/05/2010 22:46 Arcо#22
Java's bracket setup is way better.
06/05/2010 23:39 masternek#23
done, it by myself, thank you rly much :D
06/06/2010 02:48 dragon89928#24
Quote:
Originally Posted by .Arco View Post
Java's bracket setup is way better.
yep i second that
06/06/2010 06:56 xSynthesis#25
I realized that It doesn't show the name of person who wrote the wish on the file.

Code:
#region wish tree
                            case 999999: // make sure you change this to the npc you want to use
                                {

                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("What is your wish?"));
                                        GC.AddSend(Packets.NPCLink2("Type in your wish", 1));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else if (Control == 1)
                                       [COLOR="Magenta"]foreach (DictionaryEntry DE in World.H_Chars)
                                      {
                                          Character Chaar = (Game.Character)DE.Value;[/COLOR]
                                        string wish = ReadString(Data);
                                        if (wish != null)
                                        {
                                            string path = "C:\\OldCODB\\wish.txt";
                                            StreamWriter SW;
                                            if (File.Exists(path))
                                            {
                                                SW = File.AppendText(path);
                                                SW.WriteLine([COLOR="Magenta"]Chaar.Name +[/COLOR] ": " + wish);
                                                //will write  --   Name: My wish
                                                SW.Close();
                                                Console.WriteLine("A new wish has been made!");
                                            }
                                            else
                                            {
                                                SW = File.CreateText(path);
                                                SW.WriteLine(wish);
                                                SW.Close();
                                                Console.WriteLine("A new wish has been made!");
                                            }
                                        }
                                        GC.AddSend(Packets.NPCSay("Your Wish has been added into the file"));
                                        GC.AddSend(Packets.NPCLink2("Thanks", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    break;
                                }
                            #endregion
Add/Change the codes with pink ones. =]
06/06/2010 07:42 dragon89928#26
Quote:
Originally Posted by xSynthesis View Post
I realized that It doesn't show the name of person who wrote the wish on the file.
it doesn't? I'm pretty sure it will. What you're doing right there is cycling through characters, which is unnecessary since you already know that the person that pressed the npc is already gc.mychar.

edit: Okay, I took another look at the code and I think what's gonna happen if you do that is it will write all the names of the people with the same wish in the file x.x Because you didn't add any checks.
06/06/2010 08:10 s.bat#27
Quote:
Originally Posted by xSynthesis View Post
I realized that It doesn't show the name of person who wrote the wish on the file.
Did you test to see if it doesn't write the player's name to the file, or are you just guessing? It looks like it should write the player's name to the file. Your code on the other hand, looks like it will write every single player's name in the file with the single player's wish, but I didn't look too closely into it.
06/06/2010 08:20 Arcо#28
Quote:
Originally Posted by xSynthesis View Post
I realized that It doesn't show the name of person who wrote the wish on the file.
Uhm...
SW.WriteLine(GC.MyChar.Name + ": " + wish);
Yes it does?
06/06/2010 08:22 xSynthesis#29
Quote:
Originally Posted by s.bat View Post
Did you test to see if it doesn't write the player's name to the file, or are you just guessing? It looks like it should write the player's name to the file. Your code on the other hand, looks like it will write every single player's name in the file with the single player's wish, but I didn't look too closely into it.
Yep I tested it and all I seen was wishes. There was no names. The first code which is
Code:
                                       foreach (DictionaryEntry DE in World.H_Chars)
                                      {
                                          Character Chaar = (Game.Character)DE.Value;
allows you to use "Chaar" at NPCDialog.cs otherwise you will get errors. I don't really know why but it seems GC.MyChar.Name doesn't work for some reason. But Chaar.Name does. I have tested my code aswell. And it works for me. D=

Edit:
Quote:
Originally Posted by .Arco View Post
Uhm...
SW.WriteLine(GC.MyChar.Name + ": " + wish);
Yes it does?
Well, It might work on you but it doesnt for me. I got ConquerSX's source and it's kinda different than normal one. It might because of that. I dunno D=
06/07/2010 11:10 masternek#30
yes, there are names, but thx for try helping xsynthesis :D