Difference between revisions of "LlSetPayPrice"

From Second Life Wiki
Jump to navigation Jump to search
 
(34 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/VWR-3048}}{{Issues/VWR-8744}}
|func_id=302|func_sleep=0.0|func_energy=10.0
|func_id=302|func_sleep=0.0|func_energy=10.0
|func=llSetPayPrice
|func=llSetPayPrice|sort=SetPayPrice
|p1_type=integer|p1_name=price|p1_desc=PAY_* constant or positive value
|p1_type=integer|p1_name=price|p1_desc=PAY_* constant or positive value (including zero)
|p2_type=list|p2_name=quick_pay_buttons|p2_desc=PAY_* constants and/or positive integer values
|p2_type=list|p2_name=quick_pay_buttons|p2_desc=Four PAY_* constants and/or positive integer values (zero is not shown)
|sort=PayPrice
|func_desc=Suggest default amounts for the pay text field and pay buttons of the appearing dialog when someone chooses to pay this object.
|func_desc=Sets the default amount for pay text field and pay buttons of the appearing dialog when someone chooses to pay this object.
|caveats=*This function should not be trusted to limit the values of money payable to the object; ''always'' verify the amount paid is the amount expected.
* Use only one call to this function in all the scripts on an object to prevent confusion about which values are used.  You still need to check in the money event that the amount is as expected.
* This function only works when called from the root prim of an object. Its effect applies to all the prims in the object. Calling it from a child prim has no effect. 
* Payment to a prim can be blocked by the llSetPayPrice() setting in the prim, which persists even if the script with llSetPayPrice() is removed.
* '''Caution:''' Calling this function will enable payment on the prim (or the whole object if it is the root prim) for the current state, even when this state has no money event.
* Otherwise, the pay option will only be shown in prims having a running script with a [[money]] event (or in all the prims of the object if the root has a running script with a money event).
* The effect seems to persist even if the script is recompiled with out the [[llSetPayPrice]] function, even if the script is replaced with another one which includes a [[money]] event, but not [[llSetPayPrice]].
* Money cannot be paid to an attachment; "Pay" will go directly to the wearer instead.
* If '''quick_pay_buttons''' contains a negative value or zero, the button will not be shown at all.
** However, zero is allowed for '''price''', which is used to set the custom text field's value within the Pay window.
 
|examples=This will give the user a dialog box without the '''price''' field and only one button with a value of 150.
|examples=This will give the user a dialog box without the '''price''' field and only one button with a value of 150.
<pre>llSetPayPrice(PAY_HIDE, [150,PAY_HIDE,PAY_HIDE,PAY_HIDE])</pre>
<source lang="lsl2">llSetPayPrice(PAY_HIDE, [150,PAY_HIDE,PAY_HIDE,PAY_HIDE])</source>
 
<source lang="lsl2">integer price = 10;
 
default
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_DEBIT)
            state cash;
    }
}
 
state cash
{
    state_entry()
    {
        llSetPayPrice(price, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
    }
    money(key id, integer amount)
    {
        if(amount != price)
        {
            llGiveMoney(id, amount);
            llInstantMessage(id, "You paid "+(string)amount+", which is the wrong price, the price is: "+(string)price);
        }
        else
        {
            //insert your give code here.
            llInstantMessage(id, "You paid the right price");
        }
    }
}</source>
|spec
|spec
|caveats
|constants=
|constants=
{{{!}}
{{{!}}
{{!}}
{{!}}
{{{!}}{{Prettytable}}
{{{!}}{{Prettytable|style=margin-top:0;}}
{{!}}-{{Hl2}}
{{!}}-{{Hl2}}
! colspan="2" {{!}} Constant
! colspan="2" {{!}} Constant
! {{HoverText|Alt|Alternate}}
! Description
! Description
{{!}}-
{{!}}-
{{!}} [[PAY_HIDE]]
{{!}} [[PAY_HIDE]]
{{!}} -1
{{!}} -1
{{!}} Do not show this quick pay button.
{{!}} <center>0</center>
{{!}} Hides this quick pay button.
{{!}}-
{{!}}-
{{!}} [[PAY_DEFAULT]]
{{!}} [[PAY_DEFAULT]]
{{!}} -2
{{!}} -2
{{!}}
{{!}} Use the default value for this quick pay button.
{{!}} Use the default value for this quick pay button.
{{!}}}
{{!}}}
{{!}}
{{!}}
{{{!}}{{Prettytable}}
{{{!}} {{Prettytable|style=margin-top:0;}}
{{!}}-{{Hl2}}
{{!}}-{{Hl2}}
! colspan="2" {{!}} Button Order
! colspan="2" {{!}} Button Order
{{!}}-
{{!}} <center>1</center>
{{!}} <center>2</center>
{{!}}-
{{!}}-
{{!}}1
{{!}} <center>3</center>
{{!}}2
{{!}} <center>4</center>
{{!}}-
{{!}}3
{{!}}4
{{!}}}
{{!}}}
{{!}}
{{!}}
{{{!}}{{Prettytable}}
{{{!}}{{Prettytable|style=margin-top:0;}}
{{!}}-{{Hl2}}
{{!}}-{{Hl2}}
! colspan="2" {{!}} Defaults
! colspan="2" {{!}} Defaults
Line 50: Line 100:
{{!}}}
{{!}}}
|helpers
|helpers
|also_functions
|also_functions={{LSL DefineRow||[[llGiveMoney]]|}}
|also_tests
|also_tests={{LSL DefineRow||[[llSetPayPrice Test]]|}}
|also_events
|also_events={{LSL DefineRow||[[money]]|}}
|also_articles
|also_articles
|notes
|notes
|cat1=Money
|cat1=Money
|cat2
|cat2=Prim
|cat3
|cat3=Dialog
|cat4
|cat4
|issues
}}
}}

Latest revision as of 03:10, 11 August 2023

Summary

Function: llSetPayPrice( integer price, list quick_pay_buttons );
0.0 Forced Delay
10.0 Energy

Suggest default amounts for the pay text field and pay buttons of the appearing dialog when someone chooses to pay this object.

• integer price PAY_* constant or positive value (including zero)
• list quick_pay_buttons Four PAY_* constants and/or positive integer values (zero is not shown)

Constant Alt Description
PAY_HIDE -1
0
Hides this quick pay button.
PAY_DEFAULT -2 Use the default value for this quick pay button.
Button Order
1
2
3
4
Defaults
$1 $5
$10 $20

Caveats

  • This function should not be trusted to limit the values of money payable to the object; always verify the amount paid is the amount expected.
  • Use only one call to this function in all the scripts on an object to prevent confusion about which values are used. You still need to check in the money event that the amount is as expected.
  • This function only works when called from the root prim of an object. Its effect applies to all the prims in the object. Calling it from a child prim has no effect.
  • Payment to a prim can be blocked by the llSetPayPrice() setting in the prim, which persists even if the script with llSetPayPrice() is removed.
  • Caution: Calling this function will enable payment on the prim (or the whole object if it is the root prim) for the current state, even when this state has no money event.
  • Otherwise, the pay option will only be shown in prims having a running script with a money event (or in all the prims of the object if the root has a running script with a money event).
  • The effect seems to persist even if the script is recompiled with out the llSetPayPrice function, even if the script is replaced with another one which includes a money event, but not llSetPayPrice.
  • Money cannot be paid to an attachment; "Pay" will go directly to the wearer instead.
  • If quick_pay_buttons contains a negative value or zero, the button will not be shown at all.
    • However, zero is allowed for price, which is used to set the custom text field's value within the Pay window.

Examples

This will give the user a dialog box without the price field and only one button with a value of 150.

llSetPayPrice(PAY_HIDE, [150,PAY_HIDE,PAY_HIDE,PAY_HIDE])
integer price = 10;

default
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_DEBIT)
            state cash;
    }
}

state cash
{
    state_entry()
    {
        llSetPayPrice(price, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
    }
    money(key id, integer amount)
    {
        if(amount != price)
        {
            llGiveMoney(id, amount);
            llInstantMessage(id, "You paid "+(string)amount+", which is the wrong price, the price is: "+(string)price);
        }
        else
        {
            //insert your give code here.
            llInstantMessage(id, "You paid the right price");
        }
    }
}

See Also

Events

•  money

Functions

•  llGiveMoney

Deep Notes

Tests

•  llSetPayPrice Test

Signature

function void llSetPayPrice( integer price, list quick_pay_buttons );