I made a chest that can only be opened by players with 30 days of Ingame time
first i added this

Code:
public static readonly TimeSpan RewardTime = TimeSpan.FromDays( 30.0 );

Then this to the ondoubleclickmethod
Code:
public override void OnDoubleClick( Mobile from )
        {
          // Mobile m = args.Mobile;
            Account ac = (Account)from.Account;
            if ( ac == null )
                return;
    if (from == null)
        return;
    //PlayerMobile pm = (PlayerMobile)from;
    Guild guild = from.Guild as Guild;
     if (guild != null && from is PlayerMobile && from.InRange( this, 1 )  && ac.TotalGameTime >= RewardTime)
	 base.OnDoubleClick( from );
}
 
This code won't crash in certain circumstances...
Code:
public override void OnDoubleClick( Mobile from )
{
   if (from == null)
       return;

    Account ac = from.Account as Account;

    if ( ac == null )
        return;

    Guild guild = from.Guild as Guild;

    if ( guild != null && from.InRange( this, 1 ) && ac.TotalGameTime >= RewardTime )
        base.OnDoubleClick( from );
}
 
what's the problem???


Lol nvm the player wasnt in a guild, the thing is ANY player can open it, even new characters, they just need to be in a guild, why is not checking for the Gametime?

gt.png almost 6 min gametime, can open the chest :p
 
Last edited:
Account.TotalGameTime is not the same as PlayerMobile.GameTime

Ah... right.Thats what im trying to check, the PlayerMobile.GameTime, so how it would be, like this?

Code:
public override void OnDoubleClick( Mobile from )
        {
         if (from == null)
       return;
//   Account ac = from.Account as Account;
//   if ( ac == null )
  //      return;
    PlayerMobile pm = (PlayerMobile)from;
      Guild guild = from.Guild as Guild;
   
     if (guild != null && from is PlayerMobile &&  from.InRange( this, 1 )  && pm.GameTime >= RewardTime)
        }

Ok checking for GameTime, works, thanks so much guys :)
 
Last edited:
Back