Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Minor on April 13, 2004, 01:36 AM

Title: Question Referring to CHAT Bots
Post by: Minor on April 13, 2004, 01:36 AM
Using Microsoft Visual C++ Compiler.

Is there an easy way to check if a person is in a game or not by using a specific Idle. For Example: If you type to bot "info Username"
and bot goes through the whois and then
Send("/msg %s %s is Currently in Game: %s\r\n",Master,User,Game);
or
Send("/msg %s %s is Not in a Game.\r\n",Master,User);
**Not in specific indentifiers but you get the point, i hope***

Can someone help me on this subject please.
Title: Re:Question Referring to CHAT Bots
Post by: Eric on April 13, 2004, 03:09 AM
/whois <user> and/or if the user is on your friends list, /friends list.
Title: Re:Question Referring to CHAT Bots
Post by: Minor on April 13, 2004, 05:43 AM
I ment, not from the command line... When making the bot... How do i get the bot to recieve the "%s is using Broodwar in game %s" and off of that say "%s is in a Game: %s"?

How do i get to say, Example:
"Bot: /whois Username"
"Server: Username is using Brood war In game 3on3"
"Bot: /msg Master Username is in game: 3on3"

How do i get it to Reply to the Server message to get it to message me saying its in a game...
And...

"Bot: /whois Username"
"Server: Username is using Broodwar in a Private channel."
"Bot: /msg Master Username is not in a game"

Is there like a special way in C++ to use the If-then-else statement with Wildcards so i could say something like:

if(serverreply == *in game*) {
 Send("/msg %s %s is in Game: %s\r\n",Master,Name,Game);
}
if(serverreply != *in game*) {
 Send("/msg %s %s is not in a Game\r\n",Master,Name);
}

Like that? Can someone please help me im very lost in this situation  :-\
Title: Re:Question Referring to CHAT Bots
Post by: iago on April 13, 2004, 08:14 AM
look up sprintf and vprintf/vfprintf/vsprintf/vsnprintf - I forget which of those is the most useful.
Title: Re:Question Referring to CHAT Bots
Post by: Moonshine on April 13, 2004, 11:01 AM
char *pszUsername = strtok(szPacket, " ");

char * pszGameName, *p;

for (;;) {
p = strtok(NULL, " ");
if (p != NULL)
  pszGameName = p;
else
  break;
}

Edit:  pszGameName might not refer to the whole game name if the game name has a space in it (e.g. Warcraft III : The frozen throne).  So you might have to use a counter inside the for loop to detect exactly how many tokens you've taken, then use the appropriate token# as the game name.
Title: Re:Question Referring to CHAT Bots
Post by: iago on April 13, 2004, 11:16 AM
The cool way to get all tokens out of a string, if you want to use strtok, is:

for(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
{
...
}


Adron showed me that a long time ago when I was complaining I didn't understand strtok(), and I've never forgotten it :)
Title: Re:Question Referring to CHAT Bots
Post by: Moonshine on April 13, 2004, 05:19 PM
lol the cool way...

that's a neat "shortcut" :)
Title: Re:Question Referring to CHAT Bots
Post by: Minor on April 14, 2004, 12:40 AM
So if i wanted an Idle (saying i have the settings for the idle already inputed) to check if a user in a list "Stalklist" and check if hes in a game it would look something like this:

void Bot::StalkProc() {

   User tmpUser;
   for (int i = 0; i < stalkList.GetElements(); i++) {
      stalkList.GetUser(i,tmpUser);
      Send("/whois %s\r\n",tmpUser.Name);
      }
   for(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
   {
   char *pszUsername = strtok(szPacket, " ");
   char * pszGameName, *p;
   for (;;) {
   p = strtok(NULL, " ");
   if (p != NULL)
     pszGameName = p;
   Send("/w %s Stalked.\r\n",tmpUser.Name);
   else
     break;
   }
}

If not please assist me because now i have 28 errors and before compiling the code i never had any... So obviously its wrong can u tell me what im doing wrong?