Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: WiLD on March 30, 2003, 09:27 PM

Title: C++ help plz
Post by: WiLD on March 30, 2003, 09:27 PM
hi all,
im kinda new to c++ im only really good in vb. but i was looking at some source codes of bots (c++) and i did find some errors so i fixed them up but 1 i just cant get it to work here it is: at the top of wild.cpp i have #include <Connection.h>  it was "Connection.h" but that caused errors so i just changed it to <Connection.h>. But when i click compile  it says Connection.h cant be found. I no its a existing file because its in the same folder so what should i do?
and remember im new 2 c++ so kinda make it simple 2 read ;)

I justed edited this to show u wats in wild.cpp

#include <Connection.h>
#include <conio.h>

void main()
{
   BinaryBot *Bot = new WiLD BinaryBot;
   strcpy(Bot->username, "Usernmae");
   strcpy(Bot->password, "Pssword");
   strcpy(Bot->cdkey, "CD-key");
   strcpy(Bot->statstring, "WiLD ChaT");
   strcpy(Bot->homechannel, "Clan VioLaToRz");
   if(Bot->Connect("211.233.0.73"))
   {
      Bot->Output->WriteEx(ConsoleOutput::YELLOW, "Connected To B.net!\n");
      Bot->Startup();
   }
   else
      Bot->Output->WriteEx(ConsoleOutput::RED, "Connection Failed!");
   delete Bot;
   getch();
}
Title: Re:C++ help plz
Post by: Eibro on March 30, 2003, 10:25 PM
Quote from: WiLD on March 30, 2003, 09:27 PM
hi all,
im kinda new to c++ im only really good in vb. but i was looking at some source codes of bots (c++) and i did find some errors so i fixed them up but 1 i just cant get it to work here it is: at the top of wild.cpp i have #include <Connection.h>  it was "Connection.h" but that caused errors so i just changed it to <Connection.h>. But when i click compile  it says Connection.h cant be found. I no its a existing file because its in the same folder so what should i do?
and remember im new 2 c++ so kinda make it simple 2 read ;)

I justed edited this to show u wats in wild.cpp

#include <Connection.h>
#include <conio.h>

void main()
{
  BinaryBot *Bot = new WiLD BinaryBot;
  strcpy(Bot->username, "Usernmae");
  strcpy(Bot->password, "Pssword");
  strcpy(Bot->cdkey, "CD-key");
  strcpy(Bot->statstring, "WiLD ChaT");
  strcpy(Bot->homechannel, "Clan VioLaToRz");
  if(Bot->Connect("211.233.0.73"))
  {
     Bot->Output->WriteEx(ConsoleOutput::YELLOW, "Connected To B.net!\n");
     Bot->Startup();
  }
  else
     Bot->Output->WriteEx(ConsoleOutput::RED, "Connection Failed!");
  delete Bot;
  getch();
}

First off, it's int main() not void main(). Second, You need to #include "Connection.h" not <Connection.h> Third you need to lose "WiLD" in BinaryBot *Bot = new WiLD BinaryBot;
Title: Re:C++ help plz
Post by: WiLD on March 30, 2003, 10:45 PM
ok thank you, but now im getting a extra error.
i still got the same error as before but i also have this one on line 4.

Line  |  Unit
4        c:\wildbot\packetbuffer.h

| Message
from c:\wildbot\Connection.h:4,

so wats wrong now......
Title: Re:C++ help plz
Post by: SiMi on March 30, 2003, 11:16 PM
hm maybe i should learn C++
Title: Re:C++ help plz
Post by: Zakath on March 30, 2003, 11:51 PM
Perhaps you shouldn't rip off DarkMinion's work, also.

The source you're copying from isn't functional...and hasn't been for a long time. Moreover, it's very bad form to just insert your name in places like that.
Title: Re:C++ help plz
Post by: WiLD on March 30, 2003, 11:58 PM
if u had havd read my first post i said it wasnt my source im learning. i wasnt going to relese it. i just want to learn c++. and i cant find ne GOOF decent tutorials on the net
Title: Re:C++ help plz
Post by: Zakath on March 31, 2003, 01:11 AM
I'm afraid that looking at DM's source isn't gonna be very helpful for just starting out. He used a number of fairly advanced concepts in creating even that rather primitive vLBBot - classes, dynamic memory allocation, a custom string library...try to find a more conventional source of inspiration if you can - it'll be much easier to understand.
Title: Re:C++ help plz
Post by: n00blar on March 31, 2003, 06:14 AM
I recommend this to you... and if you say its lame I will strangle you and cut off your nads and feed them raw to the dogs.. kthx

www.google.com -> search query = "Teach Yourself C++ in 21 Days"
Title: Re:C++ help plz
Post by: Camel on March 31, 2003, 09:22 PM
Quote from: Eibro on March 30, 2003, 10:25 PMFirst off, it's int main() not void main().
what's wrong with void main() ?
Title: Re:C++ help plz
Post by: Skywing on March 31, 2003, 09:52 PM
Quote from: Camel on March 31, 2003, 09:22 PM
Quote from: Eibro on March 30, 2003, 10:25 PMFirst off, it's int main() not void main().
what's wrong with void main() ?
void main() doesn't exist in C or C++.  It's a nonstandard compiler extension.
Title: Re:C++ help plz
Post by: WiLD on April 01, 2003, 07:44 AM
well thx about all, and i will have a look at that c++ in 21 days. i also learnt several new things today =)
just 1 quick quetion that no 1 in me chanel would help me with is:
szName = the %s before hand right....
and wat does \n\r mean i no its a varible but of like wat does it do..

Thx alot.
Title: Re:C++ help plz
Post by: MrRaza on April 01, 2003, 08:51 AM
you really need to buy a book and read it.

\n == New Line
\r == Return

there's alot mmore.
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 02, 2003, 02:35 PM
This is why people shouldn't start with VB.
Title: Re:C++ help plz
Post by: WiLD on April 02, 2003, 06:38 PM
dont you mean SHOULD start with vb storm?

well thx raza.

because all the sources iv looked at i always see \n\r so that helps me alot. mmm FINAL LAST THING: do you have to put \n on every line? and \r means return but return to wat is it like return aka enter?
Title: Re:C++ help plz
Post by: Starnaught on April 02, 2003, 06:42 PM
\n = new line
\r = carriage return

\n puts the cursor on the next line
\r returns the cursor to the leftmost position
Title: Re:C++ help plz
Post by: WiLD on April 02, 2003, 06:48 PM
wow thank you again. every1 here is so helpful thank you all. now that i understand those 2 varibles clearly i will understand most bot sources abit more.
Thank you

WiLD
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 02, 2003, 08:18 PM
No typo in my post. VB lets you assume a lot of stuff you can't assume in other languages.
Title: Re:C++ help plz
Post by: dxoigmn on April 02, 2003, 10:30 PM
Quote from: St0rm.iD on April 02, 2003, 08:18 PM
No typo in my post. VB lets you assume a lot of stuff you can't assume in other languages.

I don't want to start a language war, but I'm wondering what that "stuff" is.  Care to elaborate?
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 04, 2003, 09:56 PM
That memory is magically handled for you.
Also that it's ok to, say, assign a string to an int.
Title: Re:C++ help plz
Post by: Yoni on April 05, 2003, 06:00 AM
It's not OK to assign a string to an int in VB, but the conversion is indeed much simpler than in, say, C.

Converting from VB to C = "wtf? You have to use a function to copy strings?"
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 05, 2003, 08:04 PM
"what's a function?"
Title: Re:C++ help plz
Post by: Yoni on April 05, 2003, 08:19 PM
Naa, VB at least uses the keyword "Function". Maybe "what's a pointer"
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 05, 2003, 08:35 PM
I mean, it's not like VB programmers actually make their own functions anyway.
Title: Re:C++ help plz
Post by: Yoni on April 06, 2003, 07:56 AM
If they didn't write their own functions, they wouldn't get very far (not much farther from Label1.Caption="l33tb4wt")
Title: Re:C++ help plz
Post by: Camel on April 07, 2003, 12:15 AM
hey, it's entirely possible to use pointers in vb!
1) manipulating copymemory (not really manipulating -- that is actually the intended use for copymemory, but to a vb programmer it's manipulation ::))
2) VarPtr(), StrPtr(), and ObjPtr()

i mean, why bother doing "str1 = mid(str2, 2)" when you could do "str1 = space(len(str2) - 1) : copymemory str1, strptr(str2) + 1, len(str2) - 1" ?
Title: Re:C++ help plz
Post by: Grok on April 07, 2003, 04:04 AM
That won't work.

Strings in VB are ... well I'll let you try it.
Title: Re:C++ help plz
Post by: Etheran on April 07, 2003, 07:02 AM
Unicode.
Title: Re:C++ help plz
Post by: Camel on April 07, 2003, 03:06 PM
of course it would work
it wouldnt *accomplish* anything, but it would work
Title: Re:C++ help plz
Post by: c0ol on April 10, 2003, 12:04 AM
NO, again im with storm, VB is horrible for you. VB will get u thinking like a retarted monkey, then when u actaully try to code in a real language you will have no idea whats going on.
Title: Re:C++ help plz
Post by: Camel on April 10, 2003, 12:36 AM
well of course you wouldn't want to learn about pointers in vb. that would just be recockulous. it can be confusing enough just learning it in a real language, so it would be 50million times harder in vb. my point was that it is _possible_ to manipulate data with pointers in vb. example:
   VerQueryValue lpbBuffer(0), "\", ffip, dwSize
   CopyMemory ffi, ffip, Len(ffi)

   version = 0
   CopyMemory x, ByVal ffip + 16, 4: version = version Or ((x And &HFF) * (256 ^ 2)) 'LShift(x And &HFF, 8 * 2)
   CopyMemory x, ByVal ffip + 18, 4: version = version Or ((x And &HFF) * (256 ^ 3)) 'LShift(x And &HFF, 8 * 3)
   CopyMemory x, ByVal ffip + 20, 4: version = version Or (x And &HFF)
   CopyMemory x, ByVal ffip + 22, 4: version = version Or ((x And &HFF) * (256 ^ 1)) 'LShift(x And &HFF, 8)


this doesn't write data to an address, it only reads data..but i think you'll get the point
Title: Re:C++ help plz
Post by: Banana fanna fo fanna on April 10, 2003, 02:31 PM
Pointers are syntax though...