User/Digit Ditko/experience transport script

From Second Life Wiki
Jump to navigation Jump to search

Transport an avatar and use experience permissions

// use a regoins coordinates here to transport avatar to another region.
vector gRegion = ZERO_VECTOR; 

// region specific location
vector gPos = <128.0, 128.0, 100.0>;

// Avatar will face this direction
vector gLookAt = <0.0, 0.0, 0.0>;


// -----------------------------------------------------------------------------
// Default state
default
{
    collision_start (integer inNumDetected)
    { 
        integer i;
        for (i = 0; i < inNumDetected; i++)
        {
            llRequestExperiencePermissions (llDetectedKey (i), "");
        }
    }
     
    experience_permissions (key inAvatar)
    {   
        if (gRegion == ZERO_VECTOR)
        {
            llTeleportAgent (inAvatar, "", gPos, gLookAt); 
        }   
        else
        {
            llTeleportAgentGlobalCoords (inAvatar, gRegion, gPos, gLookAt);
        }
    }
    
    
    on_rez (integer inParam)
    {
        llResetScript ();
    }
    
    
    changed (integer inMask)
    {   
        if (inMask & (CHANGED_INVENTORY | CHANGED_OWNER))
        {
            llResetScript ();
        }      
    }
}