Song Requests

From Second Life Wiki
Jump to: navigation, search

Created by Kira Komarov.

Here is a simple script I have seen on marketplace selling for a few thousand lindens for which I wanted to create a free counterpart. This script is used by DJs to pipeline song requests made by their listeners. When the listeners touch the prim, they are instructed how to make a song request with a dedication and once they send it, the script stores that information along with their avatar names. Once the DJ (the owner of the script) touches the prim, the script sends the DJ the list of song requests.

//////////////////////////////////////////////////////////
// [K] Kira Komarov - 2011, License: GPLv3              //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.              //
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
// ------------------- CONFIGURATION ------------------ //
// You can change this to a channel your listeners will use. 
integer DEDICATION_CHANNEL = 98;
 
//////////////////////////////////////////////////////////
// --------------------- INTERNALS -------------------- //
list requests = [];
 
default
{
 
    touch_start(integer total_number)
    {
        if(llDetectedKey(0) != llGetOwner())
            jump user;
        if(llGetListLength(requests) == 0) {
            llOwnerSay("No dedications are currently lined up.");
            return;
        }
        llOwnerSay("----------------- BEGIN REQUESTS ------------------");
        integer itra;
        for(itra=0; itra<llGetListLength(requests); itra+=3) {
            llOwnerSay(llList2String(requests, itra) + " requested the song: " + llList2String(requests, itra+1));
            llOwnerSay("With the dedication: " + llList2String(requests, itra+2));
            if(itra+3<llGetListLength(requests)-1)
                llOwnerSay("-------------------------------------------------------");
        }
        llOwnerSay("------------------ END REQUESTS -------------------");
        return;
@user;
        integer comHandle = llListen(DEDICATION_CHANNEL, "", llDetectedKey(0), "");
        llInstantMessage(llDetectedKey(0), "To request the song \"That's Life - Frank Sinatra\" with the dedication \"For my friend Lydia, I love you!\", you would type into the main chat:\n\n/" + (string)DEDICATION_CHANNEL + " That's life - Frank Sinatra%For my friend Lydia, I love you!\n\nThe forward-slash and the number after the slash are important.");
    }
 
    listen( integer channel, string name, key id, string message )
    {
        if(channel != DEDICATION_CHANNEL) return;
 
        requests +=  (list)name + llList2List(llParseString2List(message, ["%"], [""]), 0, 0) + llList2List(llParseString2List(message, ["%"], [""]), 1, 1);
        llInstantMessage(id, "Thank you! Your dedication has been stored and will be played at the DJ's convenience.");
    }
}

You can use this as part of a bigger build for your set. The script works independently and must be placed in a separate prim. However, that separate prim can be part of a linked set without a problem. Enjoy!