new command: ParcelBuy
This commit is contained in:
parent
04eeee600d
commit
e29b6b1a25
1 changed files with 39 additions and 0 deletions
39
Core/Commands/Parcel/ParcelBuy.cs
Normal file
39
Core/Commands/Parcel/ParcelBuy.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue