Jump to content

Limiting a Script to work only on a specific sim/estate


Victoria Bennett
 Share

You are about to reply to a thread that has been inactive for 150 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Sure.  The LSL function llGetParcelDetails has a parameter PARCEL_DETAILS_NAME that you can use to find out what parcel your scripted object is in.  So, you run a timer that checks that function every once in a while.  If the answer is that the object is not in the parcel where you want it to be active, you just tell the script to change states. Do the same thing in reverse in the new state.  Generically, something like this....

default
{
     state_entry ()
     {
          llSetTimerEvent(5.0);
     }

    // and a bunch of other events that do important stuff

     timer ()
     {
          string Parcel = llList2String(llGetParcelDetails( llGetPos(),PARCEL_DETAILS_NAME),0);
          if ( Parcel != strMy_Parcel_Name )
          {
               state sleep;
          }
      }
}

state sleep
{
      state_entry()
      {
            llSetTimerEvent(5.0);
      }

      timer()
      {
          string Parcel = llList2String(llGetParcelDetails( llGetPos(),PARCEL_DETAILS_NAME),0);
          if ( Parcel == strMy_Parcel_Name )  // And obviously, if not, stay right here, sleeping
          {
               state default;
          }
       }
}

where you substitute your parcel's name in place of strMy_Parcel_Name   .  You could use PARCEL_DETAILS_ID if you wanted to avoid the possibility that some other parcel has precisely the same name as yours.  And if you want to check for the entire region, do exactly the same thing, using llGetRegionName().

    

Edited by Rolig Loon
Additional information
  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...

I this always worked for me in the past when I was doing demos on scripted items.

I don't recommend using PARCEL_DETAILS_NAME all someone has to do is go to there own land and rename it and the script will work just fine for them.

 

string Allow_Region = "Your Region Name";

integer Permission(string region)
{
    integer hasPermission = FALSE;
    if (region == Allow_Region)
    {
        hasPermission = TRUE;
    }
    return hasPermission;
}


default
{
    changed(integer change)
    {
        string region = llGetRegionName();
        if (change & CHANGED_OWNER) 
        {
            llResetScript();
        }
        
        if (change & CHANGED_REGION) 
        {
            if (Permission(region) == TRUE)
            {
                
            }
        }
        
        if (change & CHANGED_TELEPORT) 
        {
            if (Permission(region) == TRUE)
            {
                
            }
        }
        
        if (change & CHANGED_REGION_START) 
        {
            if (Permission(region) == TRUE)
            {
                
            }
        }
    }
}

 

Link to comment
Share on other sites

Quote
On 1/1/2023 at 8:36 AM, Casey Conundrum said:

I this always worked for me in the past when I was doing demos on scripted items.

I don't recommend using PARCEL_DETAILS_NAME all someone has to do is go to there own land and rename it and the script will work just fine for them.

They'd have to be determined for that script to work, but yes, for higher focus, you could use PARCEL_DETAILS_ID for parcel recognition.

Edited by Bugs Larnia
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 150 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...