OsNpcRemove

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m
m (Change See Also)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
 +
|function_syntax=osNpcRemove(key npc)
 +
|csharp_syntax=
 +
|description=*Removes the NPC specified by key '''npc'''.
 
|threat_level=High
 
|threat_level=High
|function_syntax=void osNpcRemove(key npc)
+
|permissions=${OSSL|osslNPC}
|ossl_example =It might be helpful to erase all of the NPCs in your sim.
+
|delay=0
 +
|ossl_example=This might be helpful to erase all of the NPCs in your sim.
 
<source lang="lsl">
 
<source lang="lsl">
// sim-wide NPC killer
+
//
// kill all of NPCs in this SIM
+
// osNpcRemove Script Exemple
// Attempts to kill agents too, but it will silently fail
+
// Author: djphil
// http://opensimulator.org/wiki/OsNpcRemove
+
//
 
   
 
   
 
default
 
default
 
{
 
{
 +
    state_entry()
 +
    {
 +
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcRemove usage.");
 +
    }
 +
 
     touch_start(integer number)
 
     touch_start(integer number)
 
     {
 
     {
         list avatars = llList2ListStrided(osGetAvatarList(), 0, -1, 3);
+
         list npcs = llList2ListStrided(osGetNPCList(), 0, -1, 3);
         integer i;
+
          
         llSay(0,"NPC Removal: No avatars will be harmed or removed in this process!");
+
         if (npcs == [])
         for (i=0; i<llGetListLength(avatars); i++)
+
        {
 +
            llSay(PUBLIC_CHANNEL, "There is no NPC's in this sim currently.");
 +
         }
 +
       
 +
        else
 
         {
 
         {
             string target = llList2String(avatars, i);
+
             integer length = llGetListLength(npcs);
             osNpcRemove(target);
+
             integer i;
             llSay(0,"NPC Removal: Target "+target);
+
   
 +
            for (i = 0; i < length; i++)
 +
             {
 +
                key npc = llList2Key(npcs, i);
 +
                llSay(PUBLIC_CHANNEL, "Remove NPC: " + npc + " (" + llKey2Name(npc) + ").");
 +
                osNpcSay(npc, "Goodbye!");
 +
                osNpcRemove(npc);
 +
            }
 
         }
 
         }
 
     }
 
     }
 
}
 
}
    </source>
+
</source>
See [[osNpcCreate]] for another example.
+
|additional_info=If the '''NPC''' is the UUID of any other type of agent (i.e. a user's regular avatar, not an NPC), this function will silently fail, not erasing existing avatar.<br>
|description=*Removes the avatar who has specified by '''npc'''.
+
In other words, this function does not work on regular avatars but only on NPCs
*If the '''npc''' is the UUID of any agent (or users, not NPC), this function will silently fail, not erasing existing avatar.
+
|
+
 
}}
 
}}
 +
== See Also ==
 +
* [[osNpcCreate]]
 +
* [[osNpcRemove]]

Latest revision as of 18:52, 5 December 2020

osNpcRemove(key npc)
  • Removes the NPC specified by key npc.
Threat Level High
Permissions ${OSSL
Extra Delay 0 seconds
Example(s)
This might be helpful to erase all of the NPCs in your sim.
//
// osNpcRemove Script Exemple
// Author: djphil
//
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osNpcRemove usage.");
    }
 
    touch_start(integer number)
    {
        list npcs = llList2ListStrided(osGetNPCList(), 0, -1, 3);
 
        if (npcs == [])
        {
            llSay(PUBLIC_CHANNEL, "There is no NPC's in this sim currently.");
        }
 
        else
        {
            integer length = llGetListLength(npcs);
            integer i;
 
            for (i = 0; i < length; i++)
            {
                key npc = llList2Key(npcs, i);
                llSay(PUBLIC_CHANNEL, "Remove NPC: " + npc + " (" + llKey2Name(npc) + ").");
                osNpcSay(npc, "Goodbye!");
                osNpcRemove(npc);
            }
        }
    }
}
Notes
If the NPC is the UUID of any other type of agent (i.e. a user's regular avatar, not an NPC), this function will silently fail, not erasing existing avatar.

In other words, this function does not work on regular avatars but only on NPCs


[edit] See Also

Personal tools
General
About This Wiki