So i have this item that im trying to prevent it from being hold inside a container, i want players be able to put inside their backpack but not inside any other container such as bags, metalchests... etc, this is what i have right now but is not working, right now its not letting me put the item inside any container.

Container.cs


Code:
public override bool CheckHold( Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
        {
            if ( IsSecure && !BaseHouse.CheckHold( m, this, item, message, checkItems, plusItems, plusWeight ) )
                return false;
          
            if ( item is myitemcarg || ( item is Container && Parent == null &&  ((Container)item).FindItemByType(

typeof( myitemcarg ) ) != null ) )
                {
                    m.SendMessage( "You cant put that item inside of a container." );


                    return false;
                }
          
            return base.CheckHold( m, item, message, checkItems, plusItems, plusWeight );
        }


Thanks!
 
Last edited:
The way I did it was:

inside the item's script rather than changing Container.cs
Code:
public override bool DropToItem(Mobile from, Item target, Point3D p)
        {
                if (target == from.Backpack)
                {   
                    return base.DropToItem(from, target, p);
                }
                else
                {
                    from.SendMessage("You cant put that item inside of a container.");           
                    return false;
                }
        }
 
Back