CODE
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)//make dialog easy, pick a channel by itself and destroy it after 5 seconds
{
menu_channel = (integer)(llFrand(99999.0) * -1);//yup a different channel at each use
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(5.0);
}
default
{
touch_start(integer t)
{
menu(llDetectedKey(0),"hello world",["yes","no"]);
}
timer() //so the menu timeout and close its listener
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel) //in case you have others listeners
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
if(message == "yes")
{
//do stuffs
}
else if(message == "no")
{
//do other stuffs
}
}
}
}