Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Off the Dole

Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
03-05-2006 10:45
CODE

// Off The Dole - Return Unwanted Welfare Payments
//
// Do you clamor in the forums for economic reform but still collect "welfare" every week?
// It's time for you to do your part to strengthen the Second Life economy.
// Now you can automatically send unsolicited L$ back to Governor Linden every Tuesday!
//
// Place this script in the contents of an in-world prim.
// Right-click and "Pay..." to make a one time payment
// Left-click to configure an automatic weekly payment

// constant - governor linden's key
key GOVERNOR_LINDEN = "3d6181b0-6a4b-97ef-18d8-722652995cf1";

// constant - how often we check to see if it's time to pay the stipend back (in seconds)
float FREQUENCY = 3600.0;

// variable - listener handle
integer listener;

// variable - how much we'll pay to governor linden each week
integer stipend_amount;

// variable - keep track of the last time we paid the weekly stipend back
string last_paid;

// variable - total amount paid
integer total;

setStipend() {
listener = llListen(-987234, "", llGetOwner(), "");

llDialog(llGetOwner(), "Choose the amount of your stipend.\nCurrently set to: L$" + (string)stipend_amount, ["50", "500", "Disable"], -987234);

// set the timer event so we only listen for one minute before closing our listener
llSetTimerEvent(60.0);
}

cleanUp() {
// remove the listener
llListenRemove(listener);

listener = FALSE;

// set the timer back to once per hour if we have a stipend defined
if (stipend_amount) {
llSetTimerEvent(FREQUENCY);
} else {
llSetTimerEvent(0.0);
}
}

sendMoney(integer amount) {
llGiveMoney(GOVERNOR_LINDEN, amount);

total += amount;

setText();
}

setText() {
string text;

if (stipend_amount) text = "Automatically returning L$" + (string)stipend_amount + " to Governor Linden every week!\n";

text = text + "Total returned: L$" + (string)total;

llSetText(text, <1.0, 1.0, 1.0>, 1.0);
}

default {
on_rez(integer start) {
llResetScript();
}

state_entry() {
llSetText("", ZERO_VECTOR, 0.0);

// set the fast pay buttons
llSetPayPrice(PAY_DEFAULT, [50, 500, PAY_HIDE, PAY_HIDE]);

// check to see if debit permission is already granted by the current owner
if (llGetPermissions() & PERMISSION_DEBIT && llGetPermissionsKey() == llGetOwner()) {
state accept_payments;
} else {
llRequestAgentData(GOVERNOR_LINDEN, DATA_NAME);
}
}

touch_start(integer touches) {
if (llDetectedKey(0) == llGetOwner()) llResetScript();
}

dataserver(key query, string data) {
// request debit permissions only if the payment key is set to governor linden
if (data == "Governor Linden") {
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
} else {
llOwnerSay("Payment key is not set to Governor Linden's key!");
}
}

run_time_permissions(integer permission) {
// we can now accept payments if debit permissions were granted
if (permission & PERMISSION_DEBIT) {
// reset stipend amount and last paid time for new user
stipend_amount = 0;

last_paid = "";

total = 0;

llSetObjectName("Off the Dole");

llSetObjectDesc("Right-click and \"Pay..\" at any time - Left-click to set weekly stipend amount");

state accept_payments;
} else {
llOwnerSay("Debit permission must be granted!");
}
}
}

state accept_payments {
on_rez(integer start) {
state default;
}

state_entry() {
setText();

if (stipend_amount) {
// set the timer to once per hour if we have a stipend defined
llSetTimerEvent(FREQUENCY);
} else {
// prompt user to set their stipend amount if not already defined
setStipend();
}
}

touch_start(integer touches) {
if (llDetectedKey(0) == llGetOwner()) setStipend();
}

listen(integer channel, string name, key id, string message) {
stipend_amount = (integer)message;

cleanUp();

setText();
}

money(key id, integer amount) {
sendMoney(amount);
}

timer() {
// time out the listener if the user doesn't choose a stipend amount in 60 seconds
if (listener) {
llOwnerSay("Timed out. Touch to set your stipend amount.");

cleanUp();
}

if (!stipend_amount) return;

// parse out the timestamp down to the hour
list timestamp = llParseString2List(llGetTimestamp(), ["-" , "T", ":"], []);

integer year = llList2Integer(timestamp, 0);
integer month = llList2Integer(timestamp, 1);
integer day = llList2Integer(timestamp, 2);
integer hour = llList2Integer(timestamp, 3);

// since stipends are handing out early tuesday morning so we'll send it back on tuesday after 20:00 GMT
if (hour < 20) return;

// day of week function by gabriel spinnaker
integer a = (14 - month) / 12;
integer y = year - a;
integer m = month + (12 * a) - 2;
integer d = (day + y + (y / 4) - (y / 100) + (y / 400) + ((31 * m) / 12)) % 7;

if (d != 2) return;

// test to see if we've already paid back the stipend today
string test = (string)month + "-" + (string)day + "-" + (string)year;

if (test == last_paid) return;

last_paid = test;

sendMoney(stipend_amount);

llInstantMessage(llGetOwner(), "You paid your stipend of L$" + (string)stipend_amount + " back to Governor Linden on " + last_paid + ".");
}

state_exit() {
llSetTimerEvent(0.0);
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
03-06-2006 22:03
/54/57/92073/1.html
_____________________
i've got nothing. ;)
Snakekiss Noir
japanese designer
Join date: 9 Dec 2003
Posts: 334
money tree
03-15-2006 12:52
A MUCH better idea is to sponsor a money tree and help other people with your 'unwanted' lindens
_____________________
Whatever happened to Important Basic Feature Improvements including improving the outdated 5 year old AV Body Appearance system to Poser standard?

What happened to the 'see for miles' graphical visions we were shown of Havok Engine? Instead we got moral crusades to please American businesses.

OPPOSE LOCAL TAXES ON VIRTUAL WORLDS !!

THE BRAVE NEW WORLD HAS BECOME A BIG NEW SHOP