Introduction

I have seen this script on marketplace. I have made a free version of it. It is very simple, it allows an in-world prim to make payments on your behalf based on a schedule written in a notecard residing in the same prim as this script.

Setup

  • Create a notecard called Timed Payments (the name is important) and configure your scheduled payments. For example, if you would want to pay Morgan LeFay, having the key cb2c07d7-4cf3-6f5e-b026-1218d4c534e8 the sum of L200 on the date 2011-08-19, your notecard would contain only one line:
Morgan LeFay#cb2c07d7-4cf3-6f5e-b026-1218d4c534e8#2011-08-19#200

where the first filed before the hash represents the name of the avatar to be paid, the second field after the hash represents the key of that avatar, the third field represents the date (in format: YYYY-MM-DD) when this payment will occur and the fourth field "200" represents the number of linden dollars which will be sent. You can list as many lines for as many avatars as you want. I have also modified the key so that people who copy paste without reading will not pay me anything.

  • After you are done writing this notecard, drop it in a prim along with the script below and the payments should start on the very same day.

Script Configuration

The script takes two parameters in the CONFIGURATION section:

  • CUSTOM_PAYMENT_MESSAGE is a message that will be sent to the avatar to be paid prior to sending the money. There are a number of tokens you can use when customising this string: %n% will be replaced at runtime with the name of the person to be paid, %m% will be replaced at runtime with the name of your avatar and %d% will be replaced at runtime with the date when the payment is made.
  • REOCURRING_PAYMENTS this setting will make the script pay the amount of money you have configured on every single day of the month you have configured in the notecard. For example, if your notecard looks like this:
Morgan LeFay#cb2c07d7-4cf3-6f5e-b026-1218d4c534e8#2011-08-19#200

then every 19th of August, the script will pay Morgan LeFay the sum of L200.

Code

scheduled_payments.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                   CONFIGURATION                      //
//////////////////////////////////////////////////////////
//                                                      //
// A string that represents the message that will get
// to the receiver of the payment. The tokens in the 
// strings are special: %n% will get replaced with the
// receiver's name, %m% will get replaced with the 
// owner of this script and %d% will be replaced with 
// the date when this script will run.
string CUSTOM_PAYMENT_MESSAGE = "Hello, %n%! I am was scheduled on %d% to send you money on behalf of %m%. Please standby for payment...";
// Set this to 1 to make this script every month on the 
// day specified in the "Timed Payments" notecard. For 
// example if you have 2011-12-26 as date in the notecard
// then if you set REOCURRING_PAYMENTS to 1, the script 
// will make a payment every month on the 26th.
integer REOCURRING_PAYMENTS = 1;
//                                                      //
//                  END CONFIGURATION                   //
//////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
//                              INTERNALS                                //
///////////////////////////////////////////////////////////////////////////
 
key pQuery = NULL_KEY;
integer pLine = 0;
list payLog = [];
list payList = [];
integer nRun = 0;
 
string tokenSubstitute(string input, key id) {
    list kSubst = llParseString2List(input, ["%"], [""]);
    integer itra;
    for(itra=0; itra<llGetListLength(kSubst); ++itra) {
        if(llList2String(kSubst, itra) == "n") kSubst = llListReplaceList(kSubst, (list)llKey2Name(id), itra, itra);
        if(llList2String(kSubst, itra) == "m") kSubst = llListReplaceList(kSubst, (list)llKey2Name(llGetOwner()), itra, itra);
        if(llList2String(kSubst, itra) == "d") kSubst = llListReplaceList(kSubst, (list)llGetDate(), itra, itra);
    }
    return llDumpList2String(kSubst, " ");
}
 
init() {
    payList = [];
    integer itra;
    for(itra=0, pLine=0; itra<llGetInventoryNumber(INVENTORY_NOTECARD); ++itra) {
        if(llGetInventoryName(INVENTORY_NOTECARD, itra) == "Timed Payments")
            jump found_payments;
    }
    return;
@found_payments;
    pQuery = llGetNotecardLine("Timed Payments", pLine);
    llSetTimerEvent(1.0);    
}
 
default
{
    state_entry() {
        init();
    }
 
    on_rez(integer num) {
        init();
    }
 
    timer() {
        if(nRun) {
            llSetTimerEvent(.0);
            state pay;
        }
        llSetTimerEvent(1.0);
    }
 
    dataserver(key id,string data) {
        if(id != pQuery) return;
        if(data == EOF) {
            ++nRun;
            return;
        }
        if(data == "") jump next_line;
        payList += data;
@next_line;
        pQuery = llGetNotecardLine("Timed Payments", ++pLine);
    }
}
 
state pay
{
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
 
    changed(integer change) {
        if(change & CHANGED_INVENTORY)
            llResetScript();
    }
 
    run_time_permissions(integer perm) {
        if(perm & PERMISSION_DEBIT) {
            llOwnerSay("Processing payments for today...");
            llSetTimerEvent(5.0);
        }
    }
 
    touch_start(integer num) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer itra;
        for(itra=0; itra<llGetListLength(payLog); ++itra) {
            llOwnerSay(llList2String(payLog, itra));
        }
    }
 
    timer() {
        llSetTimerEvent(.0);
        integer itra;
        for(itra=0; itra<llGetListLength(payList); ++itra) {
            list pays = llParseString2List(llList2String(payList, itra), ["#"], [""]);
            if(llList2String(pays, 2) != llGetDate() && !REOCURRING_PAYMENTS)
                jump next_payment;
            if(REOCURRING_PAYMENTS && llList2String(llParseString2List(llGetDate(), ["-"], [""]), 1) != llList2String(llParseString2List(llList2String(pays, 2), ["-"], [""]), 1))
                jump next_payment;
            if(llKey2Name(llList2String(pays, 1)) != llList2String(pays,0))
                jump next_payment;
            if(llList2Integer(pays, 3) < 1)
                jump next_payment; 
            llInstantMessage(llList2Key(pays, 1), tokenSubstitute(CUSTOM_PAYMENT_MESSAGE, llList2Key(pays,1)));
            llGiveMoney(llList2Key(pays, 1), llList2Integer(pays, 3));
            payLog += (list)("I paid: l$" + llList2String(pays, 3) + " on " + llGetDate() + " to " + llList2String(pays, 0));
@next_payment;
        }
        llOwnerSay("All payments for " + llGetDate() + " completed. Going to sleep.");
        llSetTimerEvent(86400.0);
    }
}

secondlife/scheduled_payments.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.