LSL Wiki Mirror 10-5-2006: llGetOwner

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings ::
key llGetOwner()

Returns the key of the owner of the scripted object.

Note: a script will only check to see its owner when llGetOwner is called. This can be annoying if you transfer ownership of the object to another user. If you're using llGetOwner in llListen or llRequestPermissions, consider putting llResetScript in the on_rez event, or even llListen in on_rez. Remember to remove your old listens with llListenRemove or they'll pile up! Depending on what you have in state_entry, llResetScript is usually the best method.

You can retrieve the owner of a specific object other than the one containing the script with llGetOwnerKey.

Examples:
default
{
    state_entry()
    {
        if (llDetectedOwner(0) == llGetOwner())
        {
            //do stuff
        }
    }
}


default {
    state_entry() {
        llListen(0, "", llGetOwner(), ""); // listen to my owner
    }
    
    listen(integer channel, string name, key id, string message) {
        llSay(0, name + " said: " + message); // repeat owner's text
    }
    
    on_rez(integer start_param) {
        // every time we're rezzed, reset the script
        // this ensures that if we're transferred to a new owner, we're listening to them and not still to the previous one
        llResetScript();
    }
}

Q: How do I get the owner's name instead?
A: If the owner is in the same sim as the object at the time it's called, (IE, if your script is within an attachment) use llKey2Name. Otherwise, you need to use llRequestAgentData and the dataserver event, which takes longer and is more complicated.


Functions | Keys
There is no comment on this page. [Display comments/form]