Im trying to make universalstoragekeys


Code:
    public bool CheckAccessibility( Item item, Mobile from )
        {
            SecureAccessResult res = CheckSecureAccess( from, item );

            switch ( res )
            {
                case SecureAccessResult.Insecure: break;
                case SecureAccessResult.Accessible: return true;
                case SecureAccessResult.Inaccessible: return false;
            }
           if ( item is ReagentKey )
           return IsFriend( from );
            if ( !IsLockedDown( item ) )
                return true;
            if ( from.AccessLevel >= AccessLevel.GameMaster )
                return true;
            if ( item is Runebook )
                return true;

it doesnt work, the storageykey has to be either in the backpack or locked down inside a house, if its inside a house only Owner have acess to it


Code:
        //checks if the person trying to access the storekeys can do it
        public bool CanUse( Mobile from )
        {
            if( IsChildOf( from.Backpack ) )
            {
                if( CanUseFromPack )
                {
                    return true;
                }
                else
                {
                    from.SendMessage( "That cannot be used from your backpack" );
                    return false;
                }
            }
            else if( !Movable )
            {
                if( !from.InRange( this, 2 ) )
                {
                    from.SendMessage( "You are out of range" );
                    return false;
                }
                if( CanUseFromHouse )
                {
                    BaseHouse house = BaseHouse.FindHouseAt( this );

                    if( house == null || !house.HasSecureAccess( from, Level ) )
                    {
                        return false;
                    }
                    return true;
                }
                else
                {
                    from.SendMessage( "That cannot be used while locked down" );
                    return false;
                }
            }

            if( CanUseFromPack )
            {
                from.SendMessage( "This must be in your backpack to be used." );
            }
            else if( CanUseFromHouse )
            {
                from.SendMessage( "This must be locked down in your house to be used." );
            }
            return false;
        }
 
I think I was working on something with a similar issue - where I needed permissions for Friends or Anyone on an Addon item, so I made it a Container and overrode the DoubleClick method. You could try something similar. Base your item on a Container. This should allow you to set security level for the item as the owner of the house.
 
There are items (i cant remember wich ones) when you singleclick the show a small menu with the access level context menu, do you know what items im talking about?

the context name was setacess if i recall good
 
There are items (i cant remember wich ones) when you singleclick the show a small menu with the access level context menu, do you know what items im talking about?

the context name was setacess if i recall good

Yes. Doors and containers do that.
 
Back