void Player_MoveItemToStorage(byte f_slot, byte t_slot, int o_id)
{
#region Move item to storage
try
{
//Check if the user isnt in any state/action that we will not allow.
if (Character.State.Die) return;
if (Character.Stall.Stallactive) return;
if (Character.Alchemy.working) return;
if (Character.Position.Walking) return;
//Normal storage
if (!Character.Network.Guild.UsingStorage)
{
//Get item information
Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0);
//Get storage price of the item
int storageprice = Data.ItemBase[item.ID].Storage_price;
//Set amount if its only 1
if (item.Amount == 0) item.Amount = 1;
//Multiply the price, per amount
storageprice *= item.Amount;
//Anti hack check make sure that the owner of the item is correct
int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner"));
//Check if the owner really owns the item.
if (ownerid == Character.Information.CharacterID)
{
//Make sure the stack count is equal or lower then max stack amount
if (item.Amount <= Data.ItemBase[item.ID].Max_Stack)
{
//If the user has enough gold (Equally or higher to storage price).
if (Character.Information.Gold >= storageprice)
{
//Set character gold
Character.Information.Gold -= storageprice;
//Send update packet for gold
client.Send(Packet.UpdateGold(Character.Information.Gold));
//Update mssql database information
MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='1' WHERE storageacc='" + Player.ID + "' AND id='" + item.dbID + "'");
//Send visual move packet to player
client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_STORAGE"));
//Save the player gold
SaveGold();
}
//If the user does not have enough gold
else
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
}
}
//This should not happen but if the stack is to high.
else
return;
}
//If the player is not the item owner (Hacking attempt).
else
{
Disconnect("ban");
Console.WriteLine("Autobanned user: " + Player.AccountName + " Due to hacking");
}
}
//Guild storage
else
{
//Get item information
Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0);
//Get storage price of the item
int storageprice = Data.ItemBase[item.ID].Storage_price;
//Set amount if its only 1
if (item.Amount == 0) item.Amount = 1;
//Multiply the price, per amount
storageprice *= item.Amount;
//Anti hack check make sure that the owner of the item is correct
int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner"));
//Check if the owner really owns the item.
if (ownerid == Character.Information.CharacterID)
{
//Make sure the stack count is equal or lower then max stack amount
if (item.Amount <= Data.ItemBase[item.ID].Max_Stack)
{
//If the user has enough gold (Equally or higher to storage price).
if (Character.Information.Gold >= storageprice)
{
//Set character gold
Character.Information.Gold -= storageprice;
//Send update packet for gold
client.Send(Packet.UpdateGold(Character.Information.Gold));
//Update mssql database information
MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='3' ,guild_storage_id='" + Character.Network.Guild.Guildid + "' WHERE id='" + item.dbID + "'");
//Send visual move packet to player
client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_GUILD_STORAGE"));
//Save the player gold
SaveGold();
}
//If the user does not have enough gold
else
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
}
}
//This should not happen but if the stack is to high.
else
return;
}
//If the player is not the item owner (Hacking attempt).
else
{
Disconnect("ban");
Console.WriteLine("Autobanned user: " + Player.AccountName + " Due to hacking");
}
}
}
catch (Exception ex)
{
Console.WriteLine("Storage move error : {0}", ex);
Systems.Debugger.Write(ex);
}
//Save player information
SavePlayerInfo();
#endregion
}