Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Listening on multiple channels

Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
01-28-2007 07:34
I remember a thread addressing this, but I can't find it. I need to monitor three channels in a listener. I recall there was a way to do it with a single line then parse out the channels with if statements. Can anyone remember either the thread, or how to do this?

Thanks.

Treat
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-28-2007 08:01
inside the listen event

listen(integer channel, string name, key id, string message)

each varible is passed anytime the object hears something, which you can use to biuld if cluases


CODE

listen(integer channel, string name, key id, string message)
{
if (channel == 127)
{
if (id == llGetOwner())
{
// do some owner only stuff
}
else if (name == "joe avatar")
{
// do some other stuff
}
else llSay("you do not have access");
}

else if (channel == 137)
{
if (id == llGetOwner())
{
// do some owner only stuff
}
else if (name == "joe avatar")
{
// do some other stuff
}
else llSay("you do not have access");
}
}
Treat Rothschild
Registered User
Join date: 27 Apr 2006
Posts: 20
01-28-2007 08:05
Thanks, do I need a llListen in the state_entry?
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-28-2007 08:12
you need to define a listen with llListen yes

if the object is listining all of the time yes in state entry

also i would go ahead and set a chat channel ... since you know how to filter by name key and message now theres not really a reason for mutiple channels ... for mutiple channels you will need to setup a listener on channel 0, or make (X) amount of listeners for each channel ... both are less resource effecient than a single listener filtered out by channel

llListen(127,"",NULL_KEY,"";);