void Player_TakeGoldW(byte type, long gold)
{
#region Take gold from storage
try
{
//Check if the user isnt in any state/action that we will not allow.
if (!Character.State.Die || !Character.Stall.Stallactive || !Character.Alchemy.working || !Character.Position.Walking)
{
//Normal storage
if (!Character.Network.Guild.UsingStorage)
{
//Check if the gold is equally or higher to the amount withdrawing
if (Character.Account.StorageGold >= gold)
{
//If ok, reduce the gold from storage
Character.Account.StorageGold -= gold;
//Add the gold to inventory gold
Character.Information.Gold += gold;
//Send packet update gold
client.Send(Packet.UpdateGold(Character.Information.Gold));
//Send visual update
client.Send(Packet.MoveItem(type, 0, 0, 0, gold, "MOVE_WAREHOUSE_GOLD"));
//Save the gold information
SaveGold();
}
//If gold is to low
else
{
//Send error message to the player.
client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
}
}
//Guild storage
else
{
//Check if the gold is equally or higher to the amount withdrawing
if (Character.Network.Guild.StorageGold >= gold)
{
//If ok, reduce the gold from storage
Character.Network.Guild.StorageGold -= gold;
//Add the gold to inventory gold
Character.Information.Gold += gold;
//Send packet update gold
client.Send(Packet.UpdateGold(Character.Information.Gold));
client.Send(Packet.GuildGoldUpdate(Character.Network.Guild.StorageGold, 0x21));
client.Send(Packet.GuildStorageGold(Character));
//Save the gold information
SaveGold();
//Save guild gold
SaveGuildGold();
}
//If gold is to low
else
{
//Send error message to the player.
client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
}
}
}
}
catch (Exception ex)
{
Systems.Debugger.Write(ex);
Console.WriteLine("Take gold from warehouse error {0}", ex);
}
//Save player information
SavePlayerInfo();
#endregion
}