LlRequestMoney

From Second Life Wiki

Second Life Wiki > LlRequestMoney
Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/fr Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ja Template:Needs Translation/LSL/ko Template:Needs Translation/LSL/nl Template:Needs Translation/LSL/hu Template:Needs Translation/LSL/no Template:Needs Translation/LSL/da Template:Needs Translation/LSL/sv Template:Needs Translation/LSL/tr Template:Needs Translation/LSL/pl Template:Needs Translation/LSL/pt Template:Needs Translation/LSL/ru Template:Needs Translation/LSL/uk Template:Needs Translation/LSL/zh-Hans Template:Needs Translation/LSL/zh-Hant

Image:Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Contents

Summary

Function: llRequestMoney( key source, key destination, integer amount, string message );
REQUEST Function ID
0.0 Delay
0.0 Energy

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

 
// 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 
    }
}
 

Tip-Jar Alternative

 
// 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");
        }
    }
}
 

Deep Notes

Personal tools
In other languages