Sunday, 17 October 2010

COUNTDOWN SCRIPT - Second Life®

// Specify time and date in UTC

string Date = "2011.06.21"; // YYYY.MM.DD
string Time = "00:00:01"; // hh:mm:ss

string  TEXT     = "The end of the world will come in"; // Additional text defining the event
string  FINISHED = "uh oh..."; // Text displayed when event happened
vector  COLOR = <1,1,1>;     // Color of the displayed text 


string myGMTTime;
integer SECONDS;

countdown()
{
    llSetText(TEXT+"\n"+(string)(SECONDS/86400)+" days, "
        +(string)((SECONDS%86400)/3600)+" hours, "
        +(string)(((SECONDS%86400)%3600)/60)+" minutes, "
        +(string)(((SECONDS%86400)%3600)%60)+ "seconds.",COLOR,1);
}



default
{
    state_entry()
    {
        myGMTTime = Date +"."+Time;
        string toUnix = "http://www.iwebtool.com/tool/tools/unix_time_converter/unix_time_converter.php?year="
        + llGetSubString(myGMTTime,0,3) + "&mon=" + llGetSubString(myGMTTime,5,6) + "&day="
        + llGetSubString(myGMTTime,8,9) + "&hour=" + llGetSubString(myGMTTime,11,12) + "&min="
        + llGetSubString(myGMTTime,14,15) + "&sec=" + llGetSubString(myGMTTime,17,18);
        SECONDS = llGetUnixTime();
        llHTTPRequest(toUnix,[HTTP_METHOD,"GET"],"");
    }


    http_response(key request_id,integer status, list metadata, string body)
    {
        body = llGetSubString(body, 50, -9);
        SECONDS = (integer)body + 18000 - (2 * llGetUnixTime()) + SECONDS;
        llSetTimerEvent(1);
    }

    timer()
    {
        if (SECONDS > 0)
        {
            SECONDS = SECONDS - 1;
            countdown();
        }
        else
        {
            llSetText(FINISHED, COLOR,1);
            llSetTimerEvent(0);
        }
    }

}
do not forget your donation

CANDLE FIRE ON/OFF SCRIPT - Second Life®

// V1 //

integer on; // Establish "on" as a global variable so that we can remember whether or not the flame is on.

Flame(integer num)
{
    if(num) // Do we or don't we make a flame? Num is either TRUE or FALSE (1 or 0).
    {
        llParticleSystem([PSYS_PART_FLAGS, 275, // Make the flame since the condition above was met.
        PSYS_SRC_PATTERN, 4,
        PSYS_PART_START_ALPHA, 0.6,
        PSYS_PART_END_ALPHA, 0.0,
        PSYS_PART_START_COLOR, <1.0, 1.0, 0.3>,
        PSYS_PART_END_COLOR, <0.8, 0.6, 0.6>,
        PSYS_PART_START_SCALE, <0.04, 0.07, 0.0>,
        PSYS_PART_END_SCALE, <0.04, 0.04, 0.0>,
        PSYS_PART_MAX_AGE, 0.3,
        PSYS_SRC_MAX_AGE, 0.0,
        PSYS_SRC_ACCEL, <0.0, 0.0, 0.02>, // These are the parameters of the particle effect.
        PSYS_SRC_ANGLE_BEGIN, 0.0,
        PSYS_SRC_ANGLE_END, 0.0,
        PSYS_SRC_BURST_PART_COUNT, 50,
        PSYS_SRC_BURST_RATE, 0.07,
        PSYS_SRC_BURST_RADIUS, 0.0,
        PSYS_SRC_BURST_SPEED_MIN, 0.001,
        PSYS_SRC_BURST_SPEED_MAX, 0.4,
        PSYS_SRC_OMEGA, <0.0, 0.0, 0.0>,
        PSYS_SRC_TARGET_KEY,(key)"",
        PSYS_SRC_TEXTURE, ""]);
        llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0, 0.8, 0.3>, 0.5, 2.0, 1.9,  // For extra effect we switch the light on too.
                              PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.1, // And set the transparency to slightly visible.
                              PRIM_GLOW, ALL_SIDES, 0.1]); // And the glow to slight.
    }
    else // Num was not 1 (TRUE) so we need to stop the effect or not start it.
    {
        llParticleSystem([]); // Make no particles (no flame).
        llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0,  // Switch the light off.
                              PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.0, // And set the transparency to invisible.
                              PRIM_GLOW, ALL_SIDES, 0.0]); // And the glow to zero.
    }
    on = num; // Establish the value of the global variable "on" as being equal to the task we just performed. This acts as our memory.
}

default // Create a state for the code to run in.
{
    state_entry() // On entering that state make the candle flame ignite.
    {
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0,1.0,0.0>, 0.0, ZERO_VECTOR, <0.0,1.0,0.0>, // Make the prim a sphere.
                              PRIM_SIZE, <0.01,0.01,0.03>, // Make the prim the right size to act as the glowing center of the flame.
                              PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0]); // Set the blank texture.
        Flame(TRUE); // Flame(TRUE); Is an order to run the code "Flame" with the integer value "TRUE" (numerical value = 1).
    }
    touch_end(integer detected) // Detect if we have touched the candle.
    {
        Flame(!on); // We now order that the Flame() code is run with the integer value that is the oposite of what it already is.
        // (!on) = FALSE if on = TRUE and TRUE if on = FALSE. The "!" means "not".
    }
}

do not forget your donation

ONLINE STATUS SCRIPT - Second Life®

//   This program is free software: you can redistribute it and/or modify                     //
//    it under the terms of the GNU General Public License as published by                    //
//    the Free Software Foundation, either version 3 of the License, or                       //
//    (at your option) any later version.                                                     //
//                                                                                            //
//    Online Indicator is distributed in the hope that it will be useful,                     //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of                          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                           //
//    GNU General Public License for more details.                                            //
//                                                                                            //
//    To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.    //
////////////////////////////////////////////////////////////////////////////////////////////////

key user_key = "7acaa529-a131-4084-8f1c-94369467c668";       // must be agent UUID whose status it will indicate
integer time = 30;                                           // time within the message should be written.
string url = "http://world.secondlife.com/resident/";
key blank = TEXTURE_BLANK;
string name;
key toucher;
string status;

// VD 2009-11-24 workaround for WEB-1383, use <meta> instead of <img>
// VD 2009-11-25 try <img> if meta tag gets removed in the future
string profile_key_prefix = "<meta name=\"imageid\" content=\"";
string profile_img_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/";
integer profile_key_prefix_length; // calculated from profile_key_prefix in state_entry()
integer profile_img_prefix_length; // calculated from profile_img_prefix in state_entry()

//string profile_key_prefix = "<meta name=\"imageid\" content=\"";
//integer s1l;

default
{
    state_entry()
    {
        profile_key_prefix_length = llStringLength(profile_key_prefix);
        profile_img_prefix_length = llStringLength(profile_img_prefix);
        llSetText("", <1,0,0>, 1.0);
        llSetTexture(blank, ALL_SIDES);
        llRequestAgentData( user_key, DATA_NAME);  
    }
    dataserver(key queryid, string data)
    {
        name = data;
        llSetObjectName(name + "'s Online Detector");
        state show;
    }
}
state show
{  
    state_entry()
    {
        llSetTimerEvent(10);
    }
    timer()
    {
        llHTTPRequest( url + (string)user_key,[HTTP_METHOD,"GET"],"");
        llRequestAgentData( user_key, DATA_ONLINE);  
    }
    on_rez(integer start_param)
    {
        llSetText("", <1,0,0>, 1.0);
        llSetTexture(blank, ALL_SIDES);
    }
    http_response(key request_id,integer status, list metadata, string body)
    {
        string profile_pic;
        integer s1 = llSubStringIndex(body, profile_key_prefix);
        integer s1l = profile_key_prefix_length;
        if(s1 == -1)
        { // second try
            s1 = llSubStringIndex(body, profile_img_prefix);
            s1l = profile_img_prefix_length;
        }

        if (s1 == -1)
        { // still no match?
            profile_pic = blank;
        }
        else
        {
            profile_pic = llGetSubString(body,s1 + s1l, s1 + s1l + 35);
            if (profile_pic == (string)NULL_KEY)
            {
                profile_pic = blank;
            }
        }
        llSetTexture(profile_pic, ALL_SIDES);
    }
    dataserver(key queryid, string data)
    {
        if ( data == "1" )
        {
            status = " is online";

            llSetText(name + status, <0,1,0>, 1.0);
        }
        else if (data == "0")
        {
            status = " is offline";

            llSetText(name + status, <1,0,0>, 1.0);
        }

    }
    touch_start(integer num_detected)
    {
        toucher = llDetectedKey(0);
        state msg;
    }
}
state msg
{
    state_entry()
    {
        llListen(0,"",toucher,"");
        llInstantMessage(toucher, "write your message to " + name +" - you have " +(string)time + " seconds");
        llInstantMessage(toucher, "to see " + name +"'s profile, click this link here: secondlife:///app/agent/" + (string)user_key + "/about");
        llSetTimerEvent(time);  
    }
    listen(integer ch, string name, key id, string msg)
    {
        llInstantMessage(user_key, llKey2Name(toucher) + " sent you a message from " + llGetRegionName() + ": " + msg);
        llInstantMessage(toucher, "message is sent.");
        llListenRemove(0);
        state show;
    }
    timer()
    {
        llInstantMessage(toucher, "time is up - touch again to write a message");
        llListenRemove(0);
        state show;
    }
}

do not forget your donation

COMISSION SCRIPT - Second Life®

// enter here the Price of the Object
integer price=79;
// enter here the Product wich a People will get after Paying Object
string product="Male Skin TGA Files";
// enter here the persons Key wich will get the Money
key partner ="5bf4a61e-347e-49b8-b4f8-c2949d6f484f";
// enter here the Hovering Text wich will be Displayed
string DISPLAYTEXT="Pay me to get the object";
// enter here the Percent wich your Partner will get
integer cpercent = 50;


integer commission;
integer payment;
/////////////////////
//    CONSTANTS    //
/////////////////////
integer PERMST=FALSE;

default
{
    state_entry()
    {
        llSetText("", <255.0,255.0,64.0>, 1);
        llGetOwner();
        llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        if(PERMST==TRUE){
        state run;}
        llSetTimerEvent(5.0);
    }
   
    touch_start(integer total_number)
    {
        llInstantMessage(llGetOwner(),llDetectedKey(0));
        if(llGetOwner() == llDetectedKey(0)){
        if(PERMST==FALSE){ 
        state perms;
        } else {state run;}}
    }
   
    timer()
    {
     if(PERMST==FALSE){ 
        state perms;
        } else {state run;}  
    }
}

state run
{
    state_entry()
    {
    llSetText(DISPLAYTEXT, <255.0,255.0,64.0>, 1);
    llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
   
    money(key payer, integer amount)
    {
        if (amount == price)
        {  
        commission = (amount * cpercent) / 100;
        payment = amount - commission;
        llGiveMoney(partner, payment);
        llInstantMessage(payer,"Thanks for your Purchase! you should receive your Item in a few seconds");
        llGiveInventory(payer,product);
        }        
       
       
        if (amount < price)
        {
            llInstantMessage(payer, "I'm sorry, but that is not enough for the item.");
            llGiveMoney(payer, amount);
        }
       
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_DEBIT)
        { 
        }
        else
        {
            llOwnerSay("Sorry, you must click [Yes] in order for this to work. Reset Display now.");
            state black_hole;
        }
    }
}

state perms {
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); 
        PERMST=TRUE;
        state default;
    }  
   
}
state black_hole
{
    state_entry()
    {
        llResetScript();
    }
}




do not forget yout donation