// Script by Steamy Latte.
// The owner of the object must be the owner of the parcel.
// Sets object text to the name of everyone who owns objects on the parcel,
// and the number of prims they own.
// Looks better after the first iteration.
// Refreshes every 10 seconds.
// Comment Miki Gymnast:
// Warning: this script will cause a stack/heap collision if there are group owned objects,
// because name of group owned objects will always be "" and the script will continously
// add then data to the lists after the db requests.
// Changing ** OwnerNames = OwnerNames + [""]; ** to ** OwnerNames = OwnerNames + ["Group"]
// and skipping the first db-request could be a quick hack, but the script is all together much
// to overloaded for an example.
list OwnerKeys;
list OwnerNames;
list OwnerQueries;
GetOwnerList()
{
list parcelPrims = llGetParcelPrimOwners(<128,128,50>);
string listString = "";
integer idx;
for(idx=0; idx<llGetListLength(parcelPrims); idx+=2)
{
key ownerKey = llList2Key(parcelPrims, idx);
string ownerName = llKey2Name(ownerKey);
if (ownerName == "")
{
ownerName = OwnerNameLookup(ownerKey);
if (ownerName == "")
{
OwnerQueries = OwnerQueries + [llRequestAgentData(ownerKey, DATA_NAME)];
OwnerKeys = OwnerKeys + [ownerKey];
OwnerNames = OwnerNames + [""];
// Get the owner key if no name is available.
ownerName = ownerKey;
}
}
integer numObjects = llList2Integer(parcelPrims, idx+1);
if (listString != "")
{
listString = listString + "\n";
}
listString = listString + ownerName + ": " + (string)numObjects;
}
llSetText(listString, <1,1,1>, 1);
}
string OwnerNameLookup(key ownerKey)
{
integer listOffset = llListFindList(OwnerKeys, [ownerKey]);
if (listOffset < 0)
return "";
return llList2String(OwnerNames, listOffset);
}
default
{
state_entry()
{
llSetTimerEvent(10);
OwnerNames = [];
OwnerKeys = [];
OwnerQueries = [];
GetOwnerList();
}
timer()
{
GetOwnerList();
}
dataserver(key queryId, string data)
{
llOwnerSay("Got Owner name: " + data);
integer queryNumber = llListFindList(OwnerQueries, [queryId]);
if (queryNumber < 0)
{
llOwnerSay("Problem, query returned name " + data + ", but unknown query ID.");
}
else
{
OwnerNames = llListReplaceList(OwnerNames, [data], queryNumber, queryNumber);
}
}
}