Difference between revisions of "Group Authorization"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '<lsl> //============================================================ //© 2009 Chase Quinnell and TerraCo Designs // http://www.terracodesigns.com //Please keep this open so...')
 
m (<lsl> tag to <source>)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<lsl>
{{LSL Header}}
//============================================================
//© 2009 Chase Quinnell and TerraCo Designs
//      http://www.terracodesigns.com
//Please keep this open source and leave my name reference here


==Group Authorization==


This script is used to check whether the object is set to the appropriate [[group]] (by group key).




//AUTHORIZED GROUP KEYS
==The Script==
//This is the group key for the authorized group.
string authgroupkey = "INSERT YOUR GROUP KEY HERE";


//============================================================
<source lang="lsl2">
// © 2009 Chase Quinnell and TerraCo Designs
//  http://www.terracodesigns.com
//  Please keep this open source and leave my name reference here


//  This is the group key for the authorized group.
string authgroupkey = "INSERT YOUR GROUP KEY HERE";


Unauthorized()
Unauthorized()
{
{
     llOwnerSay("Authorization failed.");
    string thisScript = llGetScriptName();
 
     llOwnerSay("/me [" + thisScript + "]: Sorry, you're wearing the wrong group tag.");
     llDetachFromAvatar();
     llDetachFromAvatar();
     llDie();  
    llRemoveInventory(thisScript);
     llDie();
}
}


default
default
{
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
     state_entry()
     state_entry()
     {
     {
          
         key ownerKey = llGetOwner();
         llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
         llRequestPermissions(ownerKey, PERMISSION_ATTACH);
         key id = llGetOwner();
 
         list group = llGetObjectDetails(llGetKey(), [OBJECT_GROUP]);
         key thisPrimsKey = llGetKey();
            //gets the group key of the object
         string groupKey = llList2String(llGetObjectDetails(thisPrimsKey, [OBJECT_GROUP]), 0);
       
 
       
         if (groupKey != authgroupkey)
         if ((llList2String(group,0) != authgroupkey))
             Unauthorized();
             //checks object group key
         else
            //if it does not match, then it is unauthorized
        {
          Unauthorized();
          //queue unauthorized subroutine
        }
         else  
        {
             llOwnerSay("Authorization passed");
             llOwnerSay("Authorization passed");
        }
     }
     }
     on_rez(integer tcauth_chk)
 
     run_time_permissions(integer perm)
     {
     {
         llResetScript();
         if (!(perm & PERMISSION_ATTACH))
        //resets script on_rez so that it knows who owns it.
            llResetScript();
     }
     }
}
}
 
</source>
</lsl>

Latest revision as of 21:29, 24 January 2015

Group Authorization

This script is used to check whether the object is set to the appropriate group (by group key).


The Script

//  © 2009 Chase Quinnell and TerraCo Designs
//  http://www.terracodesigns.com
//  Please keep this open source and leave my name reference here

//  This is the group key for the authorized group.
string authgroupkey = "INSERT YOUR GROUP KEY HERE";

Unauthorized()
{
    string thisScript = llGetScriptName();

    llOwnerSay("/me [" + thisScript + "]: Sorry, you're wearing the wrong group tag.");
    llDetachFromAvatar();
    llRemoveInventory(thisScript);
    llDie();
}

default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }

    state_entry()
    {
        key ownerKey = llGetOwner();
        llRequestPermissions(ownerKey, PERMISSION_ATTACH);

        key thisPrimsKey = llGetKey();
        string groupKey = llList2String(llGetObjectDetails(thisPrimsKey, [OBJECT_GROUP]), 0);

        if (groupKey != authgroupkey)
            Unauthorized();
        else
            llOwnerSay("Authorization passed");
    }

    run_time_permissions(integer perm)
    {
        if (!(perm & PERMISSION_ATTACH))
            llResetScript();
    }
}