From 3bf412dce88cf82701a1ed6186865d8542fdca84 Mon Sep 17 00:00:00 2001 From: Madpeter Date: Sun, 26 Apr 2020 14:09:18 +0100 Subject: [PATCH] new command: ParcelPrimCountTotal --- Core/Commands/Parcel/ParcelPrimCountTotal.cs | 59 ++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Core/Commands/Parcel/ParcelPrimCountTotal.cs diff --git a/Core/Commands/Parcel/ParcelPrimCountTotal.cs b/Core/Commands/Parcel/ParcelPrimCountTotal.cs new file mode 100644 index 0000000..e3d84a8 --- /dev/null +++ b/Core/Commands/Parcel/ParcelPrimCountTotal.cs @@ -0,0 +1,59 @@ +using OpenMetaverse; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BSB.Commands.CMD_Parcel +{ + class ParcelPrimCountTotal : CoreCommand + { + public override string[] ArgTypes { get { return new[] { "Smart" }; } } + public override string[] ArgHints { get { return new[] { "Smart reply target: Channel,Avatar,HTTP url" }; } } + public override int MinArgs { get { return 1; } } + public override string Helpfile { get { return "Returns the total number of prims on the current parcel as follows: DATA=SIMNAME,PARCELID,COUNT"; } } + + public override void Callback(string[] args, EventArgs e) + { + ParcelObjectOwnersReplyEventArgs ObjectOwners = (ParcelObjectOwnersReplyEventArgs)e; + int total_count = 0; + foreach (ParcelManager.ParcelPrimOwners owner in ObjectOwners.PrimOwners) + { + total_count += owner.Count; + } + StringBuilder reply = new StringBuilder(); + int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); + reply.Append("DATA="); + reply.Append(bot.GetClient.Network.CurrentSim.Name); + reply.Append(","); + reply.Append(localid.ToString()); + reply.Append(","); + reply.Append(total_count.ToString()); + base.Callback(args, e, bot.GetCommandsInterface.SmartCommandReply(args[0], reply.ToString(), CommandName)); + } + + public override bool CallFunction(string[] args) + { + if (base.CallFunction(args) == true) + { + if (bot.GetCommandsInterface.SmartCommandReply(args[0], "Vaildate", CommandName, true) == true) + { + int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); + if (bot.CreateAwaitEventReply("parcelobjectowners", this, args) == true) + { + bot.GetClient.Parcels.RequestObjectOwners(bot.GetClient.Network.CurrentSim, localid); + return true; + } + else + { + return Failed("Unable to await reply"); + } + } + else + { + return Failed("Arg 1 is not a vaild smart target"); + } + } + return false; + } + } +}