Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with finding an offline agent's name

Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
07-14-2004 07:21
Hi,

I am writing a lotto script that will payout to a user when the user is offline ...

Currently the script stores a key representing the last winner. I would like the llSetText() to display who the last winner is but when I do an llKey2Name(last_winner), if the player is offline, I end up with nothing...

How can I find the name of an offline player if I have his key?

Thanks every so much,
Jack Lambert
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
07-14-2004 07:26
Use the dataserver luke.... ;)

llRequestAgentData, is the function you want IIRC.

-Adam
_____________________
Co-Founder / Lead Developer
GigasSecondServer
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-14-2004 07:28
llKey2Name only works if the user is online AND in the same simulator as the scripted object.

See: http://www.badgeometry.com/wiki/llKey2Name

Use llRequestAgentData and the dataserver event instead.

See: http://www.badgeometry.com/wiki/llRequestAgentData
_____________________
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-14-2004 07:29
What Adam said! :D
_____________________
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
07-14-2004 07:31
From: someone
Originally posted by Adam Zaius
Use the dataserver luke.... ;)

llRequestAgentData, is the function you want IIRC.

-Adam


I did actually try that a bit before coming here...

key lastwinner = {long key string};
string temp = llKey2Name(llRequestAgentData(lastwinner, DATA_NAME));

llSetText("Last winner: " + temp, <255,255,255>, 1.5);


...


I still end up with nada in the SetText() :(
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-14-2004 07:47
llRequestAgentData will request data from the dataserver, and will return a unique value representing the request, not the information you are looking for.

You have to then use the dataserver event handler to actually receive the requested agent data. See the wiki example at...

http://www.badgeometry.com/wiki/llRequestAgentData
_____________________
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
07-14-2004 07:53
example
CODE

key requestID;

default
{
state_entry()
{
llSetText("Initialized", <1,1,1>, 1);
}

touch_start(integer num_detected)
{
//Get the key of the person touching the prim
key id = llDetectedKey(0);

//Request the name of the agent
//Useful for when the agent is outside of the sim or not online
requestID = llRequestAgentData(id, DATA_NAME);

//Note, yes yes you can use llDetectedName to get the name!
//This is just a simple example illustrating the use of llRequestAgentData
}
dataserver(key queryid, string data)
{
//If this is the dataserver request we made, display the name
if (queryid == requestID)
{
llSetText("Touched By: " + data, <1,1,1>, 1);
}
}
}
_____________________
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
07-14-2004 12:19
Ahhhh, that did it. Thanks ever so much :)

--Jack