Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Presence on February 28, 2003, 07:38 PM

Title: C Bot Programming
Post by: Presence on February 28, 2003, 07:38 PM
Yo can anyone here help me with the script for connecting a bot on C ?

(plz no flaming)
Title: C Bot Programming
Post by: Presence on February 28, 2003, 07:39 PM
rr... i meant
the script in C language
for connecting a bot :D
Title: Re: C Bot Programming
Post by: Banana fanna fo fanna on March 01, 2003, 07:03 AM
greetbot
Title: Re: C Bot Programming
Post by: Moonshine on March 01, 2003, 10:58 PM
Side note: The proper term in C is source code, not scripts.
Title: Re: C Bot Programming
Post by: Presence on March 04, 2003, 05:39 PM
okay so im a total newbie...
can anyone help me ?
Title: Re: C Bot Programming
Post by: ILurker on March 04, 2003, 06:22 PM
int BnBot::Connect() {
  struct sockaddr_in name;
  struct hostent *hp;

  memset(&name, '\0', sizeof(name));
  name.sin_family = AF_INET;
  name.sin_port = htons(nServerPort);

  // if this is a hostname and not an IP address, resolve it
  char *p = szServerAddr;
  while (*p && (isdigit(*p) || (*p == '.'))) {
    p++;
  }

  // non-digit found - assume hostname
  if (*p) {
    hp = gethostbyname(szServerAddr);
    if (hp == 0)
      return 0;         // can't resolve hostname
    memcpy(&name.sin_addr, hp->h_addr, hp->h_length);
  }
  else {
    name.sin_addr.s_addr = inet_addr(szServerAddr);
  }

  s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (s == INVALID_SOCKET) {
    return 0;
  }

  if (connect(s, (struct sockaddr *)&name, sizeof(name))) {
    return 0;
  }

  return 1;
}
Title: Re: C Bot Programming
Post by: Kp on March 05, 2003, 06:58 AM
ILurker: I must point out that he asked for C code.  Your function is a class member, which only works in C++. *g*
Title: Re: C Bot Programming
Post by: MrRaza on March 05, 2003, 07:05 AM
gogogo C! ;D
Title: Re: C Bot Programming
Post by: Noodlez on March 06, 2003, 03:21 PM
QuoteILurker: I must point out that he asked for C code.  Your function is a class member, which only works in C++. *g*
It's not even his function... that's straight out of DMBot
Title: Re: C Bot Programming
Post by: Zorm on March 06, 2003, 03:31 PM
Silly noodlez, you are wrong. That is from greetbot/bnx!
Title: Re: C Bot Programming
Post by: Banana fanna fo fanna on March 07, 2003, 06:05 PM
NOODLEZ GOT OWNED.
Title: Re: C Bot Programming
Post by: ILurker on March 07, 2003, 06:38 PM
Zorm is right, and +, i was bored so i just threw a c++ code at him, that i had in my folder that i was going to delete
i bairly know c++, so i couldnt well explain the source to him
Title: Re: C Bot Programming
Post by: Noodlez on March 07, 2003, 08:26 PM
/me cries
then dmbot stole it!
Title: Re: C Bot Programming
Post by: ILurker on March 07, 2003, 09:29 PM
Wonder when the stars will be fixed  :-/ ( the forum member rank thingy's )
Title: Re: C Bot Programming
Post by: tA-Kane on March 08, 2003, 02:34 AM
QuoteWonder when the stars will be fixed
They're broken?
Title: Re: C Bot Programming
Post by: Yoni on March 08, 2003, 03:43 AM
QuoteWonder when the stars will be fixed  :-/ ( the forum member rank thingy's )
They work exactly the way they're meant to.