Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 18:14

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Can I please get a little help with this?

Discussion on Can I please get a little help with this? within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
Can I please get a little help with this?

Ok it seems everybody is fascinated with using console which is great BUT I prefer GUI, basically my issue is a simple one for those that know and I've spent hours looking on Google trying to figure this out and I'm still non the wiser

I'm using the C# client hooking sample that was kindly given to the community by IamHawtness but I have been trying to convert it to a GUI rather than a console.

I understand the simple part of adding buttons which I have done so now I click "StartCO" button and it loads the exe up. I added a richtextbox also and finally hung my head in shame because what I was attempting just didn't work no matter what code I looked at on Google.

The GUI is nothing fancy or special just a single button to load the Conquer.exe which was simple enough and as stated I added a richtextbox but how on earth do I get it so that it writes data to the richtextbox???

Code:
private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            COClient client = new COClient();

            client.Attached += (delegate()
            {
                Console.WriteLine("Client with process Id " + client.ProcessId + " attached");
                Console.WriteLine();
            });       
        }
That's all I'm trying to add for now and any help with this little part will no doubt help me to understand how to add future things. Console.Writeline doesn't seem to add to the richtextbox?

I also find I can close the GUI and the client stays on but that's not such a big deal at the moment as this code seems to open the client regardless

Code:
private void button1_Click(object sender, EventArgs e)
        {
            COClient client = new COClient();
            client.Start();
        }
denominator is offline  
Old 05/04/2012, 15:21   #2
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,198
Really, if you don't know how to show text in a TextBox control, don't bother with this.
IAmHawtness is offline  
Thanks
5 Users
Old 05/04/2012, 19:44   #3
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
Thanks for the person that PMed with help ^^ And thanks for nothing Hawtness appreciated, how the f**k you expect people to learn with an answer like that?

I actually WAS checking and have actually worked using console with Alchemy, Pservers but ALL have been in CONSOLE ffs!
denominator is offline  
Old 05/04/2012, 20:02   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Make your own method for using WriteLine with a textbox...

Textboxes are object with a property Text...

richTextBox1.Text = "new text for the box!"


What I did in my proxy Paradise Example was something like...

Code:
 public void OutputLine(string text)
        {
                this.Invoke(new MethodInvoker(delegate { List<string> lines = packetsOut.Lines.ToList(); lines.Insert(0, text); if (lines.Count > 100) lines.RemoveAt(100); packetsOut.Lines = lines.ToArray(); packetsOut.Refresh(); }));
        }
It's messy but basically here's what I'm doing...

I create a list of all lines currently in the textbox (I do this because of the handy dandy list functions... you could do it in far 'better' ways... I used this because it's dead simple)

Ok so we now have a list of all of our lines. We want to add a new line? Well insert it at the START of the textbox (so newest line always is at top. If you want it always at bottom like a normal console... well you can sort out the scrolling yourself xD)

So... lines.Insert(0, text);

This adds our new text at the begining of the list.

Wait... what if the list is too long? Well... simply RemoveAt(maximumNumberOfLines) to keep it trimmed down.

Now that we have all of our lines... simply set the textbox text. Only slight issue there is it operates using arrays (we could have used arrays but then you have to write your own array functions.

textbox.Lines = lines.ToArray();

Tada! I also have the refresh there but I don't recall if it's needed.

The use of delegates I seem to remember having to do with cross thread issues when dealing with winforms but I honestly don't remember.

I generally don't go anywhere near winform and my experience is essentially single threaded, simple winform programs where nothing really matters, console applications or XNA where you have to design your own GUI library anyways lol.
pro4never is offline  
Thanks
1 User
Old 05/04/2012, 20:57   #5
 
U2_Caparzo's Avatar
 
elite*gold: 0
Join Date: Aug 2011
Posts: 314
Received Thanks: 90
Quote:
Originally Posted by denominator View Post
Thanks for the person that PMed with help ^^ And thanks for nothing Hawtness appreciated, how the f**k you expect people to learn with an answer like that?

I actually WAS checking and have actually worked using console with Alchemy, Pservers but ALL have been in CONSOLE ffs!
google, u can't say that u spent hours in google and u didn't find how to append text in a richtextbox..
U2_Caparzo is offline  
Old 05/04/2012, 21:49   #6
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
No U2_Carparzo that's why I eventually went to sleep at 3:00PM UK time >.<

Anyway a simple explanation was given and P4N has also given an explanation, this is supposed to be a HELP forum and seems there are very FEW helpers on the forums these days which is why the pserver section went to ***** as well and why many people left for other coding forums.

Looking for forums associated with a ***** game such as Conquer though is like looking for a needle in a haystack with the few exceptions.

Reagardless I have read what I've been told, Googled some more and found that what it was that I needed is somewhat simple. Putting it into practise is working if I just want to add simple text when the button is pressed as well as it loading Conquer. Getting it to display the ProcessID is something I'm still looking into and I don't exactly like to be spoonfed, it was me that enlightened this community that there was an error with the marriage sequence in the 5165 pserver source and just because I had the source to look at. Like I said before I have worked on console apps but GUI is prettier looking albeit slightly different with how things are coded or at least to me it is.


EDIT:- P4N I LOVE YOU!!!!! No **** got it all working and showing in GUI now instead of console, thank you for your help See guys I asked for a LITTLE help and NOT spoonfeeding , now showing PID, packets sent and received all in the GUI.
denominator is offline  
Reply




All times are GMT +2. The time now is 18:14.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.