User:Fox Diller/EventRequests

From Second Life Wiki
< User:Fox Diller
Revision as of 05:59, 4 May 2007 by Fox Diller (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
// Crystal Studio Request Script
// Version 1.0
//
// Use this at your own risk.
// Desc: You can use this to have a request system inside a club that it might be hard to get requests from end-users.

// User Modifiable Settings:\

// Change this to the channel you want to listen too.
// If you change it to '0', the script will not run!
// This is used to keep this script lag free.
integer CHAN_NUM                    = 69;

// Change this to the name of your event.
string EVENT_NAME                   = "Graveyard Shift";

// You could change this to another language if needed, or something different. Ex: "Questions."
string REQ_NAME                     = "Requests";

// BEGIN CODE
// Warning: Do not change anything below this line unless you know absolutely what you are doing!!!! omgz

// DEFINE
integer LISTEN_OFFLINE;
integer LISTEN_ONLINE;
integer REQ_AMM;
// DONE.

// Custom Functions
setText(integer TEXT_STATE)
{
    if (TEXT_STATE) llSetText( 
        EVENT_NAME + " " + 
        REQ_NAME +
        " - ON\n---------------------------------------------\n" +
        "Please type: \"/" + (string)CHAN_NUM +
        " [" + llToLower(REQ_NAME) + "] to send a " + llToLower(REQ_NAME), <0,1,0>, 1.0);
    if (!TEXT_STATE) llSetText(EVENT_NAME + " " + REQ_NAME + " - OFF", <1,0,0>, 1.0);
}

default
{
    state_entry()
    {
        llOwnerSay("Request System Startup... Please click on me to turn the request machine on.");  
    }

    touch_start(integer total_number)
    {
        state on;
    }
}

state on
{
    state_entry()
    {
        if (CHAN_NUM) LISTEN_ONLINE = llListen(CHAN_NUM, "", "", "");
        else
        {
             llOwnerSay("Fatal Error: CHAN_NUM is set to 0! SCRIPT RUNTIME ERROR");
            llSetScriptState(llGetScriptName(), FALSE);
        }
        setText(1);
    }
    
    touch_start(integer total_number)
    {
        llListenRemove(LISTEN_ONLINE);
        llInstantMessage(llGetOwner(), "You have recieved " + (string)REQ_AMM + " " + REQ_NAME);
        state off;
    }
    
    listen(integer LISTEN_CHAN, string LISTEN_NAME, key LISTEN_ID, string LISTEN_MSG)
    {
        llInstantMessage(llGetOwner(), LISTEN_NAME + " " + REQ_NAME + ": " + LISTEN_MSG);
        llInstantMessage(LISTEN_ID, EVENT_NAME + " thanks you for your " + REQ_NAME);
        REQ_AMM++;
        setText(1); 
    }
}

state off
{
    state_entry()
    {
        LISTEN_OFFLINE = llListen(CHAN_NUM, "", "", "");
        REQ_AMM = 0;
        setText(0);
    }
    
    touch_start(integer total_number)
    {
        llListenRemove(LISTEN_OFFLINE);
        state on;
    }
    
    listen(integer LISTEN_CHAN, string LISTEN_NAME, key LISTEN_ID, string LISTEN_MSG)
    {
        llInstantMessage(LISTEN_ID, REQ_NAME + " are not being taken at this time. Sorry.");
    }
}