OsAvatarType

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
integer osAvatarType(key avatarKey)
+
{{osslfunc
Returns:
+
|function_syntax=integer osAvatarType(key avatarKey)
 +
|csharp_syntax=
 +
|description=Returns:
 +
 
 
* < 0 in case of error
 
* < 0 in case of error
 
* 0 if avatar not found
 
* 0 if avatar not found
Line 6: Line 9:
 
* 2 if it is a NPC
 
* 2 if it is a NPC
  
 +
|threat_level=ignored
 +
|permissions=true
 +
|delay=0
 +
|ossl_example=<source lang="lsl">
 +
 +
 +
// This script listens for a key on channel 1 which will then
 +
// tell you if the specified key is an NPC or not.
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        llListen(1, "", llGetOwner(), "");   
 +
    }
 +
   
 +
    listen(integer channel , string name, key id, string message)
 +
    {
 +
        if(channel == 1)
 +
        {
 +
            integer isNPC = osIsNpc((key)message); //Get information on the key.
 +
            string keyInfo = llKey2Name((key)message) + " (" + message + ")";
 +
       
 +
            if(isNPC) //Supplied key is an NPC
 +
                llOwnerSay(keyInfo + " is an NPC.");
 +
           
 +
            else if(!isNPC)
 +
            {
 +
                //We now know that the supplied key isn't an NPC.
 +
                //Let's find out if the key exists as an agent or not.
 +
               
 +
                if(llGetAgentSize((key)message) != ZERO_VECTOR) //Supplied key is an agent and not an npc
 +
                    llOwnerSay(keyInfo + " is an AGENT and not an NPC");
 +
                   
 +
                else //Supplied key is either not an NPC or the NPC doesn't exist
 +
                    llOwnerSay(keyInfo + " is either not an NPC or the NPC does not exist.");
 +
            }
 +
        } 
 +
    }
 +
}
  
Threat Level This function does not do a threat level check
+
</source>
Permissions Use of this function is always allowed by default
+
|additional_info=This function was added in 0.9.2.0
Delay 0 seconds
+
}}

Revision as of 08:01, 21 April 2021

integer osAvatarType(key avatarKey)
Returns:
  • < 0 in case of error
  • 0 if avatar not found
  • 1 if it is a normal avatar
  • 2 if it is a NPC
Threat Level This function does not do a threat level check
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
// This script listens for a key on channel 1 which will then
// tell you if the specified key is an NPC or not.
 
default
{
    state_entry()
    {
        llListen(1, "", llGetOwner(), "");    
    }
 
    listen(integer channel , string name, key id, string message)
    {
        if(channel == 1)
        {
            integer isNPC = osIsNpc((key)message); //Get information on the key.
            string keyInfo = llKey2Name((key)message) + " (" + message + ")";
 
            if(isNPC) //Supplied key is an NPC
                llOwnerSay(keyInfo + " is an NPC.");
 
            else if(!isNPC)
            {
                //We now know that the supplied key isn't an NPC.
                //Let's find out if the key exists as an agent or not.
 
                if(llGetAgentSize((key)message) != ZERO_VECTOR) //Supplied key is an agent and not an npc
                    llOwnerSay(keyInfo + " is an AGENT and not an NPC");
 
                else //Supplied key is either not an NPC or the NPC doesn't exist
                    llOwnerSay(keyInfo + " is either not an NPC or the NPC does not exist.");
            } 
        }   
    }
}
Notes
This function was added in 0.9.2.0


Personal tools
General
About This Wiki