The flow is like this. Can anyone see why I shouldn't be able to give some 3rd party money with this?
CODE
// ExampleMoney
// Pay the object money, this script refunds incorrect payments
// This code is public domain.
integer gCorrectAmount = 150; // this defines the correct price -- we only accept L$10
string item_name = "Toy"; // the name of the item we're going to look for.
key Friend = "a822ff2b-ff02-461d-b45d-dcd10a2de0c2"; //example key I do have the good one
default
{
state_entry()
{
llSetText("Right Click this box to pay $150 for Toy.", <0,1,0>, 1.0);
llAllowInventoryDrop(TRUE);
// get permission from the owner to pay out money using the llGiveMoney function.
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
money(key id, integer amount)
{
// has the user paid the correct amount?
if (amount == gCorrectAmount)
{
// if so, thank the payer by name.
llSay(0,"Thank you, " + llKey2Name(id) + ".");
llGiveInventory(id,"Toy");
//here is the offending code that won't work.....
llGiveMoney(Friend, AMOUNT/2);
}
// is the amount paid less than it needs to be?
else if (amount < gCorrectAmount)
{
// 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 - gCorrectAmount; // determine how much extra they've paid.
llSay(0,"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
llGiveMoney(id, refund); // refund their change.
}
}
}
Thanks for any help you can offer.
