Dan(Tasanar)

Moderator
On my shard a characters "Age" shows below his name. This is done by an edit to player mobile.

The age was based on the creation of the account, however now I would like it to be based off of his in-game playing time.

This is the old code.

Code:
//START
            Account acct = this.Account as Account;

            if (acct != null && this.AccessLevel <= AccessLevel.Player)
            {
                TimeSpan totalTime = (DateTime.UtcNow - acct.Created);
                list.Add(1060658, String.Format("Age\t{0} Days", totalTime.Days.ToString())); // ~1_val~: ~2_val~
            }
            //END

I tried many things including this

Code:
//START       

            if (PlayerMobile != null && this.AccessLevel <= AccessLevel.Player)
            {
                GameTime totalGameTime = (DateTime.UtcNow - PlayerMobile.SessionStart);
                list.Add(1060658, String.Format("Age\t{0} Days", totalGameTime.Days.ToString())); // ~1_val~: ~2_val~
            }
            //END

obviously wrong

and got a little inspiration from this

Code:
PlayerMobile pm = e.Mobile as PlayerMobile;

            if (pm != null)
            {
                pm.m_GameTime += (DateTime.UtcNow - pm.m_SessionStart);

                if (pm.m_Quest != null)
                {
                    pm.m_Quest.StopTimer();
                }

                #region Mondain's Legacy
                QuestHelper.StopTimer(pm);
                #endregion

                pm.m_SpeechLog = null;
                pm.LastOnline = DateTime.UtcNow;

                pm.AutoStablePets();
            }

Any help would be great.
 
I am an idiot, after really looking at how the ObjectPropertyList works in PlayerMobile I realized I was looking way to deep.

This works as intended if anyone else is interested in something similar

Code:
//START                  
            if (AccessLevel <= AccessLevel.Player)
            {
                list.Add(1060658, String.Format("Age\t{0} Days", GameTime.Days.ToString())); // ~1_val~: ~2_val~
            }
            //END

I have it added here

Code:
}
                if (IsStaff())
                {
                    list.Add(
                        1060658, "{0}\t{1}", "Staff", String.Format("<BASEFONT COLOR={0}>{1}", color, GetAccessLevelName(AccessLevel)));
                }
                else
                {
                    list.Add(1060658, "VIP");
                }
            }
          
            //START                  
            if (AccessLevel <= AccessLevel.Player)
            {
                list.Add(1060658, String.Format("Age\t{0} Days", GameTime.Days.ToString())); // ~1_val~: ~2_val~
            }
            //END
            // ADD RIGHT ABOVE BOTTOM METHOD

            if (PlayerProperties != null)
            {
                PlayerProperties(new PlayerPropertiesEventArgs(this, list));
            }
        }


Does anyone see anything wrong with its placement at the bottom?
 
Last edited:
Back