Difference between revisions of "LlGetParcelPrimOwners"

From Second Life Wiki
Jump to navigation Jump to search
(Added an example script.)
Line 16: Line 16:
// Looks better after the first iteration.
// Looks better after the first iteration.
// Refreshes every 10 seconds.
// 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 OwnerKeys;

Revision as of 11:47, 7 July 2008

Summary

Function: list llGetParcelPrimOwners( vector pos );
2.0 Forced Delay
10.0 Energy

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).

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.

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

Deep Notes

Signature

function list llGetParcelPrimOwners( vector pos );