Money
Objects can receive L$ from avatars and, with the owner’s permission, pay L$ out. Vendors, tip jars, rentals and games are built from these few functions.
Receiving needs no permission: the money event fires when someone pays the object. Paying out needs PERMISSION_DEBIT, granted by the owner. Handle it carefully, because a bug can spend the owner’s money.
Concepts
- Receiving payments
- The
moneyevent fires when someone pays the object - The pay dialog shows a default amount and quick-pay buttons, which the script
controls - Set the click action to
payto open it on click
- The
- Paying out
- The owner grants
PERMISSION_DEBITthroughllRequestPermissions llTransferLindenDollarsreturns a transaction key, and reports success or failure intransaction_resultllGiveMoneyis the older call with no result
- The owner grants
- Vendors
- After payment, a vendor checks the amount and gives the item, refunding wrong amounts
- Several items can be given as a folder, and agent data can be looked up
Functions and events
event | money(key id, integer amount) |
void | llSetPayPrice(integer price, list quick_pay_buttons) |
key | llTransferLindenDollars(key destination, integer amount) |
event | transaction_result(key id, integer success, string data) |
integer | llGiveMoney(key destination, integer amount) |
void | llGiveInventory(key target, string item) |
Money on the wiki
The wiki’s category of money functions and events.
Scripting Details
event | money(key id, integer amount)Triggered when a resident specified by id pays an amount of Linden dollars (L$) to the prim. |
void | llSetPayPrice(integer price, list quick_pay_buttons)Suggests default amounts for the pay text input field price and the four payment dialog quick_pay_buttons when an avatar pays this object. |
void | llSetClickAction(integer action)Sets the action (a CLICK_ACTION_* flag) performed when an avatar left-clicks the prim. |
integer | CLICK_ACTION_PAY = 3Opens the pay dialog when the prim is clicked or touched. |
void | llRequestPermissions(key agent, integer permissions)Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution. |
integer | PERMISSION_DEBIT = 0x00002Runtime permission that allows the script to successfully call llGiveMoney or llTransferLindenDollars to debit the owner's account. |
key | llTransferLindenDollars(key destination, integer amount)Transfers amount of L$ from the script owner to the destination avatar, requiring the PERMISSION_DEBIT permission. Returns a key query handle matching the resulting transaction_result event. |
event | transaction_result(key id, integer success, string data)Triggered when an asynchronous L$ transfer (such as llTransferLindenDollars) is completed. Passes transaction info id, success status, and CSV or error data. |
integer | llGiveMoney(key destination, integer amount)Transfers the specified amount of L$ from the script owner to the destination avatar. Silently fails if the PERMISSION_DEBIT permission has not been granted. Returns 0 (use llTransferLindenDollars to match transactions to transaction_result events). |
void | llGiveInventory(key target, string item)Gives the specified inventory item to the target, as permitted by the permissions system. The target can be any agent or an object located in the same region. |
integer | llGiveAgentInventory(key agent, string folder, list items, list options)Gives the specified inventory items to the agent as a new folder named folder, as permitted by the permissions system. Customizes the transfer using options. |
key | llRequestAgentData(key id, integer data)Asynchronously requests the specified data category (DATA_*) about the agent id. Triggers a dataserver event with the results and returns a key query handle. |
Additional
llSetPayPrice— suggests the default amount and the four quick-pay buttons (pay buttons)PAY_HIDE— hide the specified quick pay button completelyPAY_DEFAULT— use the default value for the specified quick pay button
llSetClickActionCLICK_ACTION_PAY— opens the pay dialog when the prim is clicked or touched
transaction_result— on failure, reports a transfer error
Receiving payments
Section titled “Receiving payments”Constant groups PayButton 2
Paying out
Section titled “Paying out”Constant groups TransferError 8
Related
Section titled “Related”See also Category MoneySL Wiki LSL MoneyFeature AvatarsFeature Parcels & RegionsSL Wiki Script library: moneyPlanned Recipe: vendor with refunds