Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Tip jar with profit share

Asuna Kaligawa
SCC Security Officer
Join date: 20 Sep 2008
Posts: 15
09-26-2008 08:24
Me again...miss dummy/cheap......I am trying to get a Tip jar/donation box script that allows profit sharing with possibly 5-6 Av's. The ones I have found seem a bit overpriced.....Is any one willing to Lend a hand? I have the following tip jar script. Can it be modified for my desire and keep the hovertext where it shows how much is in there + who donated last and the amount they donated? The script IS NOT MINE Credit goes to the scripter Angel Fluffy + angel's given credits


CODE

// CARP Donation box script. Written by Angel Fluffy, with credit to :
// Keknehv Psaltery, jean cook, ama omega, nada epoch, YadNi Monde
// for their work on the "DONATION box" script upon which it was based.

string imtext = "I'm the Dancer's Donation Box! Please right click and pay me to donate, as this supports the __________ project and helps keep the place open for you!";
// this is the text sent to someone who clicks on the prim containing this script and who isn't the owner.

// first line of hover text above box (always constant)
string floaty = "__________ Donation Box\n";

// when total donated this month is less than monthlyneeded, display whatfunding_1 as the funding target,
// when it is more, display whatfunding_2. This allows you to show your donors when you have switched
// from funding your essential running costs to funding expansion.
string whatfunding_1 = "Funding : __________ \n";
string whatfunding_2 = "Funding : __________ \n";

// name of the current month
// we *could* get this automatically, but changing the month automatically isn't as easy as it seems.
// This is a change I might make in a future version.
string thismonth = "October";

// How much are we trying to raise per month?
// The script displays a countdown in SETTEXT above the prim its in, counting down until this target is reached.
// After this target is reached, the countdown disappears, being replaced with a tally.
// The goal of this is to encourage people to donate by setting a clear goal they feel they can help achieve by donating.
integer monthlyneeded = 30000;


// These two variables define the starting numbers for how much has been donated across all time, and how much this month.
// These starting numbers will have the donations the script recieves in between each reset/save added to it,
// and the result displayed in float text over the top of the script.
// The first time you start accepting donations, you should set both of the numbers below to zero.
// When saving this script, you (the object owner) should touch the donation box object,
// which will then tell you how much has been donated in total and how much has been donated this month.
// Entering this information here before saving will allow you to preserve the 'state' of the script across edits/restarts.
integer totaldonated = 0;
integer monthdonated = 0;

// these settings are like the above, but save the 'last donor' information. You can set them to "" and 0 to clear saved info.
string lastdonor = "Taffy Tinlegs";
integer lastdonated = 0;

// this interval defines how long we wait between each reminder to donate broadcast to SAY (range=20m)
integer timer_interval = 3600;

// these settings determine what the 'default' donation amounts are.
// the buttons are the 'fast pay' buttons, the 'payfield' is the default amount in the text box.
list paybuttons = [50,200,400,800];
integer payfield = 100;


// these variables should be left undefined.
string owner;
string otext;
integer mpercent;

integer updatemath() {
float mpercentfloat = ((monthdonated * 100) / monthlyneeded);
mpercent = (integer)mpercentfloat;

return 1;
}

integer updatetext() {
otext = floaty;

if (mpercent >= 100) {
otext += whatfunding_2;
} else {
otext += whatfunding_1;
}
if (lastdonated > 0) {
otext += "Last donation : L$" + (string)lastdonated + " by " + lastdonor +"\n";
}
if (mpercent >= 100) {
otext += "We have raised L$"+(string)(monthdonated - monthlyneeded)+" for this, beyond our basic running costs of L$"+(string)monthlyneeded+" for "+thismonth+". \n";
//otext += "The excess will go towards giving prizes and running special events!";
} else {
otext += "Our donors have contributed "+(string)mpercent+"% of our basic running costs ("+(string)monthdonated+"/"+(string)monthlyneeded+") for "+thismonth+".\n";
}
llSetText(otext,<1,1,1>,1);
return 1;
}
default
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
updatemath();
updatetext();
owner = llKey2Name( llGetOwner() );
llSetPayPrice(payfield,paybuttons);
llSetTimerEvent(timer_interval);
llSay(0,"Script updated. Usually this is caused by the donation box owner updating the script.");
}

money(key id, integer amount)
{
totaldonated += amount;
monthdonated += amount;
lastdonor = llKey2Name(id);
lastdonated = amount;
updatemath();
updatetext();
llInstantMessage(id,"On behalf of everyone who uses this place, thank you for the donation!");
llSay(0,(string)llKey2Name(id)+" donated L$" + (string)amount + ". Thank you very much for supporting us, it is much appreciated!" );
}
touch_start(integer num_detected){
if (llDetectedKey(0) == llGetOwner()) {
llOwnerSay("Reporting script status, because you are recognised as the owner of this donation box.");
llOwnerSay("Current TOTAL donations across all time: L$"+(string)totaldonated);
llOwnerSay("Current TOTAL donations for this month: L$"+(string)monthdonated);
} else {
llInstantMessage(llDetectedKey(0),imtext);
}
}
timer() {
integer premainder = 100 - mpercent;
integer aremainder = monthlyneeded - monthdonated;
if (mpercent < 100) {
llSay(0,"We still need to meet the last "+(string)premainder+"% of our basic costs (L$"+(string)aremainder+") this month, to pay for land tier etc. Please consider donating to help us out!");
}
llSetTimerEvent(timer_interval);
}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
I think I got it.
09-27-2008 10:22
I've tweaked the script to split up the tips among the avatars who's names are in list "SplitWith". Each name gets a predefined percentage of the tip as set in list "SplitPercent".

The keys belonging to the names, used for llGiveMoney(), need to be in the database at "w-hat.com" for the tipjar to work.

Here it is:
CODE

// lists for names, keys of avatar to split the money with and percentages of split.
list SplitWith = ["Ron Khondji","Joe Kuramoto"]; // ["name","name","name"]
list SplitPercent = [0.7,0.3]; // [float,float,float] make sure it adds up to 1.0

list SplitKey; // list with keys belonging to names, looked up on "w-hat.com"
integer length; // number of items in lists
integer count; // index#
key name_query; // dataserver query for avatar name to check avatar key.
integer flag = TRUE; // used to stop script on problem with lists.

// CARP Donation box script. Written by Angel Fluffy, with credit to :
// Keknehv Psaltery, jean cook, ama omega, nada epoch, YadNi Monde
// for their work on the "DONATION box" script upon which it was based.

string imtext = "I'm the Dancer's Donation Box! Please right click and pay me to donate, as this supports the __________ project and helps keep the place open for you!";
// this is the text sent to someone who clicks on the prim containing this script and who isn't the owner.

// first line of hover text above box (always constant)
string floaty = "__________ Donation Box\n";

// when total donated this month is less than monthlyneeded, display whatfunding_1 as the funding target,
// when it is more, display whatfunding_2. This allows you to show your donors when you have switched
// from funding your essential running costs to funding expansion.
string whatfunding_1 = "Funding : __________ \n";
string whatfunding_2 = "Funding : __________ \n";

// name of the current month
// we *could* get this automatically, but changing the month automatically isn't as easy as it seems.
// This is a change I might make in a future version.
string thismonth = "October";

// How much are we trying to raise per month?
// The script displays a countdown in SETTEXT above the prim its in, counting down until this target is reached.
// After this target is reached, the countdown disappears, being replaced with a tally.
// The goal of this is to encourage people to donate by setting a clear goal they feel they can help achieve by donating.
integer monthlyneeded = 30000;

// These two variables define the starting numbers for how much has been donated across all time, and how much this month.
// These starting numbers will have the donations the script recieves in between each reset/save added to it,
// and the result displayed in float text over the top of the script.
// The first time you start accepting donations, you should set both of the numbers below to zero.
// When saving this script, you (the object owner) should touch the donation box object,
// which will then tell you how much has been donated in total and how much has been donated this month.
// Entering this information here before saving will allow you to preserve the 'state' of the script across edits/restarts.
integer totaldonated = 0;
integer monthdonated = 0;

// these settings are like the above, but save the 'last donor' information. You can set them to "" and 0 to clear saved info.
string lastdonor = "Taffy Tinlegs";
integer lastdonated = 0;

// this interval defines how long we wait between each reminder to donate broadcast to SAY (range=20m)
integer timer_interval = 3600;

// these settings determine what the 'default' donation amounts are.
// the buttons are the 'fast pay' buttons, the 'payfield' is the default amount in the text box.
list paybuttons = [50,200,400,800];
integer payfield = 100;

// these variables should be left undefined.
string owner;
string otext;
integer mpercent;

integer updatemath() {
float mpercentfloat = ((monthdonated * 100) / monthlyneeded);
mpercent = (integer)mpercentfloat;

return 1;
}

integer updatetext() {
otext = floaty;

if (mpercent >= 100) {
otext += whatfunding_2;
} else {
otext += whatfunding_1;
}
if (lastdonated > 0) {
otext += "Last donation : L$" + (string)lastdonated + " by " + lastdonor +"\n";
}
if (mpercent >= 100) {
otext += "We have raised L$"+(string)(monthdonated - monthlyneeded)+" for this, beyond our basic running costs of L$"+(string)monthlyneeded+" for "+thismonth+". \n";
//otext += "The excess will go towards giving prizes and running special events!";
} else {
otext += "Our donors have contributed "+(string)mpercent+"% of our basic running costs ("+(string)monthdonated+"/"+(string)monthlyneeded+") for "+thismonth+".\n";
}
llSetText(otext,<1,1,1>,1);
return 1;
}

default
{
state_entry()
{
llSetText("TipJar not active. \nTouch to activate.",<.984, .686, .365>,.8);
if(flag) llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}

run_time_permissions (integer perm)
{
if (perm == PERMISSION_DEBIT) state init;
else llOwnerSay("I need those permissions. Please touch me to try again.");
}

touch_start(integer num_detected){
if (llDetectedKey(0) == llGetOwner()) llResetScript();
else llSay(0,"Only the owner can activate me.");
}

on_rez( integer sparam )
{
llResetScript();
}
}

state init
{
state_entry()
{
llSetText("Initialising....",<.984, .686, .365>,1.0);
flag = TRUE;
length = llGetListLength(SplitWith);
// get avatar keys from webserver at w-hat.com
count = 0; // index# of SplitWith
key Key = llHTTPRequest("http://w-hat.com/name2key?terse=1&name=" + llEscapeURL(llList2String(SplitWith, count)), [], "");
}


http_response(key id, integer status, list metadata, string body) // get avatar keys
{
if (status == 200){
SplitKey += (list)body;
++count;
if (count < length){
key Key = llHTTPRequest("http://w-hat.com/name2key?terse=1&name=" + llEscapeURL(llList2String(SplitWith, count)), [], "");
} else { // check lists on data integrity
if (length != llGetListLength(SplitPercent)){ // check if lists are same length
llOwnerSay("Please check the lists. Each name needs a split percentage.");
flag = FALSE;
} else { // check if sum of percentages is 100% and if there's no NULL_KEY in list
float sum;
integer i;
for (i=0; i<length; ++i){
sum += llList2Float(SplitPercent,i);
if (llList2Key(SplitKey,i) == NULL_KEY){
llOwnerSay(llList2String(SplitWith,i) + "'s key is not in the database at 'w-hat.com'. \nAborting!");
flag = FALSE;
}
}
if (sum != 1){
llOwnerSay("Please check the lists. The percentages do not add up to 100%.");
flag = FALSE;
}
}
if (flag){ // check if found keys belong to respective names
count = 0;
llSetTimerEvent(30);
name_query = llRequestAgentData(llList2Key(SplitKey,count), DATA_NAME);
} else state default;
}
} else {
llOwnerSay("Website for Name2Key is down.\nAborting!");
flag = FALSE;
state default;
}
}

dataserver(key queryid, string data)
{
if (name_query == queryid) { // request agent data to check Name2Key
if (data != llList2String(SplitWith,count)){
llOwnerSay(llList2String(SplitWith,count) + "'s key does not match with name!");
flag = FALSE;
} else if (count < length){
++count;
name_query = llRequestAgentData(llList2Key(SplitKey,count), DATA_NAME);
}
if (flag && count == length) {
llSetTimerEvent(0);
state active; // everything checks out activate tipjar
}
}
}

timer()
{
llSetTimerEvent(0);
llOwnerSay("Something went wrong with the dataserver while looking up '" + llList2String(SplitWith,count) + "' and key '" + llList2String(SplitKey,count) + "' . \nAborting!");
flag = FALSE;
state default;
}

on_rez( integer sparam )
{
llResetScript();
}
}

state active
{
state_entry()
{
updatemath();
updatetext();
owner = llKey2Name( llGetOwner() );
llSetPayPrice(payfield,paybuttons);
llSetTimerEvent(timer_interval);
llSay(0,"Script updated. Usually this is caused by the donation box owner updating the script.");
}

money(key id, integer amount)
{
totaldonated += amount;
monthdonated += amount;
lastdonor = llKey2Name(id);
lastdonated = amount;
updatemath();
updatetext();
llInstantMessage(id,"On behalf of everyone who uses this place, thank you for the donation!");
llSay(0,(string)llKey2Name(id)+" donated L$" + (string)amount + ". Thank you very much for supporting us, it is much appreciated!" );
// split amount among avatars in list
integer i;
for (i=0; i<length; ++i){
llGiveMoney(llList2Key(SplitKey,i), llFloor(amount * llList2Float(SplitPercent,i)));
}


}

touch_start(integer num_detected){
if (llDetectedKey(0) == llGetOwner()) {
llOwnerSay("Reporting script status, because you are recognised as the owner of this donation box.");
llOwnerSay("Current TOTAL donations across all time: L$"+(string)totaldonated);
llOwnerSay("Current TOTAL donations for this month: L$"+(string)monthdonated);
} else {
llInstantMessage(llDetectedKey(0),imtext);
}
}

timer() {
integer premainder = 100 - mpercent;
integer aremainder = monthlyneeded - monthdonated;
if (mpercent < 100) {
llSay(0,"We still need to meet the last "+(string)premainder+"% of our basic costs (L$"+(string)aremainder+") this month, to pay for land tier etc. Please consider donating to help us out!");
}
llSetTimerEvent(timer_interval);
}

on_rez( integer sparam )
{
llResetScript();
}
}


If you testrun it without changing the lists, I get your money, so thank you in advance :)

Use the 'quote' button to copy with indentations.
Asuna Kaligawa
SCC Security Officer
Join date: 20 Sep 2008
Posts: 15
09-29-2008 11:19
Oh my...THANK YOU!