Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Get avatars name

Dinny Dowler
Registered User
Join date: 7 Jun 2006
Posts: 7
06-14-2006 15:28
Hey,

Im new to LSL (but not programming) and cant do what seems to be the most simplest thing, I would like to get the avatars name into the variables strFirstName, and strLastName, but I dont know how to get the characters name! Ive searched for a while and would really appreciate if somebody could show me, i know it sounds simple :)

Thanks
Thraxis Epsilon
Registered User
Join date: 31 Aug 2005
Posts: 211
06-14-2006 16:10
If it is the person who owns the object....

string name = llKey2Name(llGetOwner());
Dinny Dowler
Registered User
Join date: 7 Jun 2006
Posts: 7
06-14-2006 16:18
thanks, I just found this thread aswell which was usefull

/54/99/96330/1.html
Cusprider Nephilim
Registered User
Join date: 2 Feb 2006
Posts: 13
llName2Key vs dataserver event.
06-27-2006 16:58
That works if the owner is in the same sim. Is there a way to fetch back the object owners name when the owner is either not in the sim or off line?
My research shows me that it is a data server call. But how to make data server calls is still a mistery to me. I have been studying other scripts to see how they are doing it. But what I need is an example all by itself to help clarify things for me. Thanks.
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
06-27-2006 18:04
From: Cusprider Nephilim
But how to make data server calls is still a mistery to me.

You start with a call to dataserver, requesting piece of info you're interested in:

CODE

key name_request; // global variable so you can access it later from another place

name_request = llRequestAgentData( AgentKey, DATA_NAME );

because you can't ever be sure answers from dataserver will arrive in the same order you make the calls (as long as you make more than one request in your script anyway) this call returns a 'ticket' of sorts, that you can use to match the answers you get with questions you sent to dataserver beforehand. I stored this key in name_request variable.

When the server sends you back its answer, it triggers dataserver() event:
CODE

dataserver( QueryId, Data) {

if( QueryId == name_request ) llSay( 0, "Name of person is: " + Data );
}

... the QueryId tells you which of your questions this answer is for, as it will match the 'ticket' you received when you asked this particular question. So, by checking this variable you can find out which of your questions to dataserver were answered, and act accordingly.

hth ^^;
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-27-2006 18:08
its pretty basic when you fire a function that comes back to dataserver it just gets picked up by the dataserver event, like a touch or anything else and their events

here is an example from the wiki
CODE

//By Nich Steed
default
{
touch_start(integer num_detected)
{
llRequestAgentData(llDetectedKey(0), DATA_BORN); // request creation date
}
dataserver(key queryid, string data)
{
llSay(0, "You were born on: " + data);
}
}