llRequestMoney

From Second Life Wiki
Jump to navigation Jump to search
Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Summary

Function: llRequestMoney( key source, key destination, integer amount, string message );

Sends a request to agent source that they give L$ amount to agent destination, possibly for the reason specified in message The resulting notification should also indicate which object and agent that initiated request

• key source The Resident who the money is being requested from
• key destination The intended recipient of the money
• integer amount number of L$, must be greater than zero
• string message Useful for indicating why the money is being requested

Examples

Donationware

<lsl> // Free content vendor with donation request // The vendor can be placed around the grid // The vendor doesn't have to be owned by the creator string content = "Free Shirt"; key creator = "83b3987f-9520-4275-8efe-3ac13dd3f635"; default {

   touch_start(integer touched)
   {
       llGiveInventory(llDetectedKey(0),content);   // Give the Resident the free content
       llRequestMoney(llDetectedKey(0),creator,50,"To support future content"); // Request the Resident donate L$50 
   }

} </lsl>

Tip-Jar Alternative

<lsl> // Chat based donation script // Can be used as an alternative to tip jars integer chan = 0; // Yes, I'm aware channel 0 listeners are bad integer hand; key http; integer donation; string regarding; integer func__filter(key source,string message) {

   if(llStringTrim(message,STRING_TRIM) != "")
   {
       list foo = llParseString2List(message, [" "], []);
       if(
         llGetListLength(foo) >= 7 &&
         llList2String(foo,0) == "Donate" &&
         llGetSubString(llList2String(foo,1),0,1) == "L$"
         llList2String(foo,2) == "to" &&
         llList2String(foo,5) == "for"
       ){
           amount = llGetSubString(llList2String(foo,1),2,-1);
           if((string)((integer)amount) == amount)
           {
               donation = amount;
               regarding = llDumpList2String(llDeleteSubList(foo,0,5)," ");
               http = llHTTPRequest(
                 "http://w-hat.com/name2key?name=" +
                 llDumpList2String(
                   [
                     llList2String(foo,3),
                     llList2String(foo,4)
                   ]
                   ,"%20") +
                 "&terse=1",[],"");
           }
           else
           {
               return FALSE; // amount is not an integer
           }
       }
       else
       {
           return FALSE // Minimum number of arguments not met, or not donation command
       }
   }
   else
   {
       return FALSE; // string is empty
   }

} default {

   state_entry()
   {
       hand = llListen(chan,"",llGetOwner(),"");
   }
   listen(integer channel,string name,key id,string message)
   {
       func__filter(id,message);
   }
   http_response(key query,integer status,list meta,string response)
   {
       if(s == 200 && response != NULL_KEY && llStringLength(response) == 36 && query == http) // query will likely always be http, hence why it is last in the argument list
       {
           llRequestMoney(llGetOwner(),response,donation,regarding);
       }
       else
       {
           llOwnerSay("Could not donate funds");
       }
   }

}

</lsl>

Deep Notes

Signature

//function void llRequestMoney( key source, key destination, integer amount, string message );