Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multi-user script

Skipper Abel
Registered User
Join date: 12 Sep 2006
Posts: 4
11-26-2006 11:41
I have created a script that runs in an object such that when the object is touched it will prompt for a numeric entry from the chat channel, basic stuff. Then depending on the value entered, the script will say a result. This works fine for me, but other avatars, though receiving the initial prompt OK are unable to get the script to respnd to their chat entry! I would be grateful for any suggestions.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
11-26-2006 12:13
Without seeing the actual script it's hard to say. My guess is that you have the listen event set to only listen to you.
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-26-2006 12:37
I second what Vares said.
How are you activating the listen? and When?
I would be inclined to only activate it when touched, keyed only to the toucher.

CODE

integer Listening = 0;


UpdateListen(key id)
{
CancelListen();
// Select a channel.(new channel every time)
integer listenchannel = (integer)llFrand(500) + 100;
Listening = llListen(listenchannel,"",id,"");
llSetTimerEvent(30);
}

CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}

default
{
touch_start(integer total_number)
{
key id = llDetectedKey(0);
// spammy and anyone nearby will see it.
// I'd suggest using a dialog just to make it 'transparent' to others in the area
UpdateListen(id);
llWhisper(0,"Please type your request on channel " + (string)listenchannel);
}

timer()
{
llSay(0,"Listen cancelled.");
CancelListen();
}

listen( integer channel, string name, key id, string message )
{
CancelListen();
// Do what ever it is you want to do.....

}
}


I'd also suggest that if you have only a limited number of responces a dialog driven system would be neater.
Skipper Abel
Registered User
Join date: 12 Sep 2006
Posts: 4
Solution
11-26-2006 12:38
Thanks for the reply, I found the problem I was listening for

llListen(0,"",llGetOwner(), "";);

and should have been listening for

llListen(CHANNEL, "", NULL_KEY, "";);

Thanks for the quick response, your solution certainly has a more elegant approach Newgate
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Bug Fix!!!!!!
11-27-2006 01:56
Noticed that i goofed big time.
The system was telling you which channel to type on and then changing it!!!

Replace the touch event with this code:

CODE

touch_start(integer total_number)
{
key id = llDetectedKey(0);
// spammy and anyone nearby will see it.
// I'd suggest using a dialog just to make it 'transparent' to others in the area
UpdateListen(id);
llWhisper(0,"Please type your request on channel " + (string)listenchannel);
}
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
11-27-2006 07:08
From: Newgate Ludd
I second what Vares said.
How are you activating the listen? and When?
I would be inclined to only activate it when touched, keyed only to the toucher.


Based on what the original poster wrote, it sounds like the script just displays a single result. If it's a single query and a single response, and the message on touch is purely a help message, then there's no need for a "session" and making a multi-user one is easy:

CODE

integer CHANNEL = 20;

init() {
llListen(CHANNEL,"",NULL_KEY,"");
}

default {
state_entry() { init(); }
on_rez(integer junk) { init(); }

touch_start(integer numDetected) {
llSay(0,"Please state your request on channel " + ((string)CHANNEL) + ".");
}

listen(integer channel, string name, key id, string message) {
llSay(0,name + ", your response is " + functionThatDoesTheActualWork(message));
}
}
Raeyan Aldrich
Registered User
Join date: 14 Oct 2006
Posts: 44
11-27-2006 07:35
From: Skipper Abel
Thanks for the reply, I found the problem I was listening for

llListen(0,"",llGetOwner(), "";);

and should have been listening for

llListen(CHANNEL, "", NULL_KEY, "";);

Thanks for the quick response, your solution certainly has a more elegant approach Newgate

actually skipper if you happen to come back and read this... you actually want to set:
CODE

integer listening;


as a global at the beginning of the script, then call

CODE

llListenRemove(listening);
listening = llListen(listenchannel, "", llDetectedKey(0), "");


inside the touch event, then call

CODE

llListenRemove(listening);


inside the listen() event. doing this will greatly improve run time on the script and lead to a lot less lag on the sim's resources... one listener on a script isnt so bad... but 50 of those scripts is terrible :P

this way the script only listens when it's been touched and only listens to the person who touched it. you could also add some kind of timer to the system to remove the listen event after like 10 seconds if it doesnt hear a response. but that's up to you :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-27-2006 09:22
From: Raeyan Aldrich
actually skipper if you happen to come back and read this... you actually want to set:
CODE

integer listening;


as a global at the beginning of the script, then call

CODE

llListenRemove(listening);
listening = llListen(listenchannel, "", llDetectedKey(0), "");


inside the touch event, then call

CODE

llListenRemove(listening);


inside the listen() event. doing this will greatly improve run time on the script and lead to a lot less lag on the sim's resources... one listener on a script isnt so bad... but 50 of those scripts is terrible :P

this way the script only listens when it's been touched and only listens to the person who touched it. you could also add some kind of timer to the system to remove the listen event after like 10 seconds if it doesnt hear a response. but that's up to you :)



If you look at the code I posted thats exactly what it does albeit witha 30 second time out but hey some people are slow typers...