Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Get a Users Key by Name

Seasom Hagoromo
Registered User
Join date: 8 Sep 2006
Posts: 2
09-14-2006 11:13
I'm trying to set up a postal drop box, so that I can put an object in a box, but make it so only a specific person can get the items out. Best I can figure out how to do this is to do a compare on the person's key and a pre-stored key.

I know how to get the owner and the creator's key.

Can I get the key of the person touching the object?

Is there a way to look up someones key based on their name, assuming they aren't savvy enough to retrieve their own key?

basically like, pseudowise...

touch_start
toucherkey = llGetToucherKey();
recipient = llGetSomebodysKey("John Smith";);
if (toucherkey == recipient)
llGiveInventory(recipient, "some item";)
else
say(0, "You are not the designated recipient!";)


This way if "John Smith" touches the object, it gives him "some item", but if anyone else touches it errors.

Theres probably a MUCH better mailbox/dropbox script out there, but this is mostly a learning experience.

While i'm asking stupid questions, is there a place out there where the functions in LSL are documented and organised? PHP for example, has a documentation manual that is tremendously useful, http://us2.php.net/define I always have difficulty finding things in the wiki if i dont already know what the function/command name IS ahead of time.
Dragon Eccleston
Registered User
Join date: 25 Dec 2005
Posts: 42
09-14-2006 11:26
You don't need the key if you have the name, just use llDetectedName() in the touch_start event. Avatar names can't be spoofed and objects can't touch each other, if llDetectedName() in a touch event gives your targets name, you know it's your target.

The official LSL wiki is down for a bit but a semi-complete version is available at http://rpgstats.com/wiki/index.php?title=Main_Page
Rich Cordeaux
Registered User
Join date: 8 May 2006
Posts: 26
09-14-2006 11:27
There are two main ways to get a key from a name.

One, get them to touch your object. Then use llDetectedKey to get their key.

Two, get their name and start a sensor (llSensor) search for anyone with their name. Then use llDetectedKey once it finds them.

Of course if they're not within 96 meters, it will probably fail to find them. (And I seem to remember reading something about llSensor not scanning other nearby sims, so you might want to use llSensorRepeat and then llSensorRemove afterward)

For finding things better on the wiki(s):
Since you're messing with touch events, you could look up the wiki docs on the touch event. They should point you to the llDetected functions, where you can find llDetectedKey and llDetectedName.
Dominic Webb
Differential Engineer
Join date: 1 Feb 2006
Posts: 73
09-14-2006 12:24
From: Seasom Hagoromo

touch_start
toucherkey = llGetToucherKey();
recipient = llGetSomebodysKey("John Smith";);
if (toucherkey == recipient)
llGiveInventory(recipient, "some item";)
else
say(0, "You are not the designated recipient!";)


CODE
default {
touch_start(integer num) {
key id = llDetectedKey(0);
if(llGetOwner() == id) {
llGiveInventory(id, "item");
} else {
llSay(0, "Sorry, " + llDetectedName(0) + ", no access.");
}
}
}


I use a variation of this (with group check) to give out script updates for my products..


- d.
_____________________
.sig space for rent.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
09-14-2006 12:36
Yes, I can't think of a situation where you can get a name but not a key - except in the case of items which take user instructions based on a name, for example an email-to-IM bridge where somebody wants to send an IM on the basis of a name. For those situations, there are name2key databases around (e.g. here) which can be interrogated via llHTTPRequest, but they're not the best thing to rely on as they can have errors and omissions.

Incidentally, a Linden mentioned a while back that a name2key function might be coming at some point, but there was no timescale.