// BASIC RING BUTTON // by buttbadger Mirabeau // Usage: When someone touches the doorbell, it rings and the toucher's name will be said in chat. // When the owner touches it, they can ring the bell or choose a Public and Private setting. (Private by default) // Private setting will send the notification in private IM in localchat. Only you can read it. // Public setting will send the notification in localchat, visible for everybody in range. // Like, // This script is open source and free. It can't be resold as it is. You can put it in part of your sales // as long as you keep the script in fullperm. // The title to display above the button. just leave "" if you don't want any string ringpanel = "Touch me to ring"; // The door bell sound. By default it take the first sound available in the prim string bellsound = llGetInventoryName(INVENTORY_SOUND,0); // This is the end of the thing the button will say if someone rings. The name of the clicker will be at the beginning string ringnotice = "is ringing at the door!"; // Set this to TRUE if you want the notice to display for everyone around and not just you integer publicshout = FALSE; // Some other junk integer antispam; key userkey; key owner; list menuitems; integer channel; integer listener; ringing() { llPlaySound(bellsound, 1.0); //llPlaySound(bellsound, 1.0); // Uncomment if sound is not enough loud //llPlaySound(bellsound, 1.0); // Uncomment if sound is not enough loud if (antispam == FALSE) // That way, the button can still ring but it won't spam you with IMs { antispam = TRUE; llSetTimerEvent(60.0); if (publicshout == FALSE) llOwnerSay(Who(userkey) + " " + ringnotice); // It will say "Display Name (user name) is ringing at your door!" by default else llSay(0, "secondlife:///app/agent/" + (string)userkey + "/inspect " + ringnotice); } } default { state_entry() { antispam = FALSE; owner = llGetOwner(); llSetText(ringpanel, <1,1,1>, 1.5); } touch_start(integer total_number) { userkey = llDetectedKey(0); if (userkey != owner) ringing(); else state ownermenu; } timer() // ends the antispam timer { llSetTimerEvent(0.0); antispam = FALSE; } } state ownermenu { state_entry() { if (publicshout == TRUE) menuitems = ["Private","Ring!","CANCEL"]; else menuitems = ["Public","Ring!","CANCEL"]; channel = (integer)llFrand(99999); listener = llListen(channel, "", owner, ""); llDialog(owner, "Doorbell menu\n\nPublic/Private: Choose if you get the notifications in private, or said in local chat.\nRing: Ring the doorbell!", menuitems, channel); llSetTimerEvent(30.0); } listen (integer channel, string n, key i, string m) { if (m == "Public") { publicshout = TRUE; llOwnerSay("Doorbell ringer's name will be sent in public chat."); llSetTimerEvent(0.0); llListenRemove(listener); state default; } else if (m == "Private") { publicshout = FALSE; llOwnerSay("Doorbell ringer's name will be sent as private IM in chat."); llSetTimerEvent(0.0); llListenRemove(listener); state default; } else if (m == "Ring!") { ringing(); llSetTimerEvent(0.0); llListenRemove(listener); state default; } else { llSetTimerEvent(0.0); llListenRemove(listener); state default; } } timer() { llSetTimerEvent(0.0); llListenRemove(listener); state default; } }