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
Vendor Dialog_Based_sounds_vendor  

Dialog_Based_sounds_vendor

Dialog Based sounds vendor by Kenny Jackson.lsl

Category: Vendor
By : Kenny Jackson
Created: 2010-01-10 Edited: 2014-02-23
Worlds: Second Life

the Zip file

Download all files for Dialog_Based_sounds_vendor
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Dialog_Based_sounds_vendor_by_Kenny_1.lsl
1
2 // Mods by Ferd Frederix
3 // 02-23-2014
4 // removeed useless code.
5 // made functions out of repeated items.
6 // added price checks
7 // removed listener when not being used
8 // play sounds when changed
9 // dialog always on any click
10
11 // Dialog Based sounds vendor by Kenny Jackson
12
13
14 //NOTES:
15 //1.) All sounds in the vendor will have the same price.
16 //2.) Set the price by changing the vendor description.
17 //(example. If you want the price of all the sounds in the vendor to be L$50 set the vendor description to 50.)
18 //3.) After changing the price hit the RESET button to update the script. Only the owner will see the RESET button.
19 //4.) Just drop this script and the sounds your selling into a prim
20 //5.) Click the prim to get the dialog.
21 //Kenny Jackson
22
23 integer price;
24 string wrong = "Sorry, that is not the correct price";
25 string over = "You have overpaid, here is your change";
26 string thank = "Thank you for your purchase";
27 integer finished = FALSE;
28 integer n = 0;
29 integer i;
30 list sounds;
31 integer CHANNEL;
32 string soundName;
33 string GNAME;
34 integer listener;
35 key aviKey;
36
37 Dialog ()
38 {
39 llListenRemove(listener);
40 CHANNEL = llCeil(llFrand(10000) + 10000);
41 listener = llListen(CHANNEL, "", "", "");
42 if(aviKey == llGetOwner())
43 {
44 llDialog(aviKey,"1.) Choose Next/Back to scroll through sounds.\n2.) Press Play to hear a sound.\n3.) Right Click and Pay to buy!", ["Back", "Next", "Play", "Reset"], CHANNEL);
45 }
46 else
47 {
48 llDialog(aviKey,"1.) Choose Next/Back to scroll through sounds.\n2.) Press Play to repeat a sound.\n3.) Right Click and Pay to buy!", ["Back", "Next"], CHANNEL);
49 }
50
51 }
52
53
54
55 GetSounds()
56 {
57 finished = FALSE;
58 n = 0;
59
60 while(!finished)
61 {
62 soundName = llGetInventoryName(INVENTORY_SOUND, n);
63 if(soundName == "")
64 {
65 finished = TRUE;
66 price = (integer)llGetObjectDesc();
67 if(price <= 0)
68 {
69 llOwnerSay("Price set to 10 Lindens as a default. Change it in the description and reset the script.");
70 llSetObjectDesc("10");
71 }
73 }
74 else
75 {
76 sounds = sounds + soundName;
77 n++;
78 }
79 }
80 }
81
82 default
83 {
85 {
86 GetSounds();
88 }
89
90 run_time_permissions(integer permissions)
91 {
92 //Only wait for payment if the owner agreed to pay out money
93 if(permissions & PERMISSION_DEBIT)
94 {
95 llSetText("Initialized with " + (string) n + " sounds", <0,1,0>,1);
96 state ready;
97 }
98 }
99
100 on_rez(integer start_param)
101 {
103 }
104 }
105
106 state ready
107 {
108 on_rez(integer start_param)
109 {
111 }
112
113 listen(integer channel, string name, key id, string message)
114 {
115 if(message == "Next")
116 {
117 i++;
118 if(i >= n)
119 {
120 i = 0;
121 }
122 GNAME = llList2String(sounds, i);
123 llPlaySound(GNAME, 1);
124 }
125 else if(message == "Back")
126 {
127 i--;
128
129 if(i < 0)
130 {
131 i = n - 1;
132 }
133 GNAME = llList2String(sounds, i);
134 llPlaySound(GNAME, 1);
135 }
136 else if(message == "Play")
137 {
138 GNAME = llList2String(sounds, i);
139 llPlaySound(GNAME, 1);
140 }
141 else if(message == "Reset")
142 {
144 }
145
146
147 llSetText(GNAME, <1,0,0>, 1);
148 Dialog();
149
150 }
151
152 changed(integer what)
153 {
154 if(what & CHANGED_INVENTORY)
155 {
156 GetSounds();
157 }
158 }
159
160 touch_start(integer total_number)
161 {
162 aviKey = llDetectedKey(0);
163 Dialog();
164 }
165
166 money(key id, integer amount)
167 {
168 if(amount < price)
169 {
170 llSay(0, wrong);
171 llGiveMoney(id, amount);
172 }
173 if(amount > price)
174 {
175 llSay(0, over);
176 llGiveMoney(id, amount - price);
177 llGiveInventory(id, GNAME);
178 }
179 if(amount == price)
180 {
181 llSay(0, thank);
182 llGiveInventory(id, GNAME);
183 }
184 }
185 }
186
187 // END //

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