Just had a quick question about detecting a name with a script. It's super easy to do, you only need one line:
touch_start(integer total_number)
{
llOwnerSay(llDetectedName(0));
}
In this example I put it in a touch event, but it could also go in a collision event. You can also set things to be run by the owner of the object only by using the following snippet. Anything between the brackets will be owner only:
if(llDetectedKey(0) == llGetOwner()){
}
skip to main |
skip to sidebar
Pages
LSL help: any question is fair game!
Showing posts with label llDetectedKey. Show all posts
Showing posts with label llDetectedKey. Show all posts
Saturday, November 27, 2010
Tuesday, May 18, 2010
Get a bunch of info on someone (llRequestAgentData example)
Shila asked how to get an avatar's name , DOB, Payment Info and online status. Doing this can be lengthy because each of these things need to be handled differently as they return different data types. Here is an example script I wrote this afternoon that gets all of these pieces of information:
So now you know how to get most of the data on someone's avi. If you want to do other things with this info you can put your functions in the dataserver event, inside the if statement pertaining to that piece of information.
key online_query;There are a few things you'll notice right away. First of all I have this set up so it gets the info of whoever touched the prim. The next thing is that I have four queries set up for each of the pieces of data we want to get, and finally inside the dataserver event we have four "if" statements that handle each of the queries. The name query returns the avatar's name as a string, their online status returns as an integer disguised as a string (either 1 or 0 depending on their online status), their birthday returns as a string in the format YYYY-MM-DD, and their payment info also returns as integers in string format, 0 for no payment info, 1 for pay info on file, and 3 for pay info used. Don't ask what happened to 2.
string name_query;
string birthday_query;
string payinfo_query;
string owner_name;
string online;
string birthday;
string payinfo;
default
{
touch_start(integer total_number)
{
key id = llDetectedKey(0);
name_query = llRequestAgentData(id, DATA_NAME);
online_query = llRequestAgentData(id, DATA_ONLINE);
birthday_query = llRequestAgentData(id, DATA_BORN);
payinfo_query = llRequestAgentData(id, DATA_PAYINFO);
}
dataserver(key queryid, string data)
{
//Find out their name --------------------------------------
if ( name_query == queryid )
{
owner_name = data;
llSay(0, "The name of the person is : " + owner_name );
}
//Find out if they are online-------------------------------
if ( online_query == queryid )
{
online = data;
if (online == "1"){
llSay(0, "he or she is online");
}
else
{
llSay(0, "he or she is offline");
}
}
//Find when their birthday is -------------------------------
if ( birthday_query == queryid )
{
birthday = data;
llSay(0, "Their birthday is "+ birthday);
}
//Find out what their payment info status is ----------------
if ( payinfo_query == queryid )
{
payinfo = data;
if (payinfo == "0"){
llSay(0, "They have no payment info on file");
}
if (payinfo == "1"){
llSay(0, "They have payment info on file");
}
if (payinfo == "3"){
llSay(0, "Their payment info has been used");
}//end if(payinfo == "3")
}//end query if
}//end dataserver
}//end default
So now you know how to get most of the data on someone's avi. If you want to do other things with this info you can put your functions in the dataserver event, inside the if statement pertaining to that piece of information.
Labels:
dataserver,
llDetectedKey,
llRequestAgentData,
llSay
Instructions
If you have a question you would like to see answered here, feel free to ask it in the comment section of any post, or email it to:
nucularsecrets@gmail.com
Any question is fair game, so don't be shy!
nucularsecrets@gmail.com
Any question is fair game, so don't be shy!
Featured
- OpenSim (1)
- Outline (1)
- Sculpties in Blender (1)
Followers
Contributors
Friends
Index
- PHP (1)
- changed (2)
- click and drag (1)
- dataserver (2)
- link_message (1)
- llAllowInventoryDrop (1)
- llAvatarOnSitTarget (1)
- llDetectedKey (2)
- llDetectedName (1)
- llDetectedTouchPos (1)
- llDetectedTouchUV (1)
- llGetOwner (2)
- llGetScriptName (1)
- llHTTPRequest (1)
- llListen (1)
- llParticleSystem (1)
- llRegionSay (1)
- llRemoveInventory (1)
- llRequestAgentData (2)
- llResetScript (1)
- llSay (3)
- llSetLinkPrimitiveParamsfast (2)
- llSetObjectName (1)
- llSetPos (1)
- llSetTimerEvent (1)
- llSitTarget (1)
- particles (1)
- timer (1)
- touch (1)
Blog Archive
-
►
2010
(18)
- ► Nov 21 - Nov 28 (1)
- ► Sep 19 - Sep 26 (1)
- ► Aug 15 - Aug 22 (1)
- ► Aug 8 - Aug 15 (1)
- ► Aug 1 - Aug 8 (1)
- ► Jul 25 - Aug 1 (1)
- ► Jul 4 - Jul 11 (1)
- ► Jun 13 - Jun 20 (1)
- ► May 23 - May 30 (3)
- ► May 16 - May 23 (5)
- ► May 2 - May 9 (2)
Copyright 2010 Nucular Secrets . Powered by Blogger
Blogger Templates created by Deluxe Templates Wordpress by thebookish