Bonjour,
J'ai trouvé le script ci-dessous, qui correspond à ce que tu recherches, sur le Forum SL :
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;
}
}
Et les explications d'utilisation que j'ai traduit :
NOTES:
1.) Tous les sons du vendor auront le même prix (cela peu poser problème).
2.) Change le prix dans le champ description du vendor.
(Exemple : Si tu veux que tous les sons soient à L$50, met dans la description du vendor "50".)
3.) Après avoir ajouté de nouveaux sons au vendor ou après avoir changé le prix, appuies sur le bouton
Reset dans le menu.
Seul l'owner peut voir ce bouton.
4.) Met juste le script et les sons que tu veux vendre dans 1 prim.
5.) Clique sur la prim pour avoir un menu (dialog).
6.) Si tu veux avoir plus d'un vendor sur le même terrain, assures toi d'avoir différents numéros de chan (integer CHANNEL = 123456) sur chacun d'eux pour éviter les conflits entre les vendors.
Voilà.