Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Combining dialogs and money events...

Jess Riederer
particle maniac
Join date: 10 Jun 2007
Posts: 9
04-16-2008 10:33
What i'm trying to do is make a vendor script which pops up a dialog menu on pay, let's them choose the permissions they want, and gives it to them after they choose or refunds their money if they choose cancel or the request times out. i've never done anything with dialogs before and i can't figure out how to integrate it into the money event or make it work in a seperate event. i basically jacked some dialog code from a script i had already, and the menu comes up when i pay but doesn't give the items. also is there a way to do this without a listener for the dialog menu, it would be nice to have as little lag as possible as i have a ton of objects these are going to go into. Any and all help or advice would be appreciated :)

Here's part of what i have (the whole script is kinda huge and messy but this is the only part i'm having trouble with lol)

integer amount;
list main_menu = ["copy","transfer","cancel"];
integer channel;
integer listen_handle;

init() {
llListenRemove(listen_handle);

channel = llFloor(llFrand(2000000)); //random channel so multiple scripts don't interfere with each other
listen_handle = llListen(channel, "", "", "";);
}


default
{ state_entry()
{

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);

{ init(); }

channel = llFloor(llFrand(2000000)); //random channel so multiple scripts don't interfere with each other
listen_handle = llListen(channel, "", "", "";);

}

money(key id, integer payed)
{
if (payed != amount)
{
llGiveMoney(id, payed);
return;
}

llDialog(id, "\n\nSelect your desired permissions", main_menu, channel);


}
listen(integer channel, string name, key id, string message) {

if (llListFindList(main_menu, [message]) != -1) {


if (message == "copy";)


llGiveInventory(id,llGetInventoryName(INVENTORY_OBJECT, (0)));
return;

}else if
(message == "transfer";)

{llGiveInventory(id,llGetInventoryName(INVENTORY_OBJECT, (1)));
return;
}
else if
(message == "cancel";)
llGiveMoney(id, payed);
return;
}
}
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
04-16-2008 10:52
I'm afraid that what you need to do is a bit more complicated than this, because of the risk of concurrency problems. Here is how I, personally, would do it:

1) Keep a list of "paying customers".
2) When somebody pays, add them to the list, and perform the llDialog call.
3) When somebody says something in response to the dialog, check that they are on the paying customers list, and ignore them if they are not. If they are, give them their item or money and remove them from the list.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-16-2008 11:03
Consider also what to do if the user doesn't answer the dialog (this can happen for any number of reasons, such as crashing or leaving before noticing the dialog). You may want to check through your list (or whatever) for timeouts every now and then and refund the money or send a default choice (if you make the default choice no-copy, you might also be able to setup some kind of system for exchanging it for a copy/no-transfer version later...).
Jess Riederer
particle maniac
Join date: 10 Jun 2007
Posts: 9
thanks Yumi and Hewee :)
04-16-2008 11:23
I'm gonna combine those two suggestions and give it a shot lol. *starts twiddling with scripts and will most likely be back in a few hours with a migraine asking for help again* ty both again :)
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
04-17-2008 00:09
I personally would suggest letting the customer make that choice on the vendor itself BEFORE they pay it. Then, on pay, you can immediately hand out the item. No lists to keep, do dialogs to listen for.