diff --git a/Core/Commands/Parcel/ParcelBuy.cs b/Core/Commands/Parcel/ParcelBuy.cs new file mode 100644 index 0000000..7c020ec --- /dev/null +++ b/Core/Commands/Parcel/ParcelBuy.cs @@ -0,0 +1,39 @@ +using BetterSecondBotShared.Static; +using OpenMetaverse; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BSB.Commands.CMD_Parcel +{ + class ParcelBuy : CoreCommand + { + public override string[] ArgTypes { get { return new[] { "Number" }; } } + public override string[] ArgHints { get { return new[] { "expected price to pay" }; } } + public override string Helpfile { get { return "Attempts to buy the parcel the bot is standing on, note: if no price expected price is set it will pay the listed price"; } } + + public override bool CallFunction(string[] args) + { + if (base.CallFunction(args) == true) + { + int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); + Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid]; + int expected_price = -1; + if(args.Length == 1) + { + int.TryParse(args[0], out expected_price); + } + if((p.SalePrice == expected_price) || (expected_price == -1)) + { + bot.GetClient.Parcels.Buy(bot.GetClient.Network.CurrentSim, localid, false, UUID.Zero, false, p.Area, p.SalePrice); + return true; + } + else + { + return Failed("Expected price is not -1 or matchs: " + expected_price.ToString() + ""); + } + } + return false; + } + } +}