Tip Jar - Percentage Paying (optional) Tip Jar

Discuss scripting tips and techniques with other inworld developers. All scripting related discussions are encouraged here.

Tip Jar - Percentage Paying (optional) Tip Jar

Postby Vincent » February 20th, 2013, 15:41:55

Percentage Paying (optional) Tip Jar - Pays the percentage (if chosen) to the founder of the group you set the object to. UNDER CERTAIN CONDITIONS (That you set and agree to) THIS SCRIPT WILL TAKE MONEY FROM YOUR ACCOUNT.

Code: Select all
// Script Name: Percentage_Paying_optional_Tip_Jar.lsl
// Author: Fred Gandt
//Pays the percentage (if chosen) to the founder of the group you set the object to.
//
//UNDER CERTAIN CONDITIONS (That you set and agree to) THIS SCRIPT WILL TAKE MONEY FROM YOUR ACCOUNT.

// This program is free software; you can redistribute it and/or modify it.
// Additional Licenes may apply that prevent you from selling this code
// and these licenses may require you to publish any changes you make on request.
//
// There are literally thousands of hours of work in these scripts. Please respect
// the creators wishes and Copyright law and follow their license requirements.
//
// License information included herein must be included in any script you give out or use.
// Licenses may also be included in the script or comments by the original author, in which case
// the authors license must be followed, and  their licenses override any licenses outlined in this header.
//
// You cannot attach a license to any of these scripts to make any license more or less restrictive.
//
// All scripts by avatar Ferd Frederix, unless stated otherwise in the script, are licensed as Creative Commons By Attribution and Non-Commercial.
// Commercial use is NOT allowed - no resale of my scripts in any form. 
// This means you cannot sell my scripts but you can give them away if they are FREE. 
// Scripts by Ferd Frederix may be sold when included in a new object that actually uses these scripts. Putting my script in a prim and selling it on marketplace does not constitute a build.
// For any reuse or distribution, you must make clear to others the license terms of my works. This is done by leaving headers intact.
// See http://creativecommons.org/licenses/by-nc/3.0/ for more details and the actual license agreement.
// You must leave any author credits and any headers intact in any script you use or publish.
///////////////////////////////////////////////////////////////////////////////////////////////////
// If you don't like these restrictions and licenses, then don't use these scripts.
//////////////////////// ORIGINAL AUTHORS CODE BEGINS ////////////////////////////////////////////

// V1 //
 
key owner;
 
integer debit_perms = FALSE;
 
integer pay_price = 0;
 
list pay_buttons = [20, 50, 100, 250];
 
integer percentage = 50; // Percentage to pay to the founder of the group the object is set to.
 
key beneficiary;
 
string default_message = "/me is very grateful for the generous contribution from ";
 
string beneficiary_message = "% of which has been paid to the founder of ";
 
key group_key;
 
string group_name;
 
Function()
{
    owner = llGetOwner();
    string owner_name = llKey2Name(owner);
    string object_name = (owner_name + "'s Money Box");
    llSetObjectName(object_name);
    llSetPayPrice(pay_price, pay_buttons);
    if(percentage)
    llRequestPermissions(owner, PERMISSION_DEBIT);
}
 
default
{
    on_rez(integer param)
    {
        Function();
    }
    state_entry()
    {
        Function();
    }
    run_time_permissions(integer perms)
    {
        if(perms & PERMISSION_DEBIT)
        {
            debit_perms = TRUE;
            group_key = llList2Key(llGetObjectDetails(llGetKey(), [OBJECT_GROUP]), 0);
            if(group_key != NULL_KEY)
            llHTTPRequest("http://world.secondlife.com/group/" + ((string)group_key), [], "");
        }
        else
        llRequestPermissions(owner, PERMISSION_DEBIT);
    }
    http_response(key q, integer status, list metadata, string body)
    {
        if(status == 200)
        {
            integer name_start = (llSubStringIndex(body, "<title>") + 7);
            integer name_end = (llSubStringIndex(body, "</title>") - 1);
            integer founder_key_start = (llSubStringIndex(body, "founderid") + 20);
            integer founder_key_end = (founder_key_start + 35);
            beneficiary = llGetSubString(body, founder_key_start, founder_key_end);
            group_name = llGetSubString(body, name_start, name_end);
        }
        else
        {
            llHTTPRequest("http://world.secondlife.com/group/" + ((string)group_key), [], "");
        }
    }
    money(key id, integer amount)
    {
        string message = "";
        integer dividend;
        string payer = llKey2Name(id);
        if(!percentage)
        {
            message = (default_message + payer);
        }
        else
        {
            dividend = llFloor((((float)amount)/100.0) * ((float)percentage)); // I'm very tired and my eyes are sticky!
            if(dividend)
            {
                if(debit_perms)
                {
                    message = (default_message + payer + ".\n" + ((string)percentage) + beneficiary_message + group_name);
                    llGiveMoney(beneficiary, dividend);
                }
                else
                {
                    message = (default_message + payer);
                }
            }
        }
        llSay(PUBLIC_CHANNEL, message);
    }
}

Signature:
W̛̲̼͚͖h͎̯͇ͬ̉̓̉ͭ͆aͣ̋̓͠t͋ ̜͔̤̠̻̯̝̅̊͋ͬ̍͢â̶ͧ͊̀r͍̞̯̲͎̣̀̿͌̿̂ͅȇ͒̓̈́̄̋̉҉̜̲ ̡͎̯̲̼̟̂ͅs̱͉͚̼͌o̶͒̎̐͋ͥm̷̦͎ͣ̄̿ė̼̺̰̿ͦ̀ ̖͉̞̝̠ͤͧ̉̾̌̎͗ḡ͖̦̘̜̩͔ͤ͜o͕͈̥̦͖͛̕o̧̪̘̱̼ͨͨ̏̌d̫̫̣̪ ̢̩͈̙̬ͤ͑D̡̖̪̠̖̺͋̌̚u̡̱ͨͮͬ͑̌ͬ̎b̷̘̍̄̆̂̑̅s̳͖̪̉͢ͅt̢̩͈̗͋ͅe̯̭̩̣̗͉ͧ̚͝p͙̼̝̮͕̿̓͋ͫ͐̽ͩ ͇̫̤ͤͩ͐ͩ̋s̶̺̻ȍ̶̻̰͔̫͎̭͎ͥͭ̽ͣn͔̼̩̠̦͇͐g̛̱̫̗̑͗ͥ̂ͣ͗s̳͓̞̠͍̔͆̽!̶͑?̶͖͎
palavas.biz | Palavas

Vincent Sobieski, who goes by the stage name "Vincentgbr", was born in Bulgaria and raised in Great Britain. Vincent grew up with a lot of passion in music which gave him the determination to start his DJ course at Point Blank London at the age of 21. He received training from Ben Bristow, at which he succeeded in the course and obtained his DJ certificate.

After gaining 6 years DJ experience, "Vincent" recently got involved with TribalDanceFR and is a weekly resident DJ for them at Club ORBILUX.

"Vincent" has also received offers to play in various Clubs in France, these include Le Balajo, La Java, La Palace, Les Etoiles, etc.

At the beginning of 2009, he started to pursue his interest in producing music. In collaboration with professional producer and friend (Sam Hunwicke), he made his 1st track called (…) and shortly after, 2nd track "DJs The Beat".
He is also looking forward to making his own album in 2012, which promises to be really interesting. He is almost certainly going to be very busy for the future....




[+/-] Copyright
User avatar
Vincent
Palavas VIP
Palavas VIP
Posts: 235
 




Return to Scripting



Who is online

Users browsing this forum: No registered users and 2 guests

cron