llGetParcelPrimOwners

From Second Life Wiki
Revision as of 20:45, 15 April 2008 by Steamy Latte (talk | contribs) (Added an example script.)
Jump to navigation Jump to search

Summary

Function: list llGetParcelPrimOwners( vector pos );

Returns a list of all residents who own objects on the parcel at pos and with individual prim counts.
The list is formatted as [ key agentKey1, integer agentCount1, key agentKey2, integer agentCount2, ... ], and sorted by agent key with a maximum of 100 strides.

• vector pos

Requires owner-like permissions for the parcel.

Caveats

  • This function causes the script to sleep for 2.0 seconds.
  • The object must be owned by the land owner or if the land is owned by a group then it must be deeded to the group or owned by a group officer (or similar rank).
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> // 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.

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);
       }
   }
}</lsl>

Deep Notes

Search JIRA for related Issues

Signature

function list llGetParcelPrimOwners( vector pos );