/// <summary>
/// Attempts to start a transfer of the given item to the bank the
/// creature is currently using.
/// </summary>
/// <param name="creature"></param>
/// <param name="itemEntityId"></param>
/// <param name="instantTransfer"></param>
/// <returns></returns>
public bool Transfer(Creature creature, long itemEntityId, bool instantTransfer)
{
// Check bank
var currentBank = creature.Temp.CurrentBankId;
if (string.IsNullOrWhiteSpace(currentBank))
{
Log.Warning("BankTransferRequest: Player '0x{0:X16}' (Account: '{1}') tried to transfer item while not being in a bank.", creature.EntityId, creature.Client.Account.Id);
return(false);
}
// Get item and tab
Item item = null;
string tabName = null;
foreach (var tab in this.Tabs.Values)
{
item = tab.GetItem(itemEntityId);
if (item != null)
{
tabName = tab.Name;
break;
}
}
if (item == null)
{
Log.Warning("BankTransferRequest: Player '0x{0:X16}' (Account: '{1}') tried to transfer a non-existing or in-transit item.", creature.EntityId, creature.Client.Account.Id);
return(false);
}
// Get fee and time
var fee = BankInventory.GetTransferFee(item, item.Bank, currentBank);
var time = BankInventory.GetTransferTime(item.Bank, currentBank);
// Incrase fee for instant transfer.
if (instantTransfer)
{
// Don't change, hardcoded in the client.
fee = 100 + (fee * 5);
time = 0;
}
// Check gold
if (this.Gold < fee)
{
Send.MsgBox(creature, Localization.Get("Unable to pay the fee, Insufficient balance."));
return(false);
}
// Transfer
item.Bank = currentBank;
item.BankTransferStart = DateTime.Now;
item.BankTransferDuration = time;
this.RemoveGold(creature, fee);
Send.BankTransferInfo(creature, tabName, item);
return(true);
}