Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

bartender script, but need help to fix a problem

Doning Yalin
Registered User
Join date: 30 Apr 2007
Posts: 22
08-27-2007 21:37
I have got a free scirpt, used it to delivery freebies to members, it works well from start, but do not work after some time, how to fix the problem?

Many thanks in advance for any help.

The script is as following:

list items = ["A","B","C","D","E","F","G","H","I"];
list items2 = ["A1","A2","A3","A4","A5","A6","A7","A8","A9","Main Menu"];
list items3 = ["B1","B2","B3","B4","B5","B6","B7","B8","B9","Main Menu"];
list items4 = ["C1","C2","C3","C4","C5","C6","C7","C8","C9","Main Menu"];
list items5 = ["D1","D2","D3","D4","D5","D6","D7","D8","D9","Main Menu"];
list items6 = ["E1","E2","E3","E4","E5","E6","E7","E8","E9","Main Menu"];
list items7 = ["F1","F2","F3","F4","F5","F6","F7","F8","F9","Main Menu"];
list items8 = ["G1","G2","G3","G4","G5","G6","G7","G8","G9","Main Menu"];
list items9 = ["H1","H2","H3","H4","H5","H6","H7","H8","H9","Main Menu"];
list items10 = ["I1","I2","I3","I4","I5","I6","I7","I8","I9","Main Menu"];
key user;
integer channel = 100;



default
{
state_entry()
{

}

touch_start(integer total_number)
{
user = llDetectedKey(0);
llDialog(user,"Select Categories:",items,channel);
llListen(channel,llKey2Name(user),user,"";);
}
listen(integer channel,string name, key id,string message)
{
if(id==user)
{

if(message=="Information";)
{
llGiveInventory(user,"Automated Item Info";);
}
if(message=="Main Menu";)
{
llDialog(user,"Item Categories",items,channel);
return;
}
if(message=="A";)
{
llDialog(user,"Item Menu: A",items2,channel);
return;
}
if(message=="B";)
{
llDialog(user,"Item Menu: B",items3,channel);
return;
}
if(message=="C";)
{
llDialog(user,"Item Menu: C",items4,channel);
return;
}
if(message=="D";)
{
llDialog(user,"Item Menu: D",items5,channel);
return;
}
if(message=="E";)
{
llDialog(user,"Item Menu: E",items6,channel);
return;
}
if(message=="F";)
{
llDialog(user,"Item Menu: F",items7,channel);
return;
}
if(message=="G";)
{
llDialog(user,"Item Menu: G",items8,channel);
return;
}
if(message=="H";)
{
llDialog(user,"Item Menu: H",items9,channel);
return;
}
if(message=="I";)
{
llDialog(user,"Item Menu: I",items10,channel);
return;
}
else
{
llGiveInventory(user,message);
}
}
}
}
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
08-27-2007 21:55
Looks like You are running out of listen "handles". Each script is allowed a maximum of 64 handles without releasing any, so your script will start failing after 64 clicks.

Here's a fix for that:

CODE

list items = ["A","B","C","D","E","F","G","H","I"];
list items2 = ["A1","A2","A3","A4","A5","A6","A7","A8","A9","Main Menu"];
list items3 = ["B1","B2","B3","B4","B5","B6","B7","B8","B9","Main Menu"];
list items4 = ["C1","C2","C3","C4","C5","C6","C7","C8","C9","Main Menu"];
list items5 = ["D1","D2","D3","D4","D5","D6","D7","D8","D9","Main Menu"];
list items6 = ["E1","E2","E3","E4","E5","E6","E7","E8","E9","Main Menu"];
list items7 = ["F1","F2","F3","F4","F5","F6","F7","F8","F9","Main Menu"];
list items8 = ["G1","G2","G3","G4","G5","G6","G7","G8","G9","Main Menu"];
list items9 = ["H1","H2","H3","H4","H5","H6","H7","H8","H9","Main Menu"];
list items10 = ["I1","I2","I3","I4","I5","I6","I7","I8","I9","Main Menu"];
key user;
integer channel = 100;
integer listen_handle = 0; // ADDED FOR LISTEN FIX


default
{
state_entry()
{

}

touch_start(integer total_number)
{
user = llDetectedKey(0);
llListenRemove(listen_handle); // ADDED FOR LISTEN FIX
llDialog(user,"Select Categories:",items,channel);
listen_handle = llListen(channel,llKey2Name(user),user,""); // ADDED FOR LISTEN FIX
}
listen(integer channel,string name, key id,string message)
{
if(id==user)
{
if(message=="Information")
{
llGiveInventory(user,"Automated Item Info");
}
if(message=="Main Menu")
{
llDialog(user,"Item Categories",items,channel);
return;
}
if(message=="A")
{
llDialog(user,"Item Menu: A",items2,channel);
return;
}
if(message=="B")
{
llDialog(user,"Item Menu: B",items3,channel);
return;
}
if(message=="C")
{
llDialog(user,"Item Menu: C",items4,channel);
return;
}
if(message=="D")
{
llDialog(user,"Item Menu: D",items5,channel);
return;
}
if(message=="E")
{
llDialog(user,"Item Menu: E",items6,channel);
return;
}
if(message=="F")
{
llDialog(user,"Item Menu: F",items7,channel);
return;
}
if(message=="G")
{
llDialog(user,"Item Menu: G",items8,channel);
return;
}
if(message=="H")
{
llDialog(user,"Item Menu: H",items9,channel);
return;
}
if(message=="I")
{
llDialog(user,"Item Menu: I",items10,channel);
return;
}
else
{
llGiveInventory(user,message);
}
}
}
}

I added three lines, labeled "// ADDED FOR LISTEN FIX"
Zermes Granville
Registered User
Join date: 6 Apr 2006
Posts: 17
08-27-2007 21:56
Insert a Timer to reset the script after a certain amount of time

in the state_entry()

add

llSetTimerEvent(300); *or the amount of time you desire*

after the listen event, add

timer()
{
llResetScript();
}
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
08-27-2007 22:19
No offense, but while such an approach may work for a while, it is not a certain cure - if more than 64 clicks come in before the reset, it will again fail until the reset. And since the bug is easily fixed, I cannot recommend the timer approach... It does not *guarantee* that the bug is fixed, only that it is periodically remedied. Meanwhile, the script accumulates more and more unneeded Listen handles, reducing sim performance.
Doning Yalin
Registered User
Join date: 30 Apr 2007
Posts: 22
08-27-2007 23:07
thank you all very much, Boss, it run well now .
thank you any way, Zermes