Thread

VB SDK : Multiple instances stealing trigger events .. Please help (Sdk)

VB SDK : Multiple instances stealing trigger events .. Please help // Sdk

1  |  

tacoguy

Feb 15, 2002, 12:03am
Hello all

I am using MrGrimm OCX (Thanks !) to make a bot to extend chat range
in my world. I am a somewhat experienced VB programmer but am an AWSDK
novice. I would appreciate any help and thanks in advance !

I am instantizing 3 bots (which works fine) using this code for each :

*************

sdk.AwInit AW_BUILD
sdk.AwCreate Universe, Port
sdk.EnableDefaultEvents
sdk.AwLoginApplication = Application
sdk.AwLoginOwner = Cit
sdk.AwLoginPrivilegePassword = Pass
sdk.AwLoginName = BotName1

***************

I am also calling a timer for each bot :

timAwWait1.Interval = 1000
timAwWait1.Enabled = True

**************

In the timer sub (1 for each of the 3 instances) I am using (latest
itteration) :

Private Sub timAwWait1_Timer()

sdk.AwWait 0
sdk.AwEventSet AW_EVENT_CHAT
sdk.AwStateChange

End Sub

**************

What happens is when bot1 logs in, it receives chat events but when
bot2 logs in, bot2 receives the events and bot1 loses them. Same when
bot3 logs in ... both bot1 and bot2 have lost events.

I have looked everywhere to try to resolve this (including hours of
scanning this newsgroup) and just cant find it.

Any help would be most appreciated :-)

Best as always
Taco

joeman

Feb 15, 2002, 12:06am
Why is the event set and state change in the timer? You only need to call
them once..

-Joe

[View Quote]

tacoguy

Feb 15, 2002, 12:27am
Hi Joe

I don't know ... I have tried everything I can think of ( I first had
just one event set and state change on form load and that did not work
so I got desperate I guess :) The joys of being a newbie !

Also each instance has a different number ... timer1 is bot 1 and
timer2 is bot 2 etc

Thanks
Taco



[View Quote] >Why is the event set and state change in the timer? You only need to call
>them once..
>
>-Joe

grimble

Feb 15, 2002, 4:04am
A couple of things here tacoguy ...

One's already been covered (chat event handler and avatar state change) and
you should remove them from the timer event. If the bot's just standing in
one spot, a single AwStateChange after a successful AwEnter will suffice and
the chat event is already installed. I do appreciate the things you try when
its going against you.

Now ... I am assuming a little here, but instantiation of bots with the VB
SDK is done by loading another AwSdkOcx control and I can't see that from
your example code here. It looks like you're using a single control, which
means, unfortunately, that the control is throwing away the instance created
by the first bot when you create the second (or maybe on the AwInit). What
you need is three AwSdkOcx controls - either in a control array or
individually named as is your preference - and you use each separately.

For example:

awSDK(1).AwCreate Universe, Port
awSDK(1).EnableDefaultEvents
awSDK(1).AwLoginApplication = Application
etc...

awSDK(1).AwCreate Universe, Port
awSDK(1).EnableDefaultEvents
awSDK(1).AwLoginApplication = Application
etc..

awSDK(3).AwCreate Universe, Port
awSDK(3).EnableDefaultEvents
awSDK(3).AwLoginApplication = Application
etc.

The AwInit call can be made to any of the controls but only once to one of
them because this is an SDK level method and not an instance level method
(consider it as a single SDK DLL fronted by the multiple controls). The same
goes for the AwTerm. This is certainly something that you SHOULDN'T do for
each bot and the SDK help could be a lot clearer on the multiple instances
side of things for newcomers. Right now I couldn't tell you if the AwWait is
SDK or instance level - its been a while. Also, some of the events and/or
callbacks, once turned on/off apply to ALL bot instances (which can be
confusing when you're not aware of it). Again, I can't remember off the top
of my head which they are - sorry - and I can't find it in the SDK help
either.

If you're already doing what I mention above with the three controls and the
AwInit placement etc., you can e-mail me if you like and we'll hit it with a
sledgehammer or something.

Cheers,

Grims.


[View Quote]

grimble

Feb 15, 2002, 4:06am
Yeah Yeah Yeah ... ok, so I mean awSDK(1), awSDK(2) and awSDK(3), rather
then awSDK(1), awSDK(1), and awSDK(3).

Sorry about that.


[View Quote]

kah

Feb 15, 2002, 12:07pm
not sure how instancing works in VB, my way is just to set up an array of
SDK objects and use the Index var supplyed by the events to know which bot
it was (works perfectly fine for me)

KAH

[View Quote]

tacoguy

Feb 16, 2002, 12:16am
Hello all !

Thanks so very much Grimble for your assistance !

While I was unable to get mutiple OCX to work on a single form ...
that was the clue I needed so badly!

What I ended up doing was making MDI child pages and placing the AW
wrapper OCX on each form.

I would have liked to do this on one form but I kept getting errors
even if I tried a control array or renaming the 3 controls. The array
kept giving compile errors while the renaming of the 3 controls would
log in but not return events.

I am sure as I recover from this massive headache that there is a much
more elegant solution.

Thanks for getting me pointed in the right direction ... I am so
appreciative !

Best as Always
Tacoguy

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