I wanted to make armors show the temporaryquestobject attachment from Xmlspawner2.

i added on singleclick method the next part;


Code:
  public override void OnSingleClick(Mobile from)
        {


            ///////////////////------------------------------XMLTEMPORARY------------------****************////////
            TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));


if (tempo != null) 
{
     if(Expiration > TimeSpan.Zero)
            {
                return String.Format("{1} Expires in {0} minutes",Expiration.TotalMinutes);
            }
 
}

///////////////////------------------------------XMLTEMPORARY------------------****************////////
}

this is the error im getting;


Errors:
+ Items/Armor/BaseArmor.cs:
CS0103: Line 1947: The name 'Expiration' does not exist in the current conte
xt
CS0103: Line 1952: The name 'Expiration' does not exist in the current conte
xt
CS0103: Line 1954: The name 'Expiration' does not exist in the current conte
xt


Thanks guys
 
Last edited:
Sorry demented i dont understand what you mean :/

You want me to add
Code:
TimeSpan Expiration = TimeSpan.Zero;
?
 
Some thing Like this I think
Code:
public override void OnSingleClick(Mobile from)
      {


	 TimeSpan Expiration = TimeSpan.Zero;


          ///////////////////------------------------------XMLTEMPORARY------------------****************////////
           TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));




if (tempo != null)
{
    if(Expiration > TimeSpan.MaxValue)
	{
              return String.Format("{1} Expires in {0} minutes",Expiration.TotalMinutes);
         }
		return TimeSpan.Zero;

}


[///////////////////------------------------------XMLTEMPORARY------------------****************////////
}
or atleast from what I remember on some websites
 
Last edited:
Code:
  public override void OnSingleClick(Mobile from)
        {
        
       
          
            ///////////////////------------------------------XMLTEMPORARY------------------****************////////
            TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));
TimeSpan Expiration = TimeSpan.Zero;

if (tempo != null)   
{
     if(Expiration > TimeSpan.Zero)
            {
                string.Format("Expires in {0} minutes",Expiration.TotalMinutes);
            }
   
}
}

this is the way i have it now, it compiles but still not showing the expiration time when singleclick
 
it has to be before Temporary see code again I finaly kinda got it right this time.You got Expiration above that Snippet it doesnt know what Expiraton is in the above code.
 
try changing the return type to Expiration...
return Expiration;
Ah sorry i missed that part, i got error


Errors:
+ Items/Armor/BaseArmor.cs:
CS0127: Line 1954: Since 'Server.Items.BaseArmor.OnSingleClick(Server.Mobile
)' returns void, a return keyword must not be followed by an object expression
 
you also need to define TotalMinutes like this..
int totalMinutes = (totalSeconds + 59) / 60;
totalMinutes.ToString());
 
you also need to define TotalMinutes like this..
int totalMinutes = (totalSeconds + 59) / 60;
Errors:
+ Items/Armor/BaseArmor.cs:
CS0103: Line 1945: The name 'totalSeconds' does not exist in the current con
text


Added that like this:


Code:
 TimeSpan Expiration = TimeSpan.Zero;
           int totalMinutes = (totalSeconds + 59) / 60;
 
No, Just Below the string.Format

Code:
[*] public override void OnSingleClick(Mobile from)
[*] {
[*]		// XmlAttach TimeSpan
[*] TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, (TemporaryQuestObject));
[*]TimeSpan Expiration = TimeSpan.Zero;
[*]

[*]if (tempo != null)
[*]{
[*]     if(Expiration > TimeSpan.Zero)
[*]           {
[*]               string.Format("Expires in {0} minutes",Expiration.TotalMinutes);
				int TotolalMinutes =

[*]           }
[*] 
[*]}
[*]}

you could alway look at some code with TimeSpan add toit like the new GetNextBulkOrder in Bribe code that was add to WeaponSmith,Weaver, ...etc
 
Last edited:
Yes you are right, iI always check first and look for same methods but i couldnt get rid of errors, thats why i post


Code:
           TimeSpan Expiration = TimeSpan.Zero;
     
            ///////////////////------------------------------XMLTEMPORARY------------------****************////////
            TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));


if (tempo != null)  
{
      if(Expiration > TimeSpan.Zero)
            {
               string.Format("Expires in {0} minutes",Expiration.TotalMinutes);
            }
          
             int totalMinutes = (totalSeconds + 59) / 60;
  
}

Im missing something like
Code:
TimeSpan ts =    //bla bla bla

Error:

Errors:
+ Items/Armor/BaseArmor.cs:
CS0103: Line 1957: The name 'totalSeconds' does not exist in the current con
text
 
I was Just glad I could Help you further along firefox
yep, think you need the ts,but Again I would look at some example code to help.
 
I was Just glad I could Help you further along firefox
yep, think you need the ts,but Again I would look at some example code to help.

Well thanks for the help, i still have that error thought, im new to this. Trust me when i say that i always check other scripts to see examples so i can copy the method or find a work around

i mean i still have this error:


Errors:
+ Items/Armor/BaseArmor.cs:
CS0103: Line 1957: The name 'totalSeconds' does not exist in the current con
text



would appreciate if someone help me with this.... i got not clue
 
Last edited:
Code Example:
Code:
        #region Bulk Orders
        public override BODType BODType { get { return BODType.Smith; } }

        public override Item CreateBulkOrder(Mobile from, bool fromContextMenu)
        {
            PlayerMobile pm = from as PlayerMobile;

            if (pm != null && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
            {
                double theirSkill = pm.Skills[SkillName.Blacksmith].Base;

                if (theirSkill >= 70.1)
                    pm.NextSmithBulkOrder = TimeSpan.FromHours(6.0);
                else if (theirSkill >= 50.1)
                    pm.NextSmithBulkOrder = TimeSpan.FromHours(2.0);
                else
                    pm.NextSmithBulkOrder = TimeSpan.FromHours(1.0);

                if (theirSkill >= 70.1 && ((theirSkill - 40.0) / 300.0) > Utility.RandomDouble())
                    return new LargeSmithBOD();

                return SmallSmithBOD.CreateRandomFor(from);
            }

            return null;
        }
maybe change totalSeconds to TimeSpan.FromHours(somenumber);
 
Ok lets go with your first script version (looks like the less mistake filled version). I don't want to sound rude but I am trying to explain why things happened how they did, but in short form.

The version I am talking about is:
Code:
public override void OnSingleClick(Mobile from)
{
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));

    if (tempo != null)
    {
        if (Expiration > TimeSpan.Zero)
        {
            return String.Format("{1} Expires in {0} minutes", Expiration.TotalMinutes);
        }
    }
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
}

Ok lets see why it does not work, well that is easy! I mean the compiler already told you that Expiration does not exist.
What Expiration do you want? The one from the TemporaryQuestObject you looked for above.

Why does it not help to set TimeSpan Expiration = TimeSpan.Zero; there? Because then it is a fixed value.
"int totalMinutes =(totalSeconds +59)/60;" I dont even know what that was intended for ^^

What you want to do? You want to use the tempo and get its Expiration. Also since you want to use 2 variables in the String.Format you should add in 2 ;) . I guess you want the name of the item but I am not sure about that.
Code:
public override void OnSingleClick(Mobile from)
{
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));

    if (tempo != null)
    {
        if (tempo.Expiration > TimeSpan.Zero)
        {
            return String.Format("{1} Expires in {0} minutes", tempo.Expiration.TotalMinutes, Name);
        }
    }
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
}
 
Ok lets go with your first script version (looks like the less mistake filled version). I don't want to sound rude but I am trying to explain why things happened how they did, but in short form.

The version I am talking about is:
Code:
public override void OnSingleClick(Mobile from)
{
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));

    if (tempo != null)
    {
        if (Expiration > TimeSpan.Zero)
        {
            return String.Format("{1} Expires in {0} minutes", Expiration.TotalMinutes);
        }
    }
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
}

Ok lets see why it does not work, well that is easy! I mean the compiler already told you that Expiration does not exist.
What Expiration do you want? The one from the TemporaryQuestObject you looked for above.

Why does it not help to set TimeSpan Expiration = TimeSpan.Zero; there? Because then it is a fixed value.
"int totalMinutes =(totalSeconds +59)/60;" I dont even know what that was intended for ^^

What you want to do? You want to use the tempo and get its Expiration. Also since you want to use 2 variables in the String.Format you should add in 2 ;) . I guess you want the name of the item but I am not sure about that.
Code:
public override void OnSingleClick(Mobile from)
{
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));

    if (tempo != null)
    {
        if (tempo.Expiration > TimeSpan.Zero)
        {
            return String.Format("{1} Expires in {0} minutes", tempo.Expiration.TotalMinutes, Name);
        }
    }
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
}

Hello Pyro, thanks for the explanation and help, i learnt something today :)

I got error,:


Errors:
+ Items/Armor/BaseArmor.cs:
CS0127: Line 1952: Since 'Server.Items.BaseArmor.OnSingleClick(Server.Mobile
)' returns void, a return keyword must not be followed by an object expression



So i got rido f the ''return'' word and server compiles, but when i singleclick an item with the attachment, it doesnt show anything!
 
If that item actually does have the attachment on it, are you sure the Timer is not already expired? Because in that case it would not return anything.
 
Code:
  ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));
     bool ascii = true;
    int hue = 1156;
    string tempostring;
    if (tempo != null)
    {
        if (tempo.Expiration > TimeSpan.Zero)
        {
          tempostring = string.Format("Expires in {0} minutes", tempo.Expiration.TotalMinutes);
           PrivateOverheadMessage(MessageType.Label, hue, ascii, tempostring, from.NetState);
        }
        // PrivateOverheadMessage(MessageType.Label, hue, ascii, tempostring, from.NetState);
    }

Hey! this is what i made, it shows the timer expiration but it shows it in a very weird way, it shows the miliseconds i guess, look:

closehelm.png closehelm.png
 
Sorry Pyro is more Knowledgable Than I,I too am just learning this TimeSpan to Datetime stuff myself and how it all works heh...
[doublepost=1493594520][/doublepost]
"int totalMinutes =(totalSeconds +59)/60;" I dont even know what that was intended for
@PyrO is it maybe to convert TimeSpan like what firefox is needing TimeSpan from seconds to minutes?
instead of +59)/60, -59/60?
 
Last edited:
I guess, but in that regard it would say it needs a minute even if it is just a second.
Now that with your negative version on the other hand it would not work.

If you just want flat minutes until it reaches seconds I think I would go and do it like this:
Code:
public override void OnSingleClick(Mobile from)
{
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
    TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));

    if (tempo != null && tempo.Expiration > TimeSpan.Zero)
    {
        if(tempo.Expiration.Minutes > 0)
        {
            from.SendMessage("Expires in {0} minutes", tempo.Expiration.Minutes);
        }
        else
        {
            from.SendMessage("Expires in {0} seconds", tempo.Expiration.Seconds);
        }
    }
    ///////////////////------------------------------XMLTEMPORARY------------------****************////////
}
 
Thank you so much Pyro, its working, i added the days because i have items that disappear in 3... 6... days etc, and it was only displaying

the minutes, so right now if an item will expire in 58 minutes and 6 days it sends 2 messages;

Expires in 58 minutes
Expires in 6 days


I would like it to say ''Expires in 6 days and 58 minutes'' both expiration timers in the same message.


Code:
 TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));
    if (tempo != null && tempo.Expiration > TimeSpan.Zero)
    {
        if(tempo.Expiration.Minutes > 0)
        {
            from.SendMessage("Expires in {0} minutes", tempo.Expiration.Minutes);
        }
         if(tempo.Expiration.Minutes > 59)
        {
           from.SendMessage("Expires in {0} hours", tempo.Expiration.Hours);
        }
         if(tempo.Expiration.Days > 1)
        {
          from.SendMessage("Expires in {0} days", tempo.Expiration.Days);
        }
        else
        {
            from.SendMessage("Expires in {0} seconds", tempo.Expiration.Seconds);
        }
    }

anyway thank you so muchhhhhhhhhhhhh i had this issue since long ago
 
Last edited:
from what I understand you want something that shows you the total time as in 3 days 2 hours 54 minutes and 42 seconds?
Should work like this:
Code:
TemporaryQuestObject tempo = (TemporaryQuestObject)XmlAttach.FindAttachment(this, typeof(TemporaryQuestObject));
        if (tempo != null && tempo.Expiration > TimeSpan.Zero)
        {
            StringBuilder message = new StringBuilder("Expires in");

            if (tempo.Expiration.Days > 0)
            {
                message.AppendFormat(" {0} days", tempo.Expiration.Days);
            }
            if (tempo.Expiration.Hours > 0)
            {
                message.AppendFormat(" {0} hours", tempo.Expiration.Hours);
            }
            if (tempo.Expiration.Minutes > 0)
            {
                message.AppendFormat(" {0} minutes", tempo.Expiration.Minutes);
            }
            if (tempo.Expiration.Seconds > 0)
            {
                message.AppendFormat(" {0} seconds", tempo.Expiration.Seconds);
            }
            from.SendMessage(message.ToString());
        }

You will need to add the using System.Text; for that though. Also in case someone really would hit it in the millisecond area without any seconds left they would just get "Expires in". So you can play around with that if you want it to not happen.
 
Should be as simple as this for example:
from.SendMessage(0x23, message.ToString());
 
Back