Difference between revisions of "LlGetPermissionsKey"

From Second Life Wiki
Jump to navigation Jump to search
(The described behavior was incorrect; if an avatar rejects a permission request, this function will return the rejecting avatar's key. See SVC-6229 and VWR-20485 for details.)
(added example)
Line 9: Line 9:
|caveats
|caveats
|constants
|constants
|examples
|examples=
<lsl>
// 1. rez a cube
// 2. create a new script and paste this
// 3. save script
// 4. right-click the prim and choose attach
// 5. touch the prim
 
announce_permissions_key()
{
    key permissionsKey = llGetPermissionsKey();
 
    // PUBLIC_CHANNEL has the integer value 0
    llSay(PUBLIC_CHANNEL,
        "key llGetPermissionsKey() = '" + (string)permissionsKey + "'");
}
 
default
{
    state_entry()
    {
        announce_permissions_key();
 
        key owner = llGetOwner();
        llRequestPermissions(owner, PERMISSION_ATTACH);
    }
 
    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);
        key owner = llGetOwner();
        key permissionsKey = llGetPermissionsKey();
 
        if (id == owner)
        {
            if (permissionsKey == owner)
                llDetachFromAvatar();
            else
                llSay(PUBLIC_CHANNEL, "Can't detach from you, you have not granted ATTACH perms.");
        }
        else
            llSay(PUBLIC_CHANNEL, "Sorry, you're not the owner!");
    }
 
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_ATTACH)
            announce_permissions_key();
    }
}
</lsl>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetPermissions]]|}}
|also_functions={{LSL DefineRow||[[llGetPermissions]]|}}

Revision as of 15:06, 6 October 2012

Summary

Function: key llGetPermissionsKey( );

Returns the key of the avatar that last granted or declined permissions to the script.

Returns NULL_KEY if permissions were never granted or declined.

Caveats

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llGetPermissionsKey() doesn't return NULL_KEY when permissions are declined

Examples

<lsl> // 1. rez a cube // 2. create a new script and paste this // 3. save script // 4. right-click the prim and choose attach // 5. touch the prim

announce_permissions_key() {

   key permissionsKey = llGetPermissionsKey();
   // PUBLIC_CHANNEL has the integer value 0
   llSay(PUBLIC_CHANNEL,
       "key llGetPermissionsKey() = '" + (string)permissionsKey + "'");

}

default {

   state_entry()
   {
       announce_permissions_key();
       key owner = llGetOwner();
       llRequestPermissions(owner, PERMISSION_ATTACH);
   }
   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       key owner = llGetOwner();
       key permissionsKey = llGetPermissionsKey();
       if (id == owner)
       {
           if (permissionsKey == owner)
               llDetachFromAvatar();
           else
               llSay(PUBLIC_CHANNEL, "Can't detach from you, you have not granted ATTACH perms.");
       }
       else
           llSay(PUBLIC_CHANNEL, "Sorry, you're not the owner!");
   }
   run_time_permissions(integer perm)
   {
       if (perm & PERMISSION_ATTACH)
           announce_permissions_key();
   }

}

</lsl>

See Also

Events

•  run_time_permissions

Functions

•  llGetPermissions
•  llRequestPermissions

Deep Notes

All Issues

~ Search JIRA for related Issues
   llGetPermissionsKey() doesn't return NULL_KEY when permissions are declined

Signature

function key llGetPermissionsKey();