public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
return new LSL_List();
// the constants are 1, 2 and 4 so bits are being set, but you
// get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4
bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION;
bool parcelOwned = scope == ScriptBaseClass.AGENT_LIST_PARCEL_OWNER;
bool parcel = scope == ScriptBaseClass.AGENT_LIST_PARCEL;
LSL_List result = new LSL_List();
if (!regionWide && !parcelOwned && !parcel)
{
result.Add("INVALID_SCOPE");
return result;
}
Vector3 pos;
UUID id = UUID.Zero;
if (parcel || parcelOwned)
{
pos = m_host.GetWorldPosition();
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
if (land == null)
{
id = UUID.Zero;
}
else
{
if (parcelOwned)
{
id = land.LandData.OwnerID;
}
else
{
id = land.LandData.GlobalID;
}
}
}
World.ForEachScenePresence(delegate(IScenePresence ssp)
{
// Gods are not listed in SL
if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent)
{
if (!regionWide)
{
pos = ssp.AbsolutePosition;
IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
if (land != null)
{
if (parcelOwned && land.LandData.OwnerID == id ||
parcel && land.LandData.GlobalID == id)
{
result.Add(ssp.UUID.ToString());
}
}
}
else
{
result.Add(ssp.UUID.ToString());
}
}
// Maximum of 100 results
if (result.Length > 99)
{
return;
}
});
return result;
}