1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Universl StorageKeys accesible for housefriends?

Discussion in 'Script Support' started by sahisahi, May 16, 2018.

  1. sahisahi
    Offline

    sahisahi Member

    Joined:
    Jan 13, 2016
    Messages:
    615
    Likes Received:
    15
    Im trying to make universalstoragekeys


    Code (C#):
    1.     public bool CheckAccessibility( Item item, Mobile from )
    2.         {
    3.             SecureAccessResult res = CheckSecureAccess( from, item );
    4.  
    5.             switch ( res )
    6.             {
    7.                 case SecureAccessResult.Insecure: break;
    8.                 case SecureAccessResult.Accessible: return true;
    9.                 case SecureAccessResult.Inaccessible: return false;
    10.             }
    11.            if ( item is ReagentKey )
    12.            return IsFriend( from );
    13.             if ( !IsLockedDown( item ) )
    14.                 return true;
    15.             if ( from.AccessLevel >= AccessLevel.GameMaster )
    16.                 return true;
    17.             if ( item is Runebook )
    18.                 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 (C#):
    1.         //checks if the person trying to access the storekeys can do it
    2.         public bool CanUse( Mobile from )
    3.         {
    4.             if( IsChildOf( from.Backpack ) )
    5.             {
    6.                 if( CanUseFromPack )
    7.                 {
    8.                     return true;
    9.                 }
    10.                 else
    11.                 {
    12.                     from.SendMessage( "That cannot be used from your backpack" );
    13.                     return false;
    14.                 }
    15.             }
    16.             else if( !Movable )
    17.             {
    18.                 if( !from.InRange( this, 2 ) )
    19.                 {
    20.                     from.SendMessage( "You are out of range" );
    21.                     return false;
    22.                 }
    23.                 if( CanUseFromHouse )
    24.                 {
    25.                     BaseHouse house = BaseHouse.FindHouseAt( this );
    26.  
    27.                     if( house == null || !house.HasSecureAccess( from, Level ) )
    28.                     {
    29.                         return false;
    30.                     }
    31.                     return true;
    32.                 }
    33.                 else
    34.                 {
    35.                     from.SendMessage( "That cannot be used while locked down" );
    36.                     return false;
    37.                 }
    38.             }
    39.  
    40.             if( CanUseFromPack )
    41.             {
    42.                 from.SendMessage( "This must be in your backpack to be used." );
    43.             }
    44.             else if( CanUseFromHouse )
    45.             {
    46.                 from.SendMessage( "This must be locked down in your house to be used." );
    47.             }
    48.             return false;
    49.         }
     
  2. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,021
    Likes Received:
    147
    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.
     
    • Thanks! Thanks! x 1
  3. sahisahi
    Offline

    sahisahi Member

    Joined:
    Jan 13, 2016
    Messages:
    615
    Likes Received:
    15
    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
     
  4. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,021
    Likes Received:
    147
    Yes. Doors and containers do that.
     
    • Thanks! Thanks! x 1
  5. PyrO
    Offline

    PyrO Active Member

    Joined:
    Jan 27, 2015
    Messages:
    876
    Likes Received:
    50
    Well it should be fine if you give it the ISecurable interface
     
    • Thanks! Thanks! x 1