Transfer amount of L$ money from script owner to destination avatar.
key llTransferLindenDollars( key destination, integer amount );
Forced delay: 0.0 seconds.
To run this function the script must request the PERMISSION_DEBIT permission with llRequestPermissions and it must be granted by the owner.
If you aren't going to use the return value or the resulting transaction_result event consider using llGiveMoney instead of this function.
Returns a key used in a matching transaction_result event for the success or failure of the transfer. If the transaction is successful, this key will show in the transaction history.
Permissions
// Pay 100 L$ to Fred Bloggs when he touches this prim
// Die if the transfer of funds was successful, else keep running
string Recipient = "Fred Bloggs"; // Authorised recipient
integer Amount = 100; // Amount to pay Fred when he touches the prim
integer DebitPerms;
key TransactionID=NULL_KEY;
default
{
state_entry()
{
// Ask the owner for permission to debit their account
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions (integer perm)
{
if (perm & PERMISSION_DEBIT)
DebitPerms = TRUE;
}
touch_start(integer num_detected)
{
if (!DebitPerms)
return; // Cannot proceed - debit permissions not granted
if (llDetectedName(0) != Recipient)
return; // unauthorised person is touching - ignore
if (TransactionID != NULL_KEY)
return; // waiting on previous transaction to complete/fail
key id = llDetectedKey(0);
TransactionID = llTransferLindenDollars(id, Amount);
}
transaction_result(key id, integer success, string data)
{
if (id != TransactionID)
return; // Ignore if not the expected transaction
if (success)
{
llOwnerSay( "Transfer of L$ to " + Recipient + " was successful");
llSleep(1.0);
llDie(); // Die so Fred can't keep taking money
}
else
{
llOwnerSay( "Transfer of L$ failed");
TransactionID = NULL_KEY;
// Keep the script running so Fred can try again, clear TransactionID to allow a new attempt
}
}
}
| Simple Piggy Bank |
Date of Release 03/12/2011