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);
}
}
}