Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Tip Jar Percentage_Paying_optional_Tip_Jar  

Percentage_Paying_optional_Tip_Jar

This work uses content from the Second Life® Wiki article Viewer Architecture. Copyright © 2007-2009 Linden Research, Inc. Licensed under the Creative Commons Attribution-Share Alike 3.0 Licens

Category: Tip Jar
By : Fred Gandt
Created: 2011-01-02 Edited: 2011-01-02
Worlds: Second Life

the Zip file

Download all files for Percentage_Paying_optional_Tip_Jar
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Percentage_Paying_optional_Tip_Jar_1.lsl
1 // V1 //
2
3 key owner;
4
5 integer debit_perms = FALSE;
6
7 integer pay_price = 0;
8
9 list pay_buttons = [20, 50, 100, 250];
10
11 integer percentage = 50; // Percentage to pay to the founder of the group the object is set to.
12
13 key beneficiary;
14
15 string default_message = "/me is very grateful for the generous contribution from ";
16
17 string beneficiary_message = "% of which has been paid to the founder of ";
18
19 key group_key;
20
21 string group_name;
22
23 Function()
24 {
25 owner = llGetOwner();
26 string owner_name = llKey2Name(owner);
27 string object_name = (owner_name + "'s Money Box");
28 llSetObjectName(object_name);
29 llSetPayPrice(pay_price, pay_buttons);
30 if(percentage)
32 }
33
34 default
35 {
36 on_rez(integer param)
37 {
38 Function();
39 }
41 {
42 Function();
43 }
45 {
46 if(perms & PERMISSION_DEBIT)
47 {
48 debit_perms = TRUE;
50 if(group_key != NULL_KEY)
51 llHTTPRequest("http://world.secondlife.com/group/" + ((string)group_key), [], "");
52 }
53 else
55 }
56 http_response(key q, integer status, list metadata, string body)
57 {
58 if(status == 200)
59 {
60 integer name_start = (llSubStringIndex(body, "<title>") + 7);
61 integer name_end = (llSubStringIndex(body, "</title>") - 1);
62 integer founder_key_start = (llSubStringIndex(body, "founderid") + 20);
63 integer founder_key_end = (founder_key_start + 35);
64 beneficiary = llGetSubString(body, founder_key_start, founder_key_end);
65 group_name = llGetSubString(body, name_start, name_end);
66 }
67 else
68 {
69 llHTTPRequest("http://world.secondlife.com/group/" + ((string)group_key), [], "");
70 }
71 }
72 money(key id, integer amount)
73 {
74 string message = "";
75 integer dividend;
76 string payer = llKey2Name(id);
77 if(!percentage)
78 {
79 message = (default_message + payer);
80 }
81 else
82 {
83 dividend = llFloor((((float)amount)/100.0) * ((float)percentage)); // I'm very tired and my eyes are sticky!
84 if(dividend)
85 {
86 if(debit_perms)
87 {
88 message = (default_message + payer + ".\n" + ((string)percentage) + beneficiary_message + group_name);
89 llGiveMoney(beneficiary, dividend);
90 }
91 else
92 {
93 message = (default_message + payer);
94 }
95 }
96 }
97 llSay(PUBLIC_CHANNEL, message);
98 }
99 }

Back to the Best Free Tools in Second Life and OpenSim.