OsIsNpc
From OpenSimulator
(Difference between revisions)
												
			 (Created page with "{{osslfunc |function_syntax=integer osIsNpc(key npc) |csharp_syntax= |description=Returns TRUE (1) / FALSE (0) if key provided is an NPC |threat_level=none |ossl_example= |additi...")  | 
			m (Added note stating which version of OpenSim introduced this function)  | 
			||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 2: | Line 2: | ||
|function_syntax=integer osIsNpc(key npc)  | |function_syntax=integer osIsNpc(key npc)  | ||
|csharp_syntax=  | |csharp_syntax=  | ||
| − | |description=Returns TRUE (1) / FALSE (0) if key provided is an NPC  | + | |description=Returns NPC status on the provided key  | 
| − | |threat_level=  | + | |
| − | |ossl_example=  | + | * Returns TRUE (1) / FALSE (0) if key provided is an NPC  | 
| − | |additional_info=  | + | * Returns FALSE (0) if the key provided doesn't exist in the scene.  | 
| + | |||
| + | |threat_level=ignored  | ||
| + | |permissions=true  | ||
| + | |delay=0  | ||
| + | |ossl_example=<source lang="lsl">  | ||
| + | |||
| + | |||
| + | // Test For NPC  | ||
| + | // Author: mewtwo0641  | ||
| + | // Date: 8-5-13  | ||
| + | |||
| + | // 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.");  | ||
| + |             }   | ||
| + |         }     | ||
| + |     }  | ||
| + | }  | ||
| + | |||
| + | </source>  | ||
| + | |additional_info=This function was added in 0.7.3-post-fixes  | ||
}}  | }}  | ||
Latest revision as of 08:27, 15 October 2018
integer osIsNpc(key npc)
 
 | |
Returns NPC status on the provided key
  | |
| 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) | |
// Test For NPC // Author: mewtwo0641 // Date: 8-5-13 // 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.7.3-post-fixes | |