Thread

What's wrong with this code? (Sdk)

What's wrong with this code? // Sdk

1  |  

andon m. coleman

Jul 29, 1999, 5:16pm
#include "stdafx.h"
#include "DlgProxy.h"
#include "mmsystem.h"
#include "SDK BOT.h"
#include "HistoryEdit.h"
#include "winsock2.h"


/* Header files used by AW SDK */
#include "aw.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Header files used to make the Dialog Boxes work */
#include "Admin.h"
#include "DJ.h"
#include "Ejector.h"
#include "Greeter.h"
#include "New_Version.h"
#include "SDK BOTDlg.h"
#include "UPDATEDlg.h"



#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/* PRE-DEFINED DATA TABLE PART 1 --- The Initializing Stage */


CString chWorld; /* Stores the World the BOT is occupying */

CString chBotName; /* Stores the Bots Name */

CString chPassword; /* Stores the Privilidge password for the Citizen ID */

CString chUniverse; /* Will be used to select the Address and Port of a
Universe to login to */



CString strText; /* Is used for the Status LOG */
CString strBotStatus; /* Is used for the Status LOG */
#define strText strBotStatus /* Used to append the newest status to the rest
of the Status Window TEXT */

#define chIP "205.153.208.40"
int nPort = 5670;
int nWhois;

int nVisitors1 = 0; /* Visitor Counter --- Value Appended to */

char *reply[255]; /* Used in MANY of the bots messages */
char message[100]; /* Used in MANY of the bots messages */

CString chVersion="V. 1.05.700 <Developers Version>"; /* Displayed when
Version is called */

void handle_avatar_add (void);
void handle_chat (void);
void handle_avatar_click (void);
Buildit (int OBJECT_X, int OBJECT_Y, int OBJECT_Z, int OBJECT_YAW, CString
OBJECT_MODEL, CString OBJECT_ACTION, CString OBJECT_DESCRIPTION);
Whisper (int WHICH_AV, CString chWhisper);
void World_Options (void);
void Whois (void);

/* SEVERAL HUNDRED TOP-SECRET LINES CUT OUT =P */

void handle_chat (void)
{

if (msg2.Find("whois") == -1){}

else
{
Whisper (1, "Whois Pending --- Please click on the avatar you wish to
recieve info on . . .");
int nWhois=aw_int (AW_CHAT_SESSION);
aw_event_set (AW_EVENT_AVATAR_CLICK, 0);
aw_event_set (AW_EVENT_AVATAR_CLICK, Whois);

}
}

Whisper (int WHICH_AV, CString chWhisper)
{

if (WHICH_AV == 1)
{
aw_whisper (aw_int (AW_CHAT_SESSION), chWhisper);
}

else
{

if (WHICH_AV == 0)
{
aw_whisper (aw_int (AW_AVATAR_SESSION), chWhisper);
}

else
{
aw_whisper (WHICH_AV, chWhisper);
}
}
return 0;
}

void Whois (void)
{
char msg[255];
int address;
int session_id = aw_int (AW_CLICKED_SESSION);
aw_address(session_id);
address = aw_int (AW_AVATAR_ADDRESS);
sprintf ((char*)reply,"Whois results for %s", aw_string
(AW_CLICKED_NAME));
sprintf (msg, "IP address: %s", inet_ntoa (*(struct in_addr*)&address));
Whisper(nWhois,(char*)reply);
Whisper(nWhois, msg);

/*--------------------------------------------------------------------------
----------------
OTHER WHOIS STUFF WILL GO HERE, AS SOON AS I GET WHISPER TO WORK WITH IP
ADDRESS STUFF . . .
--------------------------------------------------------------------------
----------------*/
aw_event_set (AW_EVENT_AVATAR_CLICK, 0);
aw_event_set (AW_EVENT_AVATAR_CLICK, handle_avatar_click);
}

/* SEVERAL HUNDRED MORE TOP-SECRET LINES CUT OUT =P */



Problem with this code is :
It doesn't whisper to ANYONE after the IP address has been retrieved . . .
If AW_AVATAR_ADDRESS didn't write to :
aw_int (AW_AVATAR_SESSION) --- I'd be able to use :


Whisper(0,(char*)reply);
Whisper(0, msg);


-Thanks in advance,
Andon Coleman

Andon13
C.E.O. of Nothing, Inc.

andon m. coleman

Jul 29, 1999, 10:10pm
Calling AW_AVATAR_ADDRESS changes the value for AW_AVATAR_SESSION . . .

In other words, when I try to whisper to the person who did the clicking, it
whispers to the person who's IP address was being looked up . . .

-Andon Coleman

andon m. coleman

Jul 29, 1999, 10:34pm
Ahh, sweet, it works . . . I can't believe I overlooked that so many times .
.. .



And thanks for the advice on the Char . . . The program builds much faster
now and the source code is a LITTLE bit smaller : )

-Andon Coleman

roland vilett

Jul 30, 1999, 4:22pm
>Calling AW_AVATAR_ADDRESS changes the value for AW_AVATAR_SESSION . . .

Okay, I still don't quite understand...AW_AVATAR_ADDRESS is just a constant,
you don't call it. Do you mean calling aw_address()? It is true that the
reply to aw_address() uses the attribute AW_AVATAR_SESSION to return the
avatar's session number, but so do many other SDK methods and events...this
is the way the SDK works. The values of the attributes are not designed to
persists across multiple API calls, they are there to communicate data back
and forth between your code and the SDK. If you need to remember a
particular value, such as an avatar's session number, across more than one
call, then you need to store it in a variable and retrieve it later. This
is a fair standard approach to API design...I hope that you don't find it
too limiting!

-Roland

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