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 TipJarClub  

TipJarClub

TipJarClub lets members of a group claim a tipjar and share tips. It will time out and remove people who do not touch it

Category: Tip Jar
By : Encog Dod
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for TipJarClub
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. TipJarClub_1.lsl
1
2 // Notecard Format:
3 // Name of notecard must be Config
4 // Line one - Pay price, comma delimited
5 // Line 2: Percent to pay to tip claimer
6 // Line 3: timeout, in seconds
7 // Line 4: 'group' if you want groups enabled, so that only members of the group can claim the jar,
8
9 // From the book:
10 //
11 // Scripting Recipes for Second Life
12 // by Jeff Heaton (Encog Dod in SL)
13 // ISBN: 160439000
14 X// Copyright 2007 by Heaton Research, Inc.
15 //
16 // This script may be freely copied and modified so long as this header
17 // remains unmodified.
18 //
19 // For more information about this book visit the following web site:
20 //
21 // http://www.heatonresearch.com/articles/series/22/
22
23 integer CHANNEL = 56;
24 integer total;
25 key claimed_key = NULL_KEY;
26 string claimed_name;
27 integer index;
28 key query;
29 float percent;
30 integer check_group = FALSE;
31 integer timeout = 0;
32
33 generalParticleEmitterOn()
34 {
37 //| PSYS_PART_BOUNCE_MASK //Bounce on object's z-axis
38 //| PSYS_PART_WIND_MASK //Particles are moved by wind
39 | PSYS_PART_INTERP_COLOR_MASK //Colors fade from start to end
40 | PSYS_PART_INTERP_SCALE_MASK //Scale fades from beginning to end
41 | PSYS_PART_FOLLOW_SRC_MASK //Particles follow the emitter
42 //| PSYS_PART_FOLLOW_VELOCITY_MASK//Particles are created at the velocity of the emitter
43 //| PSYS_PART_TARGET_POS_MASK //Particles follow the target
44 | PSYS_PART_EMISSIVE_MASK //Particles will glow
45 //| PSYS_PART_TARGET_LINEAR_MASK//Undocumented--Sends particles in straight line?
46 ,
47
48 //PSYS_SRC_TARGET_KEY , NULL_KEY,//The particles will head towards the specified key
49 //Select one of the following for a pattern:
50 //PSYS_SRC_PATTERN_DROP Particles start at emitter with no velocity
51 //PSYS_SRC_PATTERN_EXPLODE Particles explode from the emitter
52 //PSYS_SRC_PATTERN_ANGLE Particles are emitted in a 2-D angle
53 //PSYS_SRC_PATTERN_ANGLE_CONE Particles are emitted in a 3-D cone
54 //PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY Particles are emitted everywhere except for a 3-D cone
55
57
58 ,PSYS_SRC_TEXTURE, "" //UUID of the desired particle texture, or inventory name
59 ,PSYS_SRC_MAX_AGE, 0.0 //Time, in seconds, for particles to be emitted. 0 = forever
60 ,PSYS_PART_MAX_AGE, 10.0 //Lifetime, in seconds, that a particle lasts
61 ,PSYS_SRC_BURST_RATE, 1.0 //How long, in seconds, between each emission
62 ,PSYS_SRC_BURST_PART_COUNT, 1 //Number of particles per emission
63 ,PSYS_SRC_BURST_RADIUS, 10.0 //Radius of emission
64 ,PSYS_SRC_BURST_SPEED_MIN, 0.001 //Minimum speed of an emitted particle
65 ,PSYS_SRC_BURST_SPEED_MAX, 0.001 //Maximum speed of an emitted particle
66 ,PSYS_SRC_ACCEL, <0,0,0> //Acceleration of particles each second
67 ,PSYS_PART_START_COLOR, <1,1,1> //Starting RGB color
68 ,PSYS_PART_END_COLOR, <1,1,1> //Ending RGB color, if INTERP_COLOR_MASK is on
69 ,PSYS_PART_START_ALPHA, 1.0 //Starting transparency, 1 is opaque, 0 is transparent.
70 ,PSYS_PART_END_ALPHA, 1.0 //Ending transparency
71 ,PSYS_PART_START_SCALE, <.25,.25,.25> //Starting particle size
72 ,PSYS_PART_END_SCALE, <.25,.25,.25> //Ending particle size, if INTERP_SCALE_MASK is on
73 ,PSYS_SRC_ANGLE_BEGIN, 1.54 //Inner angle for ANGLE patterns
74 ,PSYS_SRC_ANGLE_END, 1.55 //Outer angle for ANGLE patterns
75 ,PSYS_SRC_OMEGA, <0.0,0.0,0.0> //Rotation of ANGLE patterns, similar to llTargetOmega()
76 ]);
77 }
78
79 generalParticleEmitterOff()
80 {
82 }
83
84 updateText()
85 {
86 string str;
87
88 if( claimed_key==NULL_KEY )
89 str = "Touch to Claim Tip Jar\n";
90 else
91 str = claimed_name + "'s Tip Jar\n";
92
93 if( total>0 )
94 str+= (string)total + " donated so far.";
95 else
96 str+= "Empty";
97
98 llSetText(str, <0,1,0>, 1);
99 }
100
101 default
102 {
104 {
106 }
107
109 {
111 }
112
113 run_time_permissions (integer perm)
114 {
115 if(perm & PERMISSION_DEBIT)
116 {
117 state unclaimed;
118 }
119 }
120 }
121
122
123 state unclaimed
124 {
126 {
127 if( claimed_key!=NULL_KEY )
128 {
129 llSay(0,"Tip jar switching back to unclaimed.");
130 }
131 index = 0;
132 query = llGetNotecardLine("Config",index++);
133 claimed_key = NULL_KEY;
134 claimed_name = "";
135 total = 0;
136 updateText();
137 }
138
139 touch_start(integer count)
140 {
141 integer success = FALSE;
142
143 if( check_group )
144 {
146 {
147 success = TRUE;
148 }
149 else
150 {
151 llSay(0,"Sorry, you are not in the correct group to claim this jar.");
152 }
153 }
154 else success = TRUE;
155
156
157 if( success )
158 {
159 claimed_key = llDetectedKey(0);
160 claimed_name = llDetectedName(0);
161 llInstantMessage(claimed_key,"You have claimed the tip Jar, touch again to uncliam.");
162 llInstantMessage(claimed_key,"You will get " + (string)(percent*100) + "% of the tips.");
163 state claimed;
164 }
165 }
166
167 money(key giver, integer amount) {
168 llSay(0, "Thanks for the " + (string)amount + "L$, " + llKey2Name(giver));
169 total+=amount;
170 updateText();
171 }
172
173 dataserver(key query_id, string data)
174 {
175 if(query == query_id)
176 {
177 // this is a line of our notecard
178 if(data != EOF)
179 {
180 // process first line, tip price list
181 if( index==1 )
182 {
183 list l = llCSV2List(data);
184 list l2 = [];
185
186 integer length = llGetListLength(l);
187 integer i;
188 for(i=0;i<length;i++)
189 {
190 l2+=[llList2Integer(l,i)];
191 }
192
193
195 }
196 // Line 2: Percent to pay to tip claimer
197 else if( index==2 )
198 {
199 percent = (integer)data;
200 percent/= 100;
201 }
202 else if( index==3 )
203 {
204 timeout = (integer)data;
205 }
206 else if( index==4 )
207 {
208 if( llToLower(data)=="group" )
209 {
210 check_group = TRUE;
211 }
212 }
213 query = llGetNotecardLine("Config",index++);
214
215 }
216 }
217 }
218 }
219
220
221 state claimed
222 {
224 {
225 if( percent>1 )
226 {
227 llInstantMessage(claimed_key, "Payback it set to more than 100%, can't claim tip jar.");
228 state unclaimed;
229 }
230
231 updateText();
232 generalParticleEmitterOn();
233 llListen(CHANNEL, "", llGetOwner(), "");
234 if( timeout>0 )
235 llSetTimerEvent(60*timeout);
236 }
237
238 money(key giver, integer amount) {
239 llSay(0, "Thanks for the " + (string)amount + "L$, " + llKey2Name(giver));
240 total+=amount;
241 llGiveMoney(claimed_key,(integer)(amount*percent));
242 updateText();
243 }
244
245 touch_start(integer count)
246 {
247 if( (llDetectedKey(0)==claimed_key) || (llDetectedKey(0)==llGetOwner()) )
248 {
249 state unclaimed;
250 }
251 }
252
253 timer()
254 {
255 state unclaimed;
256 }
257
258
259 }

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