Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vendor script not working when I am gone

Amor Arashi
Registered User
Join date: 20 Aug 2007
Posts: 4
12-11-2007 15:43
I have created simple vendors that contain items to sell; my shop is at Hawkins (217, 233, 54). The vendors are all set to my group, Amor Designs. The goal is that if the purchaser is not in my group, they get the items delivered to a new folder in their inventory. If they are a member of my group, then they get the items as above, but then are also given 25% refund as a "group member's discount". BAsically, the scripts checks to see if they belong to the group and reduces the purchase price by 75% and refunds the excess to group members.

Here is the problem:

1. If I am physically in the shop when someone makes a purchase, the script works perfectly.

2. If I am in a separate region when someone makes a purchase, the vendor takes their money, but does not give the items to their inventory, AND does not give the discount. BUT, once I TP to the SIM, it WILL deliver the merchandise AND give the discount to the purchaser the moment I show up in my shop!!

3. If I am logged off, then the vendor again takes the money and does not deliver the item, and does not give the discount. But when I log back on, it seems to just create the folder in their inventory, but not deliver the merchandise and no discount.

Someone told me they had the same problem with an email function, but it got fixed once the SIM was restarted. I asked LL to re-start my SIM and received notice they did so. Yet I still have the problem.

I am listing below the ENTIRE vendor script (it starts below the dashed line). I would be really grateful if my fellow scripters would look at it and give me your thoughts on how to fix this so that the vendors work ALL the time (even when I am not in my shop!).

Thank you,

- Amor Arashi -

(ps: I modifed this from a LSL supplied script. All are welcome to use any/all part of this code.)

-------------------------------------------------------------------


integer gProductPrice = 35; // this defines the correct price

list ItemsGiven = ["Sandals by Amor - base","Sandals by Amor - left foot","Sandals by Amor - right foot","Sandals by Amor - sizing instructions"];

float gGroupDiscount = 0.25; // this defines the group discount

integer gThisSalePrice; // this defines the price for this sale



default
{
state_entry()
{
// get permission from the owner to pay out money using the llGiveMoney function.
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [gProductPrice,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}

money(key id, integer amount)
{

if (llSameGroup(id) == 1)
{
gThisSalePrice = (integer) ((float) (gProductPrice) * (1.0 - gGroupDiscount)); // price after discount to group members
}
else
{
gThisSalePrice = gProductPrice; // price for non-group members
}

// has the user paid the correct amount?
if (amount == gThisSalePrice)
{
// if so, thank the payer by name.
llSay(0,"Thank you, " + llKey2Name(id) + ". The item(s) have been placed in a folder called 'Amor Designs' in your inventory.";);
llGiveInventoryList(id, "Amor Designs", ItemsGiven);
}

// is the amount paid less than it needs to be?
else if (amount < gThisSalePrice)
{
// if so, tell them they're getting a refund, then refund their money.
llSay(0,"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".";);
llGiveMoney(id, amount); // refund amount paid.

}

// if it's not exactly the amount required, and it's not less than the amount required,
// the payer has paid too much.
else
{
// tell them they've overpaid.
integer refund = amount - gThisSalePrice; // determine how much extra they've paid.
llSay(0, "Thank you, " + llKey2Name(id) + ". The item(s) have been placed in a folder called 'Amor Designs' in your inventory. Also, you paid too much. You are being refunded your change of L$" + (string)refund + ".";);
llGiveMoney(id, refund); // refund their change.
llGiveInventoryList(id, "Amor Designs", ItemsGiven);
}
}
}
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-11-2007 16:20
At a very quick initial scan, your problem may be with the use of llGiveInventoryList. This is not a reliable function - you should either give a single object which has its contents being all of the items you wish to deliver, or do a loop with llGiveInventory.

I can't immediately see anything else which would be causing a problem, but no doubt somebody will now come along and point something out and make me feel a fool.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-11-2007 16:54
please use php tags... qouting to get the code formatting is annoying and only works if someone is NOT in advanced edit mode.

I couldn't see anything obviously wrong with it, but since I had to open a post to look at it I reformatted it and made some tweaks eliminating a few repeat statements, and using instant message instead of say to talk to the buyers (so as not to spam the local area)

you say it's set to or deeded to the group? if deeded, I'll assume you're the group owner? IIRC debit permissions aren't supposed to work at all with groups, and this may be causing the problem. it's possible that if you are the only group member that is responsible for payments that it's still triggering when you enter the sim (which would be a bug, shouldn't work at all)

EDIT: also what Ordinal said, if it's a single item vendor there isn't a reason not to box the items
CODE

integer gProductPrice = 35; // this defines the correct price
list ItemsGiven = ["Sandals by Amor - base","Sandals by Amor - left foot","Sandals by Amor - right foot","Sandals by Amor - sizing instructions"];
float gGroupDiscount = 0.25; // this defines the group discount

integer gThisSalePrice; // this defines the price for this sale


default{
state_entry(){
// get permission from the owner to pay out money using the llGiveMoney function.
llRequestPermissions( llGetOwner(), PERMISSION_DEBIT );
llSetPayPrice( PAY_HIDE, [gProductPrice, PAY_HIDE,PAY_HIDE, PAY_HIDE] );
}

money( key id, integer amount ){
// is the amount paid less than it needs to be?
if (amount < gProductPrice){
// if so, tell them they're getting a refund, then refund their money.
llInstantMessage( id, "You didn't pay enough, " + llKey2Name( id ) + ". Refunding your payment of L$" + (string)amount + "." );
llGiveMoney( id, amount ); // refund amount paid.
}else{
// paid enough, thank the payer by name.
llInstantMessage( id ,"Thank you, " + llKey2Name( id ) + ". The item(s) have been placed in a folder called 'Amor Designs' in your inventory." );
llGiveInventoryList( id, "Amor Designs", ItemsGiven );

// apply group discount if they are wearing group tags
if (llSameGroup( id )){
gThisSalePrice = llRound( (float)(gProductPrice) * (1.0 - gGroupDiscount) ); // price after discount to group members
}else{
gThisSalePrice = gProductPrice;
}

if (amount > gThisSalePrice){
// the payer has paid too much. tell them they've overpaid.
integer refund = amount - gThisSalePrice; // determine how much extra they've paid.
llInstantMessage( id, "Refunding rebate/overpayment of L$" + (string)refund + "." );
llGiveMoney( id, refund ); // refund their change.
}
}
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Amor Arashi
Registered User
Join date: 20 Aug 2007
Posts: 4
12-11-2007 17:45
Void:

1. The vendors are "set" to group. (I tried to fix the problem by "deeding".. and like you said, it didnt work at all - the group got the money and no items ever delivered, even if I was in the same shop at the time of purchase.)

2. I will try Ordinal's and your's suggestion to put all items in a box and use llGiveInventory. But would using LlGiveInventoryList explain the anomaly of the vendor not working when I am away (and work perfectly everytime I am in the shop)? I would hve thought that if llGiveInventoryList is not reliable, then it would break on an erratic basis even when I AM in the shop (unless it has a SL eccentricity that is not documented). And of course, the purchaser would now have to go through the extra steps of rezzing the "box" prim and open it and copy the items to his inventory.

3. Using IM instead of "Say " is a good idea; i will make the change.

Thank you all again for the suggestions..

- Amor -
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-11-2007 23:34
Rez your vendor while wearing the appropriate group tag.

Do NOT share the vendor with the group.
Do NOT deed the vendor to the group.

Now it should work like it is supposed to.



llGiveInventoryList afaik does only work reliably with the purchaser being in the same sim ad the delivering object.

llGiveInventory works regardless where buyer/delivering object are located at.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-12-2007 04:09
let us how it turns out, and what the resolution is... I'm very curious to know what's causing this, and what's the solution
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
12-12-2007 16:27
just an idea.
use llSetPayPrice(PAY_HIDE,[item_price,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
and you dont need to request for L$ debit permissions and to check for the payd amount of L$ in the money event because the function will set up 1 pay button with the correct price. that also makes it possible to deed the vendor to a group if needed.
thats how i did it for my multi item vendor and its working fine.

Is there no script error message when the item is not deliverd?
Amor Arashi
Registered User
Join date: 20 Aug 2007
Posts: 4
Problem Solved !!! - finally !!! Godddddddd!!!!!!
12-12-2007 17:55
Ok.. I will take you guys thorough it step by step, just in case any one is interested in any of the intermediate steps:

1. I first tried Squirrels idea of rezzing the vendor from scratch with my original script (previously I had just dropped the script in it from the basic non-scripted SL vendor). Result - Same problem. Would only work if I was physically in the shop.

2. As suggested by Ordinal and Void, then I removed the llGiveInventoryList and put it all in a box and use LlGiveInventory instead. Result - Same problem. The "boxed" delivered perfectly as long as my avi was ohysically in the shop.

3. I had also tried Void's script using llInstantMessage instead of llSay. Result - Same problem.

4. revochen, you are right about the llSetPayPrice; the initial script did not use that and I needed the over/uunder payment logic; after I used this function, I was just too lazy to remove the superflous code.

5. Finally, along with posting my problem here, I had sent the entire post as a notecard to Andy Enfield in SL. For those that dont know, Andy is the owner and scripter for the Hippo products. Since his HippoVend allows discounts based on groups, and because of his immense scripting experience, I sent him an IM hoping he would take pity on me and help. Well, Andy was most gracious. Here is Andy's response:

"The most common cause of scripts misbehaving like this is bad group permissions (e.g. land is set to only allow scripts belonging to the same group as the land is deeded to, object is not set to group ... what happens is SL gets confused because your rights as land owner clash with the lack of rights due to the wrong group and the script fails. A known SL buggy; just set permissions correctly."

Now, to prevent griefing, etc, I had set all scripts on the land to be off. The land is deed to my group Amor Designs. The vendors are set to the Amor Designs group (not deeded). Well, I changed the About Land settings to allow "Run Scripts" by the Group only. And Voilaaaaaaa !!! All the vendors with my original (wordy!) script worked like a charm!!! I tested with several friends. When I was in a different SIM, or when I was logged off, the script worked flawlessly - purchaser without the group tag paid full price and got the folder with the items; and with the group tag, further got the discount refund. BTW, now I have to worry if someone in the group goes nuts and starts running malicious scripts; I am open to any suggestions on how to stop that, yet keep my vendors running!

BTW, I like the llGiveInventoryList because it gives the purchaser, especially those new to SL, a folder with the items. llGiveInventory does NOT allow that option; it only gives the item in their inventory. And we all know how most inventories are a pile of mess. How many of us have bought stuff but were unable to find it in our inventory jungle!! And how many of us have seen someone walk around with a box attached to their limbs because they didn't know how to get the stuff out and just attached the box to their body !! If someone has a workaround for using llGiveInventory to put the box items in a folder, let me know. It is good to know, however, that llGiveInventoryList is unreliable unless the buyer AND the vendor are in the same SIM. Since my vendors at this time only sell if you come to my shop, hopefully I wont have this problem. But it is good to know this gem about llGiveInventoryList's unreliablity, for sure.

I would like to thank everyone for all your comments and suggestions. I learned a lot in the process about things unrelated. I truly appreciate it.

And lastly, I feel obligated to give a "commercial" for Andy and his products since his insight, which I am sure can only be obtained from hours and hours of frustrating coding, was so much on target. So go out and buy his stuff if you cant code it yourself!! *grinning*

Thank you all again.

- Amor Arashi -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-12-2007 20:03
From: Amor Arashi
Well, I changed the About Land settings to allow "Run Scripts" by the Group only. And Voilaaaaaaa !!! All the vendors with my original (wordy!) script worked like a charm!!!

heh looks like I was aiming the right direction to begin with, it was a permissions bug (just not the one that came immediately to mind...

good to know about that though, as I always tell people to turn off things like object entry and rez for security, and allow group officers those rights (in the group controls)... I'll have to add the land option for allow group scripts to that list
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
12-13-2007 00:04
Even with llSetPayPrize() set you MUST NOT TRUST payments to be of the correct amount!

Always, always, ALWAYS check for the proper amount.

There are ways around the pay dialog.
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
12-13-2007 10:25
can you proof that?