Thread

WHAT THE HECK IS WRONG WITH THIS (Sdk)

WHAT THE HECK IS WRONG WITH THIS // Sdk

1  |  

trekkerx

Oct 3, 2001, 12:59am
Ive been messing with this for ever and it wont work. I cant get my bot
to respond to anything.
This is what I have...

void handle_avatar_chat (void)
{
char* chatmsg;
char reply[256];
char* temp;
int speakerSN;

chatmsg = aw_string (AW_CHAT_MESSAGE);/
speakerSN = aw_int (AW_CHAT_SESSION);

temp = _T("hi");

if (chatmsg == temp) {
sprintf (reply,"Hello %s", speakerSN);
aw_say (reply);
}
}

--
TrekkerX - CEO
Commatron
http://www.commatron.com

andras

Oct 3, 2001, 2:54am
[View Quote] HTH,
Andras

young phalpha

Oct 4, 2001, 6:34pm
try this code...

void handle_avatar_chat (void)
{
char* chatmsg;
char reply[256];
char* temp;
int speakerSN;

chatmsg = aw_string (AW_CHAT_MESSAGE); // removed a unneeded '/' from here
speakerSN = aw_int (AW_CHAT_SESSION);

temp = _T("hi");

if (stricmp(chatmsg, temp)) { // If you have Delphi you can use equal signs, but this is C++ :)
sprintf (reply,"Hello %s", speakerSN);
aw_say (reply);
}
}

[View Quote] void handle_avatar_chat (void)
{
char* chatmsg;
char reply[256];
char* temp;
int speakerSN;

chatmsg = aw_string (AW_CHAT_MESSAGE);/
speakerSN = aw_int (AW_CHAT_SESSION);

temp = _T("hi");

if (chatmsg == temp) {
sprintf (reply,"Hello %s", speakerSN);
aw_say (reply);
}
}

--
TrekkerX - CEO
Commatron
http://www.commatron.com

agent1

Oct 4, 2001, 6:46pm
*Ahem* :)

[View Quote] _T is just a macro that is used to convert strings to their Unicode equivalents, isn't it? In any case, you don't need it. Try using strcpy() or sprintf() (as YP did below) to put the value into the string. Then again, aren't all of these uninitialized pointers? Anyway...

> if (stricmp(chatmsg, temp)) { // If you have Delphi you can use equal signs, but this is C++ :)
> sprintf (reply,"Hello %s", speakerSN);

speakerSN is an int -- you need to use %d instead of %s.

> aw_say (reply);
> }
> }

young phalpha

Oct 4, 2001, 8:18pm
well I did forget that one %s thing :) Anyways, _T is for Unicode compatibility, if you plan on
using it on your computer, no need for it (if you use Windows 9x that is), and all chat messages
and replys should be initialized to 256 bytes (or 255?)...

[View Quote] [View Quote] _T is just a macro that is used to convert strings to their Unicode equivalents, isn't it? In
any case, you don't need it. Try using strcpy() or sprintf() (as YP did below) to put the value
into the string. Then again, aren't all of these uninitialized pointers? Anyway...

> if (stricmp(chatmsg, temp)) { // If you have Delphi you can use equal signs, but this is C++
:)
> sprintf (reply,"Hello %s", speakerSN);

speakerSN is an int -- you need to use %d instead of %s.

> aw_say (reply);
> }
> }

trekkerx

Oct 4, 2001, 9:28pm
yes now I know why it didnt work, thanks phalpha.

[View Quote] > well I did forget that one %s thing :) Anyways, _T is for Unicode compatibility, if you plan on
> using it on your computer, no need for it (if you use Windows 9x that is), and all chat messages
> and replys should be initialized to 256 bytes (or 255?)...
>
[View Quote] --
TrekkerX - CEO
Commatron
http://www.commatron.com

trekkerx

Oct 4, 2001, 9:46pm
It works now, but If I use sprintf(temp, "hello %s", aw_string (AW_LOGIN_NAME). It just frezes and
preforms an illegal operation.
Ive tryed using the Debug, but it gives me an error in the sprintf.c file.

[View Quote] > well I did forget that one %s thing :) Anyways, _T is for Unicode compatibility, if you plan on
> using it on your computer, no need for it (if you use Windows 9x that is), and all chat messages
> and replys should be initialized to 256 bytes (or 255?)...
>
[View Quote] --
TrekkerX - CEO
Commatron
http://www.commatron.com

young phalpha

Oct 4, 2001, 10:12pm
try:

sprintf(temp, "hello %s", aw_string(AW_AVATAR_NAME)); // AW_AVATAR_NAME is defined during this
event as the person who speaks...

[View Quote] [View Quote] > well I did forget that one %s thing :) Anyways, _T is for Unicode compatibility, if you plan
on
> using it on your computer, no need for it (if you use Windows 9x that is), and all chat
messages
> and replys should be initialized to 256 bytes (or 255?)...
>
[View Quote] --
TrekkerX - CEO
Commatron
http://www.commatron.com

trekkerx

Oct 5, 2001, 3:13am
i was using the AW_LOGIN_NAME so when you said 'hello (botname)' and such, but the sprintf just
wont add it to the temp character. It gives me a
write_char(int 104, _iobuf * 0x0064f654, int * 0x0064f3f8) line 1083 + 32 bytes
error in line 1083 in the output.c
i have no clue what it means, it just dose that.

[View Quote] > try:
>
> sprintf(temp, "hello %s", aw_string(AW_AVATAR_NAME)); // AW_AVATAR_NAME is defined during this
> event as the person who speaks...
>
[View Quote] --
TrekkerX - CEO
Commatron
http://www.commatron.com

ananas

Oct 5, 2001, 3:25am
Just a guess, if you have

char *temp;

replace it by

char temp[40];

maybe?

[View Quote] --
"_
|
/\
\ /
__/ /_

ananas

Oct 5, 2001, 3:30am
hm, maybe a little more explanation

char *temp;

This does not give you a buffer where you can store characters,
so it is just an uninitialized pointer that points to some
place in memory, it might be yours, it might belong to a different
program or it might even be program code that you destroy when
you copy (or sprintf) stuff there


char temp[40];

This can be used to actually store a string with up to 39
characters (plus 0x00 character at the end). Such an array
always consists of storage that you may use and (implicite)
a pointer too, so it can be used like a pointer but this
pointer is already initialized when it is created.

--
"_
|
/\
\ /
__/ /_

trekkerx

Oct 6, 2001, 7:54pm
ahhh, now it works. Thanks

[View Quote] > hm, maybe a little more explanation
>
> char *temp;
>
> This does not give you a buffer where you can store characters,
> so it is just an uninitialized pointer that points to some
> place in memory, it might be yours, it might belong to a different
> program or it might even be program code that you destroy when
> you copy (or sprintf) stuff there
>
> char temp[40];
>
> This can be used to actually store a string with up to 39
> characters (plus 0x00 character at the end). Such an array
> always consists of storage that you may use and (implicite)
> a pointer too, so it can be used like a pointer but this
> pointer is already initialized when it is created.
>
> --
> "_
> |
> /\
> \ /
> __/ /_

--
TrekkerX - CEO
Commatron
http://www.commatron.com

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