Thread

me again, with an sdk question :) (Sdk)

me again, with an sdk question :) // Sdk

1  |  

pc wizard

Sep 13, 1998, 10:21pm
I got the if statements to work from before... I have it where when someone
enters it checks the name with an if statement and if it is PC Wizard then
it says a different message than if it was somebody else:

#define bot_owner "PC Wizard"
.......
void handle_avatar_add (void)
{

char message[100];

if (strstr (aw_string (AW_AVATAR_NAME), bot_owner)) {
sprintf (message, "Ah, my master has entered! (unless it's a tourist)
Hello %s", aw_string (AW_AVATAR_NAME));

}
else {
sprintf (message, "Hello %s, a bot by PC Wizard.", aw_string
(AW_AVATAR_NAME));
}
aw_say (message);
printf ("avatar_add: %s\n", aw_string (AW_AVATAR_NAME));

}

It works, BUT when I was testing it I logged in as a tourist with the name
PC Wizard and it went to the
sprintf (message, "Ah, my master has entered! (unless it's a tourist) Hello
%s",
line (thinking that the if statement was true) even though the name had ""s
around it.... How do I get it to check the citizen number instead? I tried
AW_CITIZEN_NUMBER to see if it would work, but that didn't work (gave my bot
an illiegal op) is there a way to get it to check the number instead of the
name? or a way to get around it so the bot doesn't think the tourist is the
same person as the citizen? I don't really mind it in this situation, but
I'm wanting to be able to put in some commands through the chat screen that
the bot will check who said it first...

PC Wizard (ICQ-537376)
wizardry at home.com
http://pcwizard.ml.org

pc wizard

Sep 13, 1998, 10:24pm
Had a few typos in that but it was just in what the bot was supposed to say.

[View Quote]

roland vilett

Sep 14, 1998, 5:53pm
For this you should use the C library function strcmp() instead of strstr().
strstr() searches for any occurrence of the substring in the source, so
that's why the tourist name "PC Wizard" still matches. Also you'll need to
change it to be if (!strcmp (aw_string (AW_AVATAR_NAME), bot_owner)))
(notice the !) because strcmp returns 0 if the strings match.

The AW_CITIZEN_NUMBER is an integer, not a string, which is presumably why
you got an illegal op if you tried to pass it into strstr(). Also,
AW_CITIZEN_NUMBER is not defined during the various AVATAR_* events. To get
a citizen number you would have to take the avatar name and use
aw_citizen_attributes_by_name().

-Roland

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2021. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn