Donation box (goal and progress)

Thread Started By steadymobbin

2730
1
  • 36 Vote(s) - 3.17 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
PHP Code:
string imtext "I'm the __________ 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_rezinteger sparam )
    {
        
llResetScript();
    }
    
state_entry()
    {
        
updatemath();
        
updatetext();
        
owner llKey2NamellGetOwner() );
        
llSetPayPrice(payfield,paybuttons);
        
llSetTimerEvent(timer_interval);
        
llSay(0,"Script updated. Usually this is caused by the donation box owner updating the script.");
    }

    
money(key idinteger 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);
    }
// END // 
[Image: guns-bullet-shirt_recreated.jpg]
Reply


#2
Hi steadymobbin,
Is it possible to make those fields that should be configured by the owner in the config nc or something like that, not to mess with script. Some ppl are lame with scripts, but i'm sure you already know that :)

thank you,
Pero
Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  Charity Donation Box Script - YoungMoney 0 3,245 03-01-2013, 01:00 PM
Last Post: YoungMoney
  Donation Script 1.0.0 steadymobbin 0 2,100 02-18-2013, 02:03 AM
Last Post: steadymobbin

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...