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)
m (<lsl> tag to <source>)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
  Make sure that you not give away scripts with modify rights which contains this function.
  Make sure that you not give away scripts with modify rights which contains this function.


<lsl>
<source lang="lsl2">
/*
/*
     ╔═════════════════════════════════════−−−­­­­­­→
     ╔═════════════════════════════════════−−−­­­­­­→
Line 12: Line 12:
*/
*/


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


check_script_permission_mask()
////////// global function \\\\\\\\\\
CorrectPerms?()
{
{
     llSetText("", ZERO_VECTOR, 0.0);// black and transparent
    string Script = llGetScriptName(); // ask for scriptname
 
     llSetText("", ZERO_VECTOR, 0.0); // clear floatingtext
     key ownerKey = llGetOwner();
      
     string thisScript = llGetScriptName();
     // compares the ownerkey with the key's in the list
 
     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 ownerPermMask = llGetInventoryPermMask(thisScript, MASK_OWNER);
         integer MaskOwner = llGetInventoryPermMask(Script, MASK_OWNER);
         if((ownerPermMask & PERM_TRANSFER) && (ownerPermMask & PERM_COPY))
         if((MaskOwner & PERM_TRANSFER) && (MaskOwner & PERM_COPY) != 0)
         {
         {
             llOwnerSay("/me " + thisScript + ": Sorry, i was not made for you. Goodbye!");
             llOwnerSay("/me " + Script + ": Sorry, i was not made for you. Goodbye");
             llRemoveInventory(thisScript);
             llRemoveInventory(Script);
         }
         }
     }
     }
 
   
// 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 nextOwnerPermMask = llGetInventoryPermMask(Script, MASK_NEXT);
     integer MaskNext = llGetInventoryPermMask(Script, MASK_NEXT);
     if((nextOwnerPermMask & PERM_TRANSFER) && (nextOwnerPermMask & PERM_COPY))
     if((MaskNext & PERM_TRANSFER) && (MaskNext & PERM_COPY) != 0)
     {
     {
         llSetText("Please correct the script-permission to:\n"
         llSetText("please correct the script-permission to:\n(copy/no transfer) or (no copy/transfer)", <1,1,0>, 1.0);
            + "(copy/no transfer) or (no copy/transfer)", <1.0, 1.0, 0.1>, 1.0);//  yellow and opaque
         state Offline;
         state permsNotSetCorrectly;
     }
     }
}
}
Line 51: Line 44:
default
default
{
{
     on_rez(integer start_param)
     state_entry()
     {
     {
         llResetScript();
         CorrectPerms?(); // starts the global function
     }
     }


    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();
        }
     }
     }
 
   
     state_entry()
     on_rez(integer Dae)
     {
     {
         check_script_permission_mask();
         llResetScript();
    }
 
    touch_start(integer num_detected)
    {
    //  uncomment next line for debug purposes
    //  llSay(PUBLIC_CHANNEL, "Yay, script-permission correct.");
     }
     }
}
}


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

Latest revision as of 19:17, 24 January 2015

*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.
/*
    ╔═════════════════════════════════════−−−­­­­­­→
    ║ *DS* Anti (copy & transfer) © by Daemonika Nightfire (daemonika.nightfire)
    ╚══════════════════════−−−­­­→
*/

// stored key's (UUID) of creator and reseller
list CreatorKey = ["61ee201a-81cf-4322-b9a8-a5eb8da777c2","00000000-0000-0000-0000-000000000000"]; // expandable

////////// global function \\\\\\\\\\
CorrectPerms?()
{
    string Script = llGetScriptName(); // ask for scriptname
    llSetText("", ZERO_VECTOR, 0.0); // clear floatingtext
    
    // compares the ownerkey with the key's in the list
    if(llListFindList(CreatorKey, llCSV2List(llGetOwner())) == -1)
    {
        // if the ownerkey don't match, the script will delete itself when permission copy & tranfer is given
        integer MaskOwner = llGetInventoryPermMask(Script, MASK_OWNER);
        if((MaskOwner & PERM_TRANSFER) && (MaskOwner & PERM_COPY) != 0)
        {
            llOwnerSay("/me " + Script + ": Sorry, i was not made for you. Goodbye");
            llRemoveInventory(Script);
        }
    }
    
    // force the reseller to set (no copy) or (no trans), otherwise the script will not work
    integer MaskNext = llGetInventoryPermMask(Script, MASK_NEXT);
    if((MaskNext & PERM_TRANSFER) && (MaskNext & PERM_COPY) != 0)
    {
        llSetText("please correct the script-permission to:\n(copy/no transfer) or (no copy/transfer)", <1,1,0>, 1.0);
        state Offline;
    }
}

default
{
    state_entry()
    {
        CorrectPerms?(); // starts the global function
    }

    touch_start(integer total_number) // just for show that it work
    {
        llSay(0, "Yay, script-permission correct.");
    }
    
    changed(integer change)
    {
        if(change & (CHANGED_OWNER|CHANGED_INVENTORY))
        {
            llResetScript();
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}

state Offline
{
    state_entry()
    {
        llOwnerSay("Sorry, please correct the script-permission");
    }
    
    changed(integer change)
    {
        if(change & (CHANGED_OWNER|CHANGED_INVENTORY))
        {
            llResetScript();
        }
    }
    
    on_rez(integer Dae)
    {
        llResetScript();
    }
}