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