Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: detecting if key is empty (handy for detecting if groupland or not)

phoenix Behemoth
Registered User
Join date: 7 Oct 2004
Posts: 14
01-01-2006 20:11
CODE
default
{
state_entry()
{
}

touch_start(integer total_number)
{
string land;
if(llKey2Name(llGetLandOwnerAt(llGetPos())) == "")
{
land = "Group land";
}else
{
land = "land owned by " + llKey2Name(llGetLandOwnerAt(llGetPos()));
}
llSay(0, land);
}
}

hope this is handy for people
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
01-03-2006 06:49
/15/ee/80385/1.html
_____________________
i've got nothing. ;)
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-03-2006 07:09
My understanding of llKey2Name is that it will also return an empty string is the owner is an avater, but he or she is not currently in the same sim as the script doing the test. You may want to use llRequestAgentData instead

Also, the wiki states that llGetLandOwnerAt will return a null key if the land is publicly owned.
Kristian Ming
Head Like A Hole
Join date: 5 Feb 2005
Posts: 404
01-03-2006 08:59
CODE
// tested landscanner code
key landowner; // fairly obvious
integer flag = 0; // for throttling -- we're not going to allow concurrent dataserver requests
integer delayseconds = 10; // number of seconds before we declare the dataserver request dead or silently failed (group land)

// per the wiki, if we pass a group key in llRequestAgentData the dataserver will never return a response.

default
{

state_entry(){ }

touch_start(integer foo) {
if (flag == 0) {
landowner = llGetLandOwnerAt(llGetPos());
if (landowner == NULL_KEY) {
llSay(0, "This land is public. Act fast!");
// llRezObject("ImpeachBushSignLargeRotating", llGetPos() + <0, 0, 9.5>, ZERO_VECTOR, ZERO_ROTATION, 0);
// ;-)
} else {
llRequestAgentData(landowner, DATA_NAME); //
llSetTimerEvent(delayseconds);
flag = 1;
llSay(0, "Querying dataserver...");
}
} else {
llSay(0, "Outstanding data request pending. Please be patient!");
}
}

dataserver(key queryid, string data) {
if (flag == 1) {
llSay(0, "Land is owned by: " + data);
flag = 0;
llSetTimerEvent(0);
} else {
llSay(0, "Dataserver event triggered when I wasn't expecting one. Laggy!");

}
}

timer () {
llSay(0, "Dataserver event timeout. Land may be group owned.");
flag =0;
llSetTimerEvent(0);
}

}