Difference between revisions of "LlGiveMoney"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Function/permission|PERMISSION_DEBIT|grant=the owner}}{{LSL Function/avatar|destination}}{{LSL_Function
{{LSL_Function
|inject-1={{LSL_Function/warning|Usage|There is no way to determine the success of a [[llGiveMoney]] transaction. If you need to know if a transaction was successful, use [[llTransferLindenDollars]] instead of [[llGiveMoney]].}}
<!--{{#vardefine:gd_text|There is no way to determine the success of a [[llGiveMoney]] transaction. If you need to know if a transaction was successful, use [[llTransferLindenDollars]] instead of [[llGiveMoney]].}}
|deprecated=llTransferLindenDollars-->
|inject-2={{LSL_Function/permission|PERMISSION_DEBIT|grant=the owner}}{{LSL Function/avatar|destination}}
|func_id=99|func_sleep=0.0|func_energy=10.0
|func_id=99|func_sleep=0.0|func_energy=10.0
|func=llGiveMoney|sort=GiveMoney
|func=llGiveMoney|sort=GiveMoney
|return_type=integer|return_text=that is always {{HoverText|zero|0}}.
|return_type=integer|return_text=that is always {{HoverText|zero|0}}. In contrast [[llTransferLindenDollars]] returns a [[key]] that can be used to match the function call to the resulting [[transaction_result]] event and the [https://secondlife.com/my/account/transactions.php transaction history].
|p1_type=key|p1_name=destination
|p1_type=key|p1_name=destination
|p2_type=integer|p2_name=amount|p2_desc=number of L$, must be greater than zero, ('''amount''' &gt; 0)
|p2_type=integer|p2_name=amount|p2_desc=number of L$, must be greater than zero, ({{LSLP|amount}} &gt; 0)|p2_hover=number of L$, must be greater than zero, ('amount' &gt; 0)
|func_desc=Transfer '''amount''' of L$ money from script owner to '''destination''' avatar.
|func_desc=Transfer {{LSLP|amount}} of L$ money from script owner to {{LSLP|destination}} avatar.
|func_footer
|spec
|spec
|caveats=*An object cannot pay another object.
|caveats=*An object cannot pay another object.
*It is impossible for a script to tell if this function succeeded or failed at giving money.
*It is impossible for a script to tell if an llGiveMoney transaction succeeded or failed. Use [[llTransferLindenDollars]] instead.
*Objects deeded to groups cannot give money (the permission cannot be granted).
*Objects deeded to groups cannot give money (the permission cannot be granted).
*Use is limited to 30 payments in a 30 second interval for all scripts owned by that resident on a region. Sustained overage will produce a script error and halt payments while the rate remains excessive. Historically, faster payments have failed intermittently.
*Use is limited to 30 payments in a 30 second interval for all scripts owned by that resident on a region. Sustained overage will produce a script error and halt payments while the rate remains excessive. Historically, faster payments have failed intermittently.
*Once a script has the [[PERMISSION_DEBIT]] permission it can empty an account of L$.
*Once a script has the [[PERMISSION_DEBIT]] permission it can empty an account of L$.
**Fraud & theft are both {{LL|TOS}} violations and crimes. Misuse this function and you risk being banned and legal action. In addition LL may freeze the accounts of anyone the money is transferred to and restore it to it's rightful owners. This may involve retrieving it from third party exchanges and accounts on those exchanges being frozen. The system is not designed to be friendly towards fraud.
**Fraud & theft are both {{LL|TOS}} violations and crimes. Misuse this function and you risk being banned and legal action. In addition LL may freeze the accounts of anyone the money is transferred to and restore it to it's rightful owners. This may involve retrieving it from third party exchanges and accounts on those exchanges being frozen. The system is not designed to be friendly towards fraud.
|examples=<lsl>//A simple piggy bank, anyone can pay in money and anyone can click it to get money out.
|examples=
<source lang="lsl2">
// Pay 100 L$ to Fred Bloggs when he touches this prim, then die
// Compare this example with that shown under llTransferLindenDollars


integer AMOUNT = 10; //The amount of money to be given each time it is clicked.
string  Recipient = "Fred Bloggs";     // Authorised recipient
integer STASH = 50;   //The amount of money the script has to give out by default.
integer Amount = 100;                   // Amount to pay Fred when he touches the prim
 
integer DebitPerms;
update()
{
    if(STASH >= AMOUNT)
        llSetText("I have L$"+(string)STASH + " to give away!", <1,1,1>, 1);
    else
        llSetText("I have no L$ to give away :(", <1,1,1>, 1);
}


default
default
Line 30: Line 31:
     state_entry()
     state_entry()
     {
     {
         llRequestPermissions(llGetOwner(), PERMISSION_DEBIT );
        // Ask the owner for permission to debit their account
         llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
     }
     }


     run_time_permissions (integer perm)
     run_time_permissions (integer perm)
     {
     {
         if(perm & PERMISSION_DEBIT)
         if (perm & PERMISSION_DEBIT)
        {
             DebitPerms = TRUE;
             state ready;    
        }
     }
     }
}


state ready
     touch_start(integer num_detected)
{
     state_entry()
     {
     {
         update();
         if (!DebitPerms)
            return;                     // Cannot proceed - debit permissions not granted
        if (llDetectedName(0) != Recipient)
            return;                    // unauthorised person is touching - ignore
 
        key id = llDetectedKey(0);      // Get toucher's (i.e. Fred's) UUID
        llGiveMoney(id, Amount);        // Give him the money
        llDie();                        // Die so Fred can't keep taking money
     }
     }
    touch_start(integer num)
}
    {
</source>
        if(STASH >= AMOUNT)
        {
            llGiveMoney(llDetectedKey(0), AMOUNT);
            STASH -= AMOUNT;
            update();
        }
        else
        {
            llWhisper(0, "No more money to give away :(");
        }
    }
    money(key id, integer m)
    {
        STASH += m;
        update();
    }
}</lsl>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llSetPayPrice]]}}
|also_functions={{LSL DefineRow||[[llTransferLindenDollars]]}}
|also_events={{LSL DefineRow||[[money]]|}}
{{LSL DefineRow||[[llSetPayPrice]]}}
|also_events=
{{LSL DefineRow||[[money]]|}}
{{LSL DefineRow||[[transaction_result]]|}}
|also_tests
|also_tests
|also_articles
|also_articles
Line 78: Line 68:
|cat4
|cat4
}}
}}
'''Bold text'''

Latest revision as of 11:20, 22 January 2015

Emblem-important-red.png Usage Warning!

There is no way to determine the success of a llGiveMoney transaction. If you need to know if a transaction was successful, use llTransferLindenDollars instead of llGiveMoney.

Summary

Function: integer llGiveMoney( key destination, integer amount );

Transfer amount of L$ money from script owner to destination avatar.
Returns an integer that is always zero. In contrast llTransferLindenDollars returns a key that can be used to match the function call to the resulting transaction_result event and the transaction history.

• key destination avatar UUID
• integer amount number of L$, must be greater than zero, (amount > 0)

To run this function the script must request the PERMISSION_DEBIT permission with llRequestPermissions and it must be granted by the owner.

Caveats

Permissions
  • Do not depend upon the auto-grant status of permissions. Always use the run_time_permissions event.
  • If the script lacks the permission PERMISSION_DEBIT, the script will shout an error on DEBUG_CHANNEL and the operation fails (but the script continues to run).
  • If PERMISSION_DEBIT is granted by anyone other than the owner, then when the function is called an error will be shouted on DEBUG_CHANNEL.
  • Once the PERMISSION_DEBIT permission is granted there is no way to revoke it except from inside the script (for example, with a new llRequestPermissions call) or the script is reset or deleted.
  • An object cannot pay another object.
  • It is impossible for a script to tell if an llGiveMoney transaction succeeded or failed. Use llTransferLindenDollars instead.
  • Objects deeded to groups cannot give money (the permission cannot be granted).
  • Use is limited to 30 payments in a 30 second interval for all scripts owned by that resident on a region. Sustained overage will produce a script error and halt payments while the rate remains excessive. Historically, faster payments have failed intermittently.
  • Once a script has the PERMISSION_DEBIT permission it can empty an account of L$.
    • Fraud & theft are both Linden Lab violations and crimes. Misuse this function and you risk being banned and legal action. In addition LL may freeze the accounts of anyone the money is transferred to and restore it to it's rightful owners. This may involve retrieving it from third party exchanges and accounts on those exchanges being frozen. The system is not designed to be friendly towards fraud.
All Issues ~ Search JIRA for related Bugs

Examples

// Pay 100 L$ to Fred Bloggs when he touches this prim, then die
// Compare this example with that shown under llTransferLindenDollars

string  Recipient = "Fred Bloggs";      // Authorised recipient
integer Amount = 100;                   // Amount to pay Fred when he touches the prim
integer DebitPerms;

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

        key id = llDetectedKey(0);      // Get toucher's (i.e. Fred's) UUID
        llGiveMoney(id, Amount);        // Give him the money
        llDie();                        // Die so Fred can't keep taking money
    }
}

See Also

Events

•  run_time_permissions Permission receiving event
•  money
•  transaction_result

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llTransferLindenDollars
•  llSetPayPrice

Articles

•  Script permissions

Deep Notes

Search JIRA for related Issues

Signature

function integer llGiveMoney( key destination, integer amount );