ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So trying to get code to work but am getting the following errors..
C#:
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(74,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'message' of 'TrashBagBrit.Empty(Mobile, int)' [C:\ServUO\Scripts\Scripts.csproj]
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(100,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'message' of 'TrashBagBrit.Empty(Mobile, int)' [C:\ServUO\Scripts\Scripts.csproj]
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(188,26): error CS7036: There is no argument given that corresponds to the required formal parameter 'message' of 'TrashBagBrit.Empty(Mobile, int)' [C:\ServUO\Scripts\Scripts.csproj]
 
Last edited:
Your "Empty" method requires two parameters: a mobile (from) and an integer (messagem).
On error lines you are trying to call "Empty" with only one parameter (I guess it is the "messagem").

You should pass also the mobile if you need it, e.g. for line 73: Empty(from, 501478) or remote the first parameter if not needed in the code at line 128, e.g. "public void Empty(int messagem)"
 
You caught me right as I was editing the post haha, I edited out the lines that were causing issues and it compiles with what I posted but yes those 3 lines are supposed to be messages to the player.

You got me thinking about that int though so I removed it and the top 2 work now, the bottom last one I'm not sure how to add a message to.
 
Last edited:
Hard to tell which line(s) still need editing but you can edit the timer to grab the mobile you're sending the cliloc to by using the 'from' in dragdrop

EDIT: Sorry for the crap explanation, but coding on phone isnt fun
 
Hard to tell which line(s) still need editing but you can edit the timer to grab the mobile you're sending the cliloc to by using the 'from' in dragdrop

EDIT: Sorry for the crap explanation, but coding on phone isnt fun
This section I can't get working, using Mobile from and send message throws a no suitable method found to override error.
C#:
        private class EmptyTimer : Timer
        {
            private readonly TrashBagBrit m_Barrel;
            public EmptyTimer(TrashBagBrit barrel)
                : base(TimeSpan.FromMinutes(3.0))
            {
                m_Barrel = barrel;
                Priority = TimerPriority.FiveSeconds;
            }

            protected override void OnTick(Mobile from)
            {
                from.SendMessage("The trash is full!  Emptying!"); //m_Barrel.Empty(501479); // Emptying the trashcan!
            }
        }
 
Well you want to send it to the player that carries the bag right?

and you cant just add a paramenter to OnTick inside the class, since it would never be called as it does not exist. And since it does not exist you cant override it.


C#:
        private class EmptyTimer : Timer
        {
            private readonly TrashBagBrit m_Barrel;
            public EmptyTimer(TrashBagBrit barrel)
                : base(TimeSpan.FromMinutes(3.0))
            {
                m_Barrel = barrel;
                Priority = TimerPriority.FiveSeconds;
            }

            protected override void OnTick()
            {
                if(m_Barrel.RootParent is Mobile)
                    m_Barrel.RootParent.SendMessage("The trash is full!  Emptying!"); //m_Barrel.Empty(501479); // Emptying the trashcan!
                else
                    m_Barrel.PublicOverheadMessage(MessageType.Regular, 0, true, "The trash is full!  Emptying!");
            }
        }
 
Well you want to send it to the player that carries the bag right?

and you cant just add a paramenter to OnTick inside the class, since it would never be called as it does not exist. And since it does not exist you cant override it.


C#:
        private class EmptyTimer : Timer
        {
            private readonly TrashBagBrit m_Barrel;
            public EmptyTimer(TrashBagBrit barrel)
                : base(TimeSpan.FromMinutes(3.0))
            {
                m_Barrel = barrel;
                Priority = TimerPriority.FiveSeconds;
            }

            protected override void OnTick()
            {
                if(m_Barrel.RootParent is Mobile)
                    m_Barrel.RootParent.SendMessage("The trash is full!  Emptying!"); //m_Barrel.Empty(501479); // Emptying the trashcan!
                else
                    m_Barrel.PublicOverheadMessage(MessageType.Regular, 0, true, "The trash is full!  Emptying!");
            }
        }
So using that I get this:
C#:
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(177,41): error CS1061: 'object' does not contain a definition for 'SendMessage' and no accessible extension method 'SendMessage' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) [C:\ServUO\Scripts\Scripts.csproj]
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(179,52): error CS0103: The name 'MessageType' does not exist in the current context [C:\ServUO\Scripts\Scripts.csproj]
 
Last edited:
Down to 1 haha..
C#:
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(179,41): error CS1061: 'object' does not contain a definition for 'SendMessage' and no accessible extension method 'SendMessage' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) [C:\ServUO\Scripts\Scripts.csproj]
 
Sorry my bad, forgot to cast to Mobile :)

m_Barrel.RootParent.SendMessage("Emptying the trashcan!");

should be

((Mobile)]m_Barrel.RootParent).SendMessage("Emptying the trashcan!");
 
Sorry my bad, forgot to cast to Mobile :)

m_Barrel.RootParent.SendMessage("Emptying the trashcan!");

should be

((Mobile)]m_Barrel.RootParent).SendMessage("Emptying the trashcan!");
Had a typo in that but I got rid of the "]" and it compiled, testing it now haha. Also thank you!

Okay so it works and talks to the player correctly, I have one last problem, items don't get deleted lol.. I assume it's because this "Empty" I commented out is needed to call something to empty it?
C#:
        public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
        {
            if (!base.OnDragDropInto(from, item, p))
                return false;

            AddCleanupItem(from, item);

            if (TotalItems >= 50)
            {
                from.SendMessage("The trash is full!  Emptying!"); //Empty(501478); // The trash is full!  Emptying!
            }
            else
            {
                from.SendMessage("The item will be deleted in three minutes."); //SendLocalizedMessageTo(from, 1010442); // The item will be deleted in three minutes

                if (m_Timer != null)
                    m_Timer.Stop();
                else
                    m_Timer = new EmptyTimer(this);

                m_Timer.Start();
            }

            return true;
        }

to answer my own question, yes it is lol..
C#:
        public void Empty(Mobile from, int message)
        {
            PlayerMobile mobile = from as PlayerMobile;

            List<Item> items = Items;

            if (items.Count > 0)
            {
                PublicOverheadMessage(Network.MessageType.Regular, 0x3B2, message, "");

                for (int i = items.Count - 1; i >= 0; --i)
                {
                    if (i >= items.Count)
                        continue;

                    ConfirmCleanupItem(items[i]);

                    #region SA
                    if (.01 > Utility.RandomDouble())
                        DropToCavernOfDiscarded(items[i]);
                    else
                        items[i].Delete();
                    #endregion
                }

                if (m_Cleanup.Any(x => x.mobiles != null))
                {
                    foreach (var m in m_Cleanup.Select(x => x.mobiles).Distinct())
                    {
                        if (m_Cleanup.Find(x => x.mobiles == m && x.confirm) != null)
                        {
                            double point = m_Cleanup.Where(x => x.mobiles == m && x.confirm).Sum(x => x.points);
                            //m.SendLocalizedMessage(1151280, String.Format("{0}\t{1}", point.ToString(), m_Cleanup.Count(r => r.mobiles == m))); // You have received approximately ~1_VALUE~points for turning in ~2_COUNT~items for Clean Up Britannia.
                            from.SendMessage("You have received approximately {0} points for turning in {1} items for Clean Up Britannia.", point.ToString(), m_Cleanup.Count(r => r.mobiles == m));
                            PointsSystem.CleanUpBritannia.AwardPoints(m, point);
                        }
                    }
                    m_Cleanup.Clear();
                }
            }
 
Last edited:
Ok final thing, trying to add a context menu to clear the trash bag at will. Here is what I have so far:
C#:
        public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {
            base.GetContextMenuEntries(from, list);
            List<Item> items = Items;
            if (items.Count > 0)
                list.Add(new EmptyTrash());
        }

        public class EmptyTrash : ContextMenuEntry
        {
            public EmptyTrash() : base(0154, 5)
            {
            }

            public override void OnClick()
            {
                Empty(0);
            }
        }

Here is the error I'm getting:
C#:
C:\ServUO\Scripts\Custom\Custom Items\TrashBagBrit.cs(137,17): error CS0120: An object reference is required for the non-static field, method, or property 'TrashBagBrit.Empty(int)' [C:\ServUO\Scripts\Scripts.csproj]
 
Last edited:
You are trying to call "Empty" method from another class (TrashBagBrit) without a reference to a specific instance of it.
This should be working for your code.
You have to pass the instance as argument in the constructor, so line 126 should be modified accordingly ("list.Add(new EmptyTrash(this));")

C#:
        private class EmptyTrash : ContextMenuEntry
        {
            private readonly TrashBagBrit trashBagBrit;
            
            public EmptyTrash(TrashBagBrit trashBagBrit) : base(0154, 5)
            {
                this.trashBagBrit = trashBagBrit;
            }

            public override void OnClick()
            {
                trashBagBrit.Empty(0);
            }
        }
 
Hmm could someone look this over for me, it never seems to be calling the 3 min timer to remove the items from existence.. I am unsure why.. I can use the context menu to manually clear the items.
C#:
        private class EmptyTrash : ContextMenuEntry
        {
            private readonly TrashBagBrit trashBagBrit;

            public EmptyTrash(TrashBagBrit trashBagBrit) : base(0154, 5)
            {
                this.trashBagBrit = trashBagBrit;
            }

            public override void OnClick()
            {
                trashBagBrit.Empty(0);
            }
        }

        public void Empty(int message)
        {
            List<Item> items = Items;

            if (items.Count > 0)
            {
                PublicOverheadMessage(Network.MessageType.Regular, 0x3B2, message, "");

                for (int i = items.Count - 1; i >= 0; --i)
                {
                    if (i >= items.Count)
                        continue;

                    ConfirmCleanupItem(items[i]);

                    #region SA
                    if (.01 > Utility.RandomDouble())
                        DropToCavernOfDiscarded(items[i]);
                    else
                        items[i].Delete();
                    #endregion
                }

                if (m_Cleanup.Any(x => x.mobiles != null))
                {
                    foreach (var m in m_Cleanup.Select(x => x.mobiles).Distinct())
                    {
                        if (m_Cleanup.Find(x => x.mobiles == m && x.confirm) != null)
                        {
                            double point = m_Cleanup.Where(x => x.mobiles == m && x.confirm).Sum(x => x.points);
                            m.SendMessage("You have received approximately {0} points for turning in {1} items for Clean Up Britannia.", point.ToString(), m_Cleanup.Count(r => r.mobiles == m)); // You have received approximately ~1_VALUE~points for turning in ~2_COUNT~items for Clean Up Britannia.
                            PointsSystem.CleanUpBritannia.AwardPoints(m, point);
                        }
                    }
                    m_Cleanup.Clear();
                }
            }

            if (m_Timer != null)
                m_Timer.Stop();

            m_Timer = null;
        }

        private class EmptyTimer : Timer
        {
            private readonly TrashBagBrit m_Bag;
            public EmptyTimer(TrashBagBrit bag)
                : base(TimeSpan.FromMinutes(3.0))
            {
                m_Bag = bag;
                Priority = TimerPriority.FiveSeconds;
            }

            protected override void OnTick()
            {
                if (m_Bag.RootParent is Mobile)
                    ((Mobile)m_Bag.RootParent).SendMessage("Emptying the trashcan!"); //m_Bag.Empty(501479); // Emptying the trashcan!
                else
                    m_Bag.PublicOverheadMessage(MessageType.Regular, 0, true, "Emptying the trashcan!");
            }
        }
    }
}
 
Last edited:
C#:
if (m_Timer != null)
  m_Timer.Stop();
else
  m_Timer = new EmptyTimer(this);

Maybe is this piece of code: you are not creating a new timer while you add items into container, so it will be the already expired one.

Try to remove the "else" and recreate a timer at every item drop.
 
Well good news is it called the timer this time and actually said it was emptying it, but it didn't empty it haha.

Okay fixed it.. it wasn't calling "empty" in the timer.. had to add this to it:
C#:
m_Bag.Empty(0);
 
Last edited:
Back