Difference between revisions of "User:Daemonika Nightfire/Scripts/Anti copy trans"

From Second Life Wiki
Jump to navigation Jump to search
m (a few minor readability improvements)
Line 12: Line 12:
*/
*/


// stored key's (UUID) of creator and reseller
// change the keys or add more if you like
list CreatorKey = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2","00000000-0000-0000-0000-000000000000"]; // expandable
list listOfCreatorOrResellerKeys = [
            "61ee201a-81cf-4322-b9a8-a5eb8da777c2",
            "00000000-0000-0000-0000-000000000000"];


////////// global function \\\\\\\\\\
check_script_permission_mask()
CorrectPerms?()
{
{
    string Script = llGetScriptName(); // ask for scriptname
     llSetText("", ZERO_VECTOR, 0.0);// black and transparent
     llSetText("", ZERO_VECTOR, 0.0); // clear floatingtext
 
      
    key ownerKey = llGetOwner();
     // compares the ownerkey with the key's in the list
     string thisScript = llGetScriptName();
     if(llListFindList(CreatorKey, llCSV2List(llGetOwner())) == -1)
 
//  pay attention to ~, it's bitwise NOT and not -
     integer foundOwnerKeyInListOfCreatorOrResellerKeys = ~llListFindList(listOfCreatorOrResellerKeys, [ownerKey]);
 
// when the owner can't be found in the list
     if (!foundOwnerKeyInListOfCreatorOrResellerKeys)
     {
     {
        // if the ownerkey don't match, the script will delete itself when permission copy & tranfer is given
    // if the ownerkey don't match, the script will delete itself when permission copy & tranfer is given
         integer MaskOwner = llGetInventoryPermMask(Script, MASK_OWNER);
         integer ownerPermMask = llGetInventoryPermMask(thisScript, MASK_OWNER);
         if((MaskOwner & PERM_TRANSFER) && (MaskOwner & PERM_COPY) != 0)
         if((ownerPermMask & PERM_TRANSFER) && (ownerPermMask & PERM_COPY))
         {
         {
             llOwnerSay("/me " + Script + ": Sorry, i was not made for you. Goodbye");
             llOwnerSay("/me " + thisScript + ": Sorry, i was not made for you. Goodbye!");
             llRemoveInventory(Script);
             llRemoveInventory(thisScript);
         }
         }
     }
     }
   
 
    // force the reseller to set (no copy) or (no trans), otherwise the script will not work
// force the reseller to set (no copy) or (no trans), otherwise the script will not work
     integer MaskNext = llGetInventoryPermMask(Script, MASK_NEXT);
     integer nextOwnerPermMask = llGetInventoryPermMask(Script, MASK_NEXT);
     if((MaskNext & PERM_TRANSFER) && (MaskNext & PERM_COPY) != 0)
     if((nextOwnerPermMask & PERM_TRANSFER) && (nextOwnerPermMask & PERM_COPY))
     {
     {
         llSetText("please correct the script-permission to:\n(copy/no transfer) or (no copy/transfer)", <1,1,0>, 1.0);
         llSetText("Please correct the script-permission to:\n"
         state Offline;
            + "(copy/no transfer) or (no copy/transfer)", <1.0, 1.0, 0.1>, 1.0);//  yellow and opaque
         state permsNotSetCorrectly;
     }
     }
}
}
Line 44: Line 51:
default
default
{
{
     state_entry()
     on_rez(integer start_param)
     {
     {
         CorrectPerms?(); // starts the global function
         llResetScript();
     }
     }


    touch_start(integer total_number) // just for show that it work
    {
        llSay(0, "Yay, script-permission correct.");
    }
   
     changed(integer change)
     changed(integer change)
     {
     {
         if(change & (CHANGED_OWNER|CHANGED_INVENTORY))
         if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
        {
             llResetScript();
             llResetScript();
        }
     }
     }
   
 
     on_rez(integer Dae)
     state_entry()
     {
     {
         llResetScript();
         check_script_permission_mask();
    }
 
    touch_start(integer num_detected)
    {
    //  uncomment next line for debug purposes
    //  llSay(PUBLIC_CHANNEL, "Yay, script-permission correct.");
     }
     }
}
}


state Offline
state permsNotSetCorrectly
{
{
     state_entry()
     on_rez(integer start_param)
     {
     {
         llOwnerSay("Sorry, please correct the script-permission");
         llResetScript();
     }
     }
   
 
     changed(integer change)
     changed(integer change)
     {
     {
         if(change & (CHANGED_OWNER|CHANGED_INVENTORY))
         if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
        {
             llResetScript();
             llResetScript();
        }
     }
     }
      
 
     on_rez(integer Dae)
     state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Sorry, please correct the script-permissions.");
    }
 
     touch_start(integer num_detected)
     {
     {
         llResetScript();
         llSay(PUBLIC_CHANNEL, "Sorry, please correct the script-permissions.");
     }
     }
}
}
</lsl>
</lsl>

Revision as of 12:59, 1 November 2012

*DS* Anti (copy & transfer)

This funktion allows you to give away scripts with copy & transfer permissions and force the reseller to change the permission. Additionally the script will delete itself when the customer of the reseller receives it with both permissions. Because it is a global function, it can be used universally.

Make sure that you not give away scripts with modify rights which contains this function.

<lsl> /*

   ╔═════════════════════════════════════−−−­­­­­­→
   ║ *DS* Anti (copy & transfer) © by Daemonika Nightfire (daemonika.nightfire)
   ╚══════════════════════−−−­­­→
  • /

// change the keys or add more if you like list listOfCreatorOrResellerKeys = [

           "61ee201a-81cf-4322-b9a8-a5eb8da777c2",
           "00000000-0000-0000-0000-000000000000"];

check_script_permission_mask() {

   llSetText("", ZERO_VECTOR, 0.0);//  black and transparent
   key ownerKey = llGetOwner();
   string thisScript = llGetScriptName();

// pay attention to ~, it's bitwise NOT and not -

   integer foundOwnerKeyInListOfCreatorOrResellerKeys = ~llListFindList(listOfCreatorOrResellerKeys, [ownerKey]);

// when the owner can't be found in the list

   if (!foundOwnerKeyInListOfCreatorOrResellerKeys)
   {
   //  if the ownerkey don't match, the script will delete itself when permission copy & tranfer is given
       integer ownerPermMask = llGetInventoryPermMask(thisScript, MASK_OWNER);
       if((ownerPermMask & PERM_TRANSFER) && (ownerPermMask & PERM_COPY))
       {
           llOwnerSay("/me " + thisScript + ": Sorry, i was not made for you. Goodbye!");
           llRemoveInventory(thisScript);
       }
   }

// force the reseller to set (no copy) or (no trans), otherwise the script will not work

   integer nextOwnerPermMask = llGetInventoryPermMask(Script, MASK_NEXT);
   if((nextOwnerPermMask & PERM_TRANSFER) && (nextOwnerPermMask & PERM_COPY))
   {
       llSetText("Please correct the script-permission to:\n"
           + "(copy/no transfer) or (no copy/transfer)", <1.0, 1.0, 0.1>, 1.0);//  yellow and opaque
       state permsNotSetCorrectly;
   }

}

default {

   on_rez(integer start_param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
           llResetScript();
   }
   state_entry()
   {
       check_script_permission_mask();
   }
   touch_start(integer num_detected)
   {
   //  uncomment next line for debug purposes
   //  llSay(PUBLIC_CHANNEL, "Yay, script-permission correct.");
   }

}

state permsNotSetCorrectly {

   on_rez(integer start_param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
           llResetScript();
   }
   state_entry()
   {
       llSay(PUBLIC_CHANNEL, "Sorry, please correct the script-permissions.");
   }
   touch_start(integer num_detected)
   {
       llSay(PUBLIC_CHANNEL, "Sorry, please correct the script-permissions.");
   }

} </lsl>