OsNpcGetOwner

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "{{osslfunc |function_syntax=key osNpcGetOwner(key npc) |csharp_syntax= |description=Gets the NPC's owner's UUID |threat_level=none |ossl_example= |additional_info= }}")
 
m (Remove empty line)
 
(7 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
|csharp_syntax=
 
|csharp_syntax=
 
|description=Gets the NPC's owner's UUID
 
|description=Gets the NPC's owner's UUID
|threat_level=none
+
|threat_level=None
 +
|permissions=${OSSL|osslNPC}
 +
|delay=0
 
|ossl_example=
 
|ossl_example=
|additional_info=
+
'''With OS_NPC_CREATOR_OWNED:'''
 +
<source lang="lsl">
 +
//
 +
// osNpcGetOwner Script Exemple
 +
// Author: djphil
 +
//
 +
 
 +
key npc;
 +
 
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");
 +
        llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_CREATOR_OWNED.");
 +
    }
 +
 
 +
    touch_start(integer number)
 +
    {
 +
        key toucher = llDetectedKey(0);
 +
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
 +
        osAgentSaveAppearance(toucher, "appearance");
 +
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance", OS_NPC_CREATOR_OWNED);
 +
        state hasNPC;
 +
    }
 +
}
 +
 
 +
state hasNPC
 +
{
 +
    state_entry()
 +
    {
 +
        llSetTimerEvent(5.0);
 +
    }
 +
 
 +
    timer()
 +
    {
 +
        llSetTimerEvent(0.0);
 +
        key npc_owner = osNpcGetOwner(npc);
 +
        osNpcSay(npc, "Hello world!");
 +
        osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");
 +
    }
 +
 
 +
    touch_start(integer number)
 +
    {
 +
        osNpcSay(npc, "Goodbye!");
 +
        llSetTimerEvent(0.0);
 +
        osNpcRemove(npc);
 +
        npc = NULL_KEY;
 +
        state default;
 +
    }
 +
}
 +
</source>
 +
'''With OS_NPC_NOT_OWNED:''' (It Needs the setting '''AllowNotOwned''' on '''true''' in section '''[NPC]''' of your OpenSim.ini)
 +
<source lang="lsl">
 +
//
 +
// osNpcGetOwner Script Exemple
 +
// Author: djphil
 +
//
 +
 
 +
key npc;
 +
 
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");
 +
        llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NOT_OWNED.");
 +
    }
 +
 
 +
    touch_start(integer number)
 +
    {
 +
        key toucher = llDetectedKey(0);
 +
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
 +
        osAgentSaveAppearance(toucher, "appearance");
 +
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance", OS_NPC_NOT_OWNED);
 +
        state hasNPC;
 +
    }
 +
}
 +
 
 +
state hasNPC
 +
{
 +
    state_entry()
 +
    {
 +
        llSetTimerEvent(5.0);
 +
    }
 +
 
 +
    timer()
 +
    {
 +
        llSetTimerEvent(0.0);
 +
        key npc_owner = osNpcGetOwner(npc);
 +
        osNpcSay(npc, "Hello world!");
 +
        osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");
 +
    }
 +
 
 +
    touch_start(integer number)
 +
    {
 +
        osNpcSay(npc, "Goodbye!");
 +
        llSetTimerEvent(0.0);
 +
        osNpcRemove(npc);
 +
        npc = NULL_KEY;
 +
        state default;
 +
    }
 +
}
 +
</source>
 +
|additional_info=This function was added in 0.7.3-post-fixes
 
}}
 
}}

Latest revision as of 09:20, 4 December 2020

key osNpcGetOwner(key npc)
Gets the NPC's owner's UUID
Threat Level None
Permissions ${OSSL|osslNPC}
Extra Delay 0 seconds
Example(s)
With OS_NPC_CREATOR_OWNED:
//
// osNpcGetOwner Script Exemple
// Author: djphil
//
 
key npc;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");
        llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_CREATOR_OWNED.");
    }
 
    touch_start(integer number)
    {
        key toucher = llDetectedKey(0);
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
        osAgentSaveAppearance(toucher, "appearance");
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance", OS_NPC_CREATOR_OWNED);
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        llSetTimerEvent(5.0);
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        key npc_owner = osNpcGetOwner(npc);
        osNpcSay(npc, "Hello world!");
        osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Goodbye!");
        llSetTimerEvent(0.0);
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}

With OS_NPC_NOT_OWNED: (It Needs the setting AllowNotOwned on true in section [NPC] of your OpenSim.ini)

//
// osNpcGetOwner Script Exemple
// Author: djphil
//
 
key npc;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");
        llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NOT_OWNED.");
    }
 
    touch_start(integer number)
    {
        key toucher = llDetectedKey(0);
        vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
        osAgentSaveAppearance(toucher, "appearance");
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance", OS_NPC_NOT_OWNED);
        state hasNPC;
    }
}
 
state hasNPC
{
    state_entry()
    {
        llSetTimerEvent(5.0);
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        key npc_owner = osNpcGetOwner(npc);
        osNpcSay(npc, "Hello world!");
        osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");
    }
 
    touch_start(integer number)
    {
        osNpcSay(npc, "Goodbye!");
        llSetTimerEvent(0.0);
        osNpcRemove(npc);
        npc = NULL_KEY;
        state default;
    }
}
Notes
This function was added in 0.7.3-post-fixes
Personal tools
General
About This Wiki