• Welcome to Valhalla Legends Archive.
 

Whois Function

Started by Minor, April 28, 2004, 05:06 AM

Previous topic - Next topic

Minor

Microsoft C++ Visual

Knowing using:
Quotefor(char *p = strtok(str, " "); p; p = strtok(NULL, " "))
{
...
} (By: iago)

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)

iago

I don't see why you can't just do:

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

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:
char buf[196];
sprintf(buf, "/w %s %s %s %s\r\n", Command, Name, Game, gName);
Send(buf);

Is that what you're looking for?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Minor

#2
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?

Maddox

#3
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:


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

if(!p)
{
    // handle error
}

p++; // p now holds your game name.
asdf.

Minor

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

if(!p)
{
   // handle error
}

p++;  


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?

Maddox

#5
Almost, you won't dereference (*) p because that would just get the value of 1 char at that specific memory address.


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);
asdf.

Minor

#6
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?

Maddox

#7
Quote from: Maddox on April 29, 2004, 01:47 AM
There is no event for "user in game."

Maybe what you're looking for is
#define EID_INFO                1018
asdf.

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?

Maddox

Maybe you should learn the language first before tackling applications like this.
asdf.