Difference between revisions of "LlRequestPermissions"

From Second Life Wiki
Jump to navigation Jump to search
m (Formatted some items in NOTES as a list)
 
(32 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/SVC-1006}}{{Issues/SVC-8067}}{{LSL_Function/avatar|agent|sim=*}}
|func=llRequestPermissions|sort=RequestPermissions
|func=llRequestPermissions|sort=RequestPermissions
|func_id=136|func_sleep=0.0|func_energy=10.0
|func_id=136|func_sleep=0.0|func_energy=10.0
|p1_type=key|p1_name=agent|p1_desc=Avatar key
|p1_type=key|p1_name=agent|p1_desc
|p2_type=integer|p2_name=perm|p2_desc=Permission mask (bitfield containing the permissions to request).
|p2_type=integer|p2_name=permissions|p2_desc=Permission mask ([[Bit field|bitfield]] containing the permissions to request).
|func_desc=Ask agent for permission to run certain classes of functions.
|func_desc=Ask {{LSLP|agent}} for {{LSLP|permissions}} to run certain classes of functions.
|func_footer=Script execution continues without waiting for a response. When a response is given, a [[run_time_permissions]] event is put in the event queue.  
|return_text
|return_text
|spec
|spec
|caveats=
|caveats=
*Permissions do not accumulate.
<div>
**If a permission was requested with a previous call to this function and granted, then in subsequent call was not requested, that permission is released (lost).
* A dialog is presented to the agent to grant these permissions except when granted automatically as shown in the table above.
*Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more then one script.
* If object is attached to agent, "automatic" permissions are granted without notification upon request.
|examples
* Permissions persist across state changes.
* Regardless of whether granting is automatic, you should always use the [[run_time_permissions]] event.  Granting permissions takes time, and you shouldn't assume it's completed until the [[run_time_permissions]] handler gets invoked.
* The menu-option "Stop Animating Me" will release certain permissions (PERMISSION_TRIGGER_ANIMATION and PERMISSION_OVERRIDE_ANIMATIONS), if the script which holds these permissions is in the same region as the agent, and the script is not attached to the permission granter.
* Permissions do not accumulate.
** If a permission was requested with a previous call to this function and granted, then in subsequent call was not requested, that permission is released (lost).
** To request two or more permissions at the same time, use the bitwise OR <nowiki>(|) operator, e.g.:</nowiki> <source lang="lsl2">llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)</source>
</div>
* Permissions are requested and granted separately for each script, even if they are located in the same object.
* It is currently not possible to request no permissions at all (see Issues below); as a workaround [[llResetScript]] can be used.
* Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more than one script.
* The result of granting permissions affects the return of [[llGetPermissions]] and [[llGetPermissionsKey]] immediately, despite the [[run_time_permissions]] event being queued, or dropped if the object's event queue is full.
* Permission request dialogs never time out.
* If a script makes two permission requests, whichever response is last is considered the granted permissions.
* The viewer limits permission requests from any agent to any other agent to 5 dialogs in 10 seconds.
* Permission requests and changing state ...
** Requesting a permission in one state, then changing state before the agent response, will cause [[run_time_permissions]] to be fired in the new state once the agent responds.
** Requesting only auto-granted permissions in one state, then immediately changing state, will never fire [[run_time_permissions]].
|notes=When an agent grants a script non-automatic permissions they will receive a notification (in chat) of
* The '''name''' of the object that contains the script that has been granted perms,
* The name of the owner of the object,
* The location of the object in the order Region name at '''position''', and
* A statement of what permissions were granted.
If the script that holds the permissions is in a child prim the '''name''' will be that of the child prim (not the object (root)) and '''position''' will be its [[llGetLocalPos|local]] position (relative to its root).
|examples=Request permission to animate an avatar
<source lang="lsl2">default
{
    touch_start(integer detected)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("sit");
            llOwnerSay("animation will end in 5 seconds");
            llSetTimerEvent(5.0);
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llStopAnimation("sit");
    }
}</source>
 
To request two (or more) permissions at the same time, use the bitwise OR <nowiki>(|)</nowiki> [[LSL_Operators|operator]].
<source lang="lsl2">llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);</source>
: - or -
<source lang="lsl2">integer perms = PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION;
llRequestPermissions(AvatarID, perms);</source>
 
|helpers
|helpers
|also_events={{LSL DefineRow||{{LSLG|run_time_permissions}}|Permission receiver event}}
|also_events={{LSL DefineRow||[[run_time_permissions]]|Permission receiver event}}
|also_functions={{LSL DefineRow||{{LSLG|llGetPermissions}}|Get the permissions granted}}
|also_functions={{LSL DefineRow||[[llGetPermissions]]|Get the permissions granted}}
{{LSL DefineRow||{{LSLG|llGetPermissionsKey}}|Get the avatar who granted permissions.}}
{{LSL DefineRow||[[llGetPermissionsKey]]|Get the avatar who granted permissions.}}
|also_articles={{LSL DefineRow||{{LSLGC|Permissions/Script|Script permissions}}|}}
|also_articles={{LSL DefineRow||{{LSLGC|Permissions/Script|Script permissions}}|}}
|notes = A dialog is presented to the agent to grant these permissions except for a few cases:
* If agent is sitting on object - Control and Camera tracking permissions are granted without notification upon request.
* If object is attached to agent - Control and Attach permissions are granted without notification upon request.
Regardless if a dialog is displayed you should always use the {{LSLG|run_time_permissions}} event instead of depending upon this quirk.
|constants={{LSL Constants/Permissions}}
|constants={{LSL Constants/Permissions}}
|cat1=Permissions/Script
|cat1=Permissions/Script

Latest revision as of 08:59, 3 August 2021

Summary

Function: llRequestPermissions( key agent, integer permissions );
0.0 Forced Delay
10.0 Energy

Ask agent for permissions to run certain classes of functions.

• key agent avatar UUID that is in the same region
• integer permissions Permission mask (bitfield containing the permissions to request).

Script execution continues without waiting for a response. When a response is given, a run_time_permissions event is put in the event queue.

Constants Action Category Granter Automatically granted when…
PERMISSION_DEBIT 0x2 take money from agent's account Money Owner
PERMISSION_TAKE_CONTROLS 0x4 take agent's controls Control Anyone sat on, attached
PERMISSION_TRIGGER_ANIMATION 0x10 start or stop Animations on agent Animation Anyone sat on, attached
PERMISSION_ATTACH 0x20 attach/detach from agent Attachment Owner or Anyone attached
PERMISSION_CHANGE_LINKS 0x80 change links Link Owner
PERMISSION_TRACK_CAMERA 0x400 track the agent's camera position and rotation Camera Anyone sat on, attached
PERMISSION_CONTROL_CAMERA 0x800 control the agent's camera
(must be sat on or attached; automatically revoked on stand or detach)
Camera Anyone sat on, attached
PERMISSION_TELEPORT 0x1000 teleport the agent Teleport Anyone[1]
PERMISSION_SILENT_ESTATE_MANAGEMENT 0x4000 manage estate access without notifying the owner of changes Estate Owner
PERMISSION_OVERRIDE_ANIMATIONS 0x8000 configure the overriding of default animations on agent Animation Anyone attached
PERMISSION_RETURN_OBJECTS 0x10000 Used by llReturnObjectsByOwner and llReturnObjectsByID to return objects from parcels Cleanup Owner, Group Owner

Caveats

  • A dialog is presented to the agent to grant these permissions except when granted automatically as shown in the table above.
  • If object is attached to agent, "automatic" permissions are granted without notification upon request.
  • Permissions persist across state changes.
  • Regardless of whether granting is automatic, you should always use the run_time_permissions event. Granting permissions takes time, and you shouldn't assume it's completed until the run_time_permissions handler gets invoked.
  • The menu-option "Stop Animating Me" will release certain permissions (PERMISSION_TRIGGER_ANIMATION and PERMISSION_OVERRIDE_ANIMATIONS), if the script which holds these permissions is in the same region as the agent, and the script is not attached to the permission granter.
  • Permissions do not accumulate.
    • If a permission was requested with a previous call to this function and granted, then in subsequent call was not requested, that permission is released (lost).
    • To request two or more permissions at the same time, use the bitwise OR (|) operator, e.g.:
      llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)
      
  • Permissions are requested and granted separately for each script, even if they are located in the same object.
  • It is currently not possible to request no permissions at all (see Issues below); as a workaround llResetScript can be used.
  • Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more than one script.
  • The result of granting permissions affects the return of llGetPermissions and llGetPermissionsKey immediately, despite the run_time_permissions event being queued, or dropped if the object's event queue is full.
  • Permission request dialogs never time out.
  • If a script makes two permission requests, whichever response is last is considered the granted permissions.
  • The viewer limits permission requests from any agent to any other agent to 5 dialogs in 10 seconds.
  • Permission requests and changing state ...
    • Requesting a permission in one state, then changing state before the agent response, will cause run_time_permissions to be fired in the new state once the agent responds.
    • Requesting only auto-granted permissions in one state, then immediately changing state, will never fire run_time_permissions.

Examples

Request permission to animate an avatar

default
{
    touch_start(integer detected)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("sit");
            llOwnerSay("animation will end in 5 seconds");
            llSetTimerEvent(5.0);
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llStopAnimation("sit");
    }
}

To request two (or more) permissions at the same time, use the bitwise OR (|) operator.

llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
- or -
integer perms = PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION;
llRequestPermissions(AvatarID, perms);

Notes

When an agent grants a script non-automatic permissions they will receive a notification (in chat) of

  • The name of the object that contains the script that has been granted perms,
  • The name of the owner of the object,
  • The location of the object in the order Region name at position, and
  • A statement of what permissions were granted.

If the script that holds the permissions is in a child prim the name will be that of the child prim (not the object (root)) and position will be its local position (relative to its root).

See Also

Events

•  run_time_permissions Permission receiver event

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the avatar who granted permissions.

Articles

•  Script permissions

Deep Notes

Footnotes

Signature

function void llRequestPermissions( key agent, integer permissions );