RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Looping

AlphaDragon

Sorceror
Seems to work then get:
to much data pending, then core has stoped working.

Any Ideas?
:oops:





Code:
#region AuthorHeader
//
//    Auction version 2.1, by Xanthos and Arya
//
//  Based on original ideas and code by Arya
//
#endregion AuthorHeader
using System;
 
 
using Server;
using Server.Targeting;
 
using Server.Gumps;
 
namespace Arya.Auction
{
    /// <summary>
    /// General purpose target used by the auction system
    /// </summary>
    public class AuctionTarget : Target
    {
        private AuctionTargetCallback m_Callback;
 
        public AuctionTarget( AuctionTargetCallback callback, int range, bool allowground ) : base( range, allowground, TargetFlags.None )
        {
            m_Callback = callback;
        }
 
        private void checktocontinue (Mobile from , object targeted)
        {
            if (from == null)
            {
             
            }
            else
            {
                if (from.HasGump(typeof(NoticeGump)))
                {
                    from.SendMessage("has gump notice. check");
                    checktocontinue(from, targeted);
                    return;
                }
                else// if(!(from.HasGump(typeof(NoticeGump))))
                {
                    from.SendMessage("else has gump notice. check");
                    from.SendGump( new AuctionGump( from ) );
                }
            }
        }
     
        protected override void OnTarget(Mobile from, object targeted)
        {
            try
            {
                m_Callback.DynamicInvoke( new object[] { from, targeted } );
            }
            catch
            {
//                Console.WriteLine( "The auction system cannot access the cliloc.enu file. Please review the system instructions for proper installation" );
//                from.SendMessage (38,"My manager changed his mind and wont add this item to the auctions.");
                if (targeted != null)
                {
                    from.SendMessage ("target ! null");
                    if (targeted is Item)
                    {
                        ((Item)targeted).Visible = true;
                        from.SendGump( new NoticeGump( 1060637, 30720, "My Manager changed his mind and wont add this item to the auctions. For some reason he doesnt like the item.", 0xFFC000, 320, 240, null, null ) );
                        checktocontinue(from, targeted);
                     
                    }
                    else
                    {
//                    from.SendMessage (38,"My manager changed his mind and wont add this item to the auctions.");
                        from.SendGump( new NoticeGump( 1060637, 30720, "My Manager changed his mind and wont add this to the auctions. I can always try something else. For some reason he doesnt like the item.", 0xFFC000, 320, 240, null, null ) );
                        checktocontinue(from, targeted);
                    }
                }
                else
                {
                    from.SendMessage ("targeted was null");
                }
            }
        }
     
        protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
        {
            if ( AuctionSystem.Running )
            {
                from.SendGump( new AuctionGump( from ) );
            }
        }
    }
}
 

Attachments

  • 1.JPG
    13 KB · Views: 25
  • 2.JPG
    17.9 KB · Views: 24
Code:
        private void checktocontinue (Mobile from , object targeted)
        {
            if (from == null)
            {
         
            }
            else
            {
                if (from.HasGump(typeof(NoticeGump)))
                {
                    from.SendMessage("has gump notice. check");
                    checktocontinue(from, targeted);
                    return;
                }
                else// if(!(from.HasGump(typeof(NoticeGump))))
                {
                    from.SendMessage("else has gump notice. check");
                    from.SendGump( new AuctionGump( from ) );
                }
            }
        }

If you are successful in your gump check you are telling it to checktocontinue again for the gump which will of course come back positive.

I change it to be like this and it should solve your problem:

Code:
private void checktocontinue (Mobile from , object targeted)
        {
            if (from == null)
            {
       
            }
            else
            {
                if (from.HasGump(typeof(NoticeGump)))
                {
                    from.SendMessage("has gump notice. check");
                    return;
                }
                else// if(!(from.HasGump(typeof(NoticeGump))))
                {
                    from.SendMessage("else has gump notice. check");
                    from.SendGump( new AuctionGump( from ) );
                }
            }
        }
 

AlphaDragon

Sorceror
Apparently some of my initial post is missing. I was writing it as we had a power storm and had to redo it.

What I was trying to do, was the npc to send an initial gump:

from.SendGump( new NoticeGump( 1060637, 30720, "My Manager changed his mind and wont add this item to the auctions. For some reason he doesnt like the item.", 0xFFC000, 320, 240, null, null ) );


then do a loop, checking to see if the player still had the initial gump.

If player did have the gump opened to do loop again.

If player didn't have the initial gump, then to send the second gump:

from.SendGump( new AuctionGump( from ) );


Example:

Send 1st-gump

LOOP to check if player still has 1st-gump opened. if he has 1st-gump do LOOP again. If he does not have 1stgump opened, send 2nd gump. Finished.


The way you said in your post doesn't send the 2nd gump.
 

AlphaDragon

Sorceror
Your probably right. Would save on cpu processing / consumption, along with all the other possibilities of headaches down the line.

One gump ,to call another.

Seems better then trying to loop and have it auto do it (and have possibilities of problems down the line, for one reason or another.) :rolleyes:

Thanks.
 

daat99

Moderator
Staff member
Make sure you address all other button responses that may be returned using "razor" or some other game automating tool.
The players can record a gump response and if you ignore it (not being 0) and still close the gump than they will have a loophole on having the gump remain open when you don't want it to.
 
Top