Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: 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
Original Thread
03-06-2006 22:03
/15/ed/91806/1.html
_____________________
i've got nothing. ;)
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-07-2006 03:55
You made a typo
CODE

key GOVERNOR_LINDEN = "3d6181b0-6a4b-97ef-18d8-722652995cf1";

should be
CODE

key GOVERNOR_LINDEN = "1c0192ca-4095-4e18-83f2-b3fd6e217c89";



Honest. *smiles*.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-07-2006 04:04
There's a cunning name check in it as well...

Bravo, Ushuaia! An excellent service for the crusading ultra-capitalists of Second Life! Too long have they been shamed by being unwillingly branded "welfare recipients", you know, like poor people.

Really, though, to complete the process you should charge for this. It's a bit socialist otherwise isn't it?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
03-07-2006 04:20
I have to agree Ordinal; giving this script away is the wrong thing to do. It should be a pay service, where the user has to pay you to dispose of the L$.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-07-2006 04:50
From: Strife Onizuka
I have to agree Ordinal; giving this script away is the wrong thing to do. It should be a pay service, where the user has to pay you to dispose of the L$.


In true capatalistic style I'll undercut any offers and dispose of as many lindens as you want for just $1L. Send them to me, I'll take out my feee and make the rest go away.
Persephone Phoenix
loving laptopvideo2go.com
Join date: 5 Nov 2004
Posts: 1,012
Hah!
03-07-2006 05:03
Way to make me read the Scripting Tips forum. Most amusing. Now if only there were a rl equivalent where folks could send back their corporate welfare, I'd be a happy happy gurl.
_____________________
Events are everyone's business.
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
03-08-2006 09:12
From: Nepenthes Ixchel
In true capatalistic style I'll undercut any offers and dispose of as many lindens as you want for just $1L. Send them to me, I'll take out my feee and make the rest go away.

In true capitalistic style, I will offer you N-1 dollars for the privilege of disposing of N of your dollars! It's a loss leader model ;)
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
03-08-2006 10:39
From: Ordinal Malaprop

Really, though, to complete the process you should charge for this. It's a bit socialist otherwise isn't it?


We could just wait for some enterprising capitalist to offer it for sale at their bargain store. ;)

Until then, this script is now avaialable for L$1 at my Luna Oaks kiosk.
Cocoanut Cookie
Registered User
Join date: 26 Jan 2006
Posts: 1,741
03-08-2006 13:22
Does this send the money to Governor Linden?

coco
_____________________
Aliasi Stonebender
Return of Catbread
Join date: 30 Jan 2005
Posts: 1,858
03-08-2006 14:59
From: Cocoanut Cookie
Does this send the money to Governor Linden?

coco


Yes. The name-check converts the key to a name, to ensure that someone isn't being witty and sticking their own name in.
_____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-08-2006 15:04
Unless they change both. But hey - that would be the Free Market at work! Or something.
Aliasi Stonebender
Return of Catbread
Join date: 30 Jan 2005
Posts: 1,858
03-08-2006 15:36
From: Ordinal Malaprop
Unless they change both. But hey - that would be the Free Market at work! Or something.


Someone who uses a non-mod version of this script pretty much gets what's coming to them, in my eyes. :p
_____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff