Valhalla Legends Forums Archive | Battle.net Bot Development | Whois Function

AuthorMessageTime
Minor
Microsoft C++ Visual

Knowing using:
[quote]for(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
{
...
} (By: Iago)[/quote]

How do i get it to read and send to a user the Name and Game Name(Starcraft, Brood war) and Game (2v6 MicroWars). and nothing else.
Example:
Send("/whisper %s %s, %s, %s\r\n",Command,Name,Game,gName);

Example Result:
"<From: BotName> Minor, Starcraft, 3v3 BGH"

Please Help... (Writting first in CHAT Format)
April 28, 2004, 10:06 AM
iago
I don't see why you can't just do:

[code]send("/w %s %s", username, str);[/code]

What that loop does is breaks the string at every space and runs the loop for that individual part of the string. That's not quite what you're trying to do, it would seem.

If you have those variables already(command, name, game, gName) you can do this:
[code]char buf[196];
sprintf(buf, "/w %s %s %s %s\r\n", Command, Name, Game, gName);
Send(buf);[/code]
Is that what you're looking for?
April 28, 2004, 5:48 PM
Minor
Yes thank you and one more question...
What event number/tag for "USER IN GAME"?

"Edit: EID_CHANNELDOESNOTEXIST 1014" - what is the EID for USER IN GAME and what is the event number?
April 29, 2004, 5:18 AM
Maddox
There is no event for "user in game."

However, knowing that in the info text you will receive something like "username is using Starcraft in game some game name" you might do something like:

[code]
char *p = infotext;
for(int i = 0; i < 6; i++)
p = strchr(p, ' ');

if(!p)
{
// handle error
}

p++; // p now holds your game name.
[/code]
April 29, 2004, 6:47 AM
Minor
[quote]
char *p = infotext;
for(int i = 0; i < 6; i++)
p = strchr(p, ' ');

if(!p)
{
// handle error
}

p++;

[/quote]

So, would that mean that if i wanted to make it respond "Not in game" or "In game..." i would need (after that code):
if (p != NULL) {
Send("/w %s Game Name: %s\r\n",Commander,*p);
} // If in game...
if (p == NULL) {
Send("/w %s %s Not in a Game.\r\n",Commander,Suspect);
} // If user not in game

Correct?
April 29, 2004, 6:51 AM
Maddox
Almost, you won't dereference (*) p because that would just get the value of 1 char at that specific memory address.

[code]
if(p) // in game
Send("/w %s Game Name: %s\r\n", Commander, p);
else // not in game
Send("/w %s %s Not in a Game.\r\n", Commander, Suspect);
[/code]
April 29, 2004, 6:55 AM
Minor
heh ya thats an easier way :P
But can u answer the other question please? what is the event handle/id/number ?

the "EID_USERGAME 1000" kind of thing.

Edit: Or does it not matter?
April 29, 2004, 6:56 AM
Maddox
[quote author=Maddox link=board=17;threadid=6516;start=0#msg57518 date=1083221262]
There is no event for "user in game."
[/quote]

Maybe what you're looking for is
[code]#define EID_INFO 1018[/code]
April 29, 2004, 6:59 AM
Minor
void TheBot::cINFO(char *Commander, char *Suspect) {
char *p = infotext;
for(int i = 0; i < 6; i++)
p = strchr(p, ' ');

if(!p)
{
// handle error
}

p++;
if(p) // in game
Send("/w %s Game Name: %s\r\n", Commander, p);
else // not in game
Send("/w %s %s Not in a Game.\r\n", Commander, Suspect);
}

Brings up alot of errors... I never tried doing this before (Whois and acknoledges the game and ect.) Whats wrong with that?
April 29, 2004, 7:13 AM
Maddox
Maybe you should learn the language first before tackling applications like this.
April 29, 2004, 3:27 PM

Search