Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dialog Based sounds vendor

Kenny Jackson
Registered User
Join date: 26 Sep 2004
Posts: 31
06-04-2005 01:13
I have learned so much from these threads so im gonna give something back I hope its usefull !! =D

NOTES:
1.) All sounds in the vendor will have the same price.
2.) Set the price by changing the vendor description.
(example. If you want the price of all the sounds in the vendor to be L$50 set the vendor description to 50.)
3.) After adding new sounds to the vendor or changing the price or vendor name hit the RESET button to update the script. Only the owner will see the RESET button.
4.) Just drop this script and the sounds your selling into a prim
5.) Click the prim to get the dialog.
6.) If your going to have more than 1 of these in a small area make sure to have a different channel number on each of them or all the vendors in the area will respond to the others dialogs.

Im sure im forgetting to tell you something.
Feel free to post any questions or comments on this!


CODE

integer price;
string wrong = "Sorry, that is not the correct price";
string over = "You have overpaid, here is your change";
string thank = "Thank you for your purchase";
integer finished = FALSE;
integer n = 0;
integer i;
list sounds;
integer CHANNEL = 123456;
string soundName;
string GNAME;
string Vname;

default
{
state_entry()
{
while(!finished)
{
soundName = llGetInventoryName(INVENTORY_SOUND, n);
if(soundName == "")
{
finished = TRUE;
Vname = llGetObjectName();
price = (integer)llGetObjectDesc();

state debtperm;
}
else
{
sounds = sounds + soundName;
n++;
}
}
}
}
state debtperm
{
state_entry()
{
//Do some initialization here
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions(integer permissions)
{
//Only wait for payment if the owner agreed to pay out money
if (permissions)
{
llSetText("Initailized Successfully...", <0,1,0>,1);
state next;
}
}
}
state ready
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
GNAME = llList2String(sounds, i);

llListen(CHANNEL, "", "", "");
}

listen(integer channel, string name, key id, string message)
{
if(channel == CHANNEL && message == "Reset")
{
llSetText("Resetting...", <1,0,0>, 1);
llResetScript();

}

if(channel == CHANNEL && message == "Next")
{
i++;

if(i >= n)
{
i = 0;
state next;

}
else
{
state next;
}

}
if(channel == CHANNEL && message == "Back")
{
i--;

if(i < 0)
{
i = n - 1;
state next;

}
else
{
state next;
}
}
if(channel == CHANNEL && message == "Play")
{
llPlaySound(GNAME, 1);
state next;
}

}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llDetectedKey(0),"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);
}
else
{
llDialog(llDetectedKey(0),"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"], CHANNEL);
}
}

money(key id, integer amount)
{
if(amount < price)
{
llSay(0, wrong);
llGiveMoney(id, amount);
}
if(amount > price)
{
llSay(0, over);
llGiveMoney(id, amount - price);
llGiveInventory(id, GNAME);
}
if(amount == price)
{
llSay(0, thank);
llGiveInventory(id, GNAME);
}
}
}
state next
{
state_entry()
{
GNAME = llList2String(sounds, i);
llSetText(".:" + Vname + ":.\nClick for a dialog!\nSound Name: " + GNAME + "\nPrice: L$" + (string)price, <1,1,1>, 1);
state ready;
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
06-04-2005 08:22
/54/c7/49086/1.html
_____________________
i've got nothing. ;)
Mitzpatrick Fitzsimmons
Neurotican Mage
Join date: 20 Sep 2004
Posts: 62
06-04-2005 14:07
Excellent Job Kenny!!!!
Jeremy Kabumpo
Registered User
Join date: 26 Jan 2006
Posts: 1
With title block
02-09-2006 07:20
CODE
//DIALOG-BASED SOUND VENDOR
//
//This script sells sounds
//Place this script in a prim and add sound files
//Set the price by changing the description of Prim, i.e. "1" for 1L
//Press "reset" after making any changes to price or sound inventory

//Kenny Jackson
//http://forums.secondlife.com/showthread.php?t=49063

integer price;
string wrong = "Sorry, that is not the correct price";
string over = "You have overpaid, here is your change";
string thank = "Thank you for your purchase";
integer finished = FALSE;
integer n = 0;
integer i;
list sounds;
integer CHANNEL = 123456;
string soundName;
string GNAME;
string Vname;

default
{
state_entry()
{
while(!finished)
{
soundName = llGetInventoryName(INVENTORY_SOUND, n);
if(soundName == "")
{
finished = TRUE;
Vname = llGetObjectName();
price = (integer)llGetObjectDesc();

state debtperm;
}
else
{
sounds = sounds + soundName;
n++;
}
}
}
}
state debtperm
{
state_entry()
{
//Do some initialization here
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions(integer permissions)
{
//Only wait for payment if the owner agreed to pay out money
if (permissions)
{
llSetText("Initailized Successfully...", <0,1,0>,1);
state next;
}
}
}
state ready
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
GNAME = llList2String(sounds, i);

llListen(CHANNEL, "", "", "");
}

listen(integer channel, string name, key id, string message)
{
if(channel == CHANNEL && message == "Reset")
{
llSetText("Resetting...", <1,0,0>, 1);
llResetScript();

}

if(channel == CHANNEL && message == "Next")
{
i++;

if(i >= n)
{
i = 0;
state next;

}
else
{
state next;
}

}
if(channel == CHANNEL && message == "Back")
{
i--;

if(i < 0)
{
i = n - 1;
state next;

}
else
{
state next;
}
}
if(channel == CHANNEL && message == "Play")
{
llPlaySound(GNAME, 1);
state next;
}

}
touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llDetectedKey(0),"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);
}
else
{
llDialog(llDetectedKey(0),"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"], CHANNEL);
}
}

money(key id, integer amount)
{
if(amount < price)
{
llSay(0, wrong);
llGiveMoney(id, amount);
}
if(amount > price)
{
llSay(0, over);
llGiveMoney(id, amount - price);
llGiveInventory(id, GNAME);
}
if(amount == price)
{
llSay(0, thank);
llGiveInventory(id, GNAME);
}
}
}
state next
{
state_entry()
{
GNAME = llList2String(sounds, i);
llSetText(".:" + Vname + ":.\nClick for a dialog!\nSound Name: " + GNAME + "\nPrice: L$" + (string)price, <1,1,1>, 1);
state ready;
}
}
Gabriel Tackleberry
Registered User
Join date: 22 Feb 2006
Posts: 23
02-25-2006 07:00
You have to keep opening the dialog.

User clicks 'Next' to hear the next sound, and the dialog disapears, so the user must rightclick and select 'Touch' again.

And since I'm a beginner with this scripting system, I can't seem to get the dialog to come back up, just skips over my code.
Honey Something
Texture Maker
Join date: 30 Sep 2006
Posts: 24
08-04-2007 17:01
This works great as intended, but has anyone made a modification to allow a give on touch for a free item?

I'm working on doing this so I thought I'd ask before I get any further :-)
Honey Something
Texture Maker
Join date: 30 Sep 2006
Posts: 24
08-04-2007 17:10
This works great as intended, but has anyone made a modification to allow a give on touch for a free item?

I'm working on doing this so I thought I'd ask before I get any further :-)
Shep Planer
Registered User
Join date: 9 Apr 2007
Posts: 153
08-22-2007 22:53
I noticed with this script that when you click 'next' or 'back' the dialogue box dissapears so that you have to touch the vendor again to get the dialogue back before pressing play to hear the sound. Is there a way of keeping the dialogue box open?