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!

Resource icon

[2.x] Trash Bag With Points 0.0.3

No permission to download

Bittiez

Sorceror
Bittiez submitted a new resource:

Trash Bag With Points (version 0.0.2) - Trash Bag with (potentially) redeemable points!

This is a trash bag that players can carry around in their backpack to help keep your shard clean, not only does it make it easy to throw things away rather than all over the ground, but it adds points when you throw things away that you can let players spend on whatever you see fit.

This is the vendor script that I use to allow players to spend points from the...

Read more about this resource...
 

bazspeed

Sorceror
Hi mate, can you tell me how I can make the bag check for blessed and insured items?

If true, to return false.

Cheers
 

bazspeed

Sorceror
Actually I was wrong.

If i add

if (item.LootType == LootType.Blessed)
return false;

It checks for blessed items perfectly and stops blessed items going in.

But if i add

if (item.PayedInsurance = true)
return false;

It then prevents ALL items going in. Any ideas?
 

Bittiez

Sorceror
Try if(item.Insured) instead

On a side note: When checking if something is true or false you do not need to use == true
if(boolean)
{
This will happen if it is true
}




if(!boolean)
{
this will happen if it is false
}
 

bazspeed

Sorceror
HI Mate

Got a question for you. I managed to get the check to work on blessed items but the insured does not work, i have taken them out at the moment.

The question I have, the bless check works on single items, but i have been trying to get it to check the bag content before deleting. Any ideas?

Code:
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
using System.Collections.Generic;
using System.Reflection;
using System.Collections;
 
namespace Server.Items
{
    public class TrashBag : Bag
    {
 
        private int m_Points;
 
        [CommandProperty(AccessLevel.GameMaster)]
        public int Points { get { return m_Points; } set { m_Points = value; InvalidateProperties(); } }
 
        [Constructable]
        public TrashBag()
        {
            LootType = LootType.Blessed;
            Movable = true;
            m_Points = 0;
            Name = "a trash bag";
            Hue = 54;
        }
 
 
        public TrashBag(Serial serial)
            : base(serial)
        {
        }
 
 
 
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (!base.OnDragDrop(from, dropped))
                return false;
            if (dropped is Gold)
                return false;
            if (dropped.LootType == LootType.Blessed)
                return false;
            /*if (dropped.PayedInsurance = true)
                return false;*/
            if (dropped is BaseContainer)
                seachbag(dropped);
 
            m_Points += dropped.Amount;
            dropped.Delete();
 
            dropped.InvalidateProperties();
            return true;
        }
 
        public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
        {
            if (!base.OnDragDropInto(from, item, p))
                return false;
            if (item is Gold)
                return false;
            if (item.LootType == LootType.Blessed)
                return false;
            /*if (item.PayedInsurance = true)
                return false;*/
            if (item is BaseContainer)
                seachbag(item);
            m_Points += item.Amount;
            item.Delete();
 
            item.InvalidateProperties();
            return true;
        }
 
        private void seachbag(Item b)
        {
            BaseContainer bag = (BaseContainer)b;
            List<Item> items = bag.Items;
        List<Item> delme = new List<Item>();
            foreach (Item i in items)
            {
                if (i is Gold)
                    continue;
        if (i is BaseContainer)
                    seachbag(i);
                delme.Add(i);
            }
 
            foreach (Item i in delme)
            {
                if (!i.Deleted)
                {
                    m_Points += i.Amount;
                    i.Delete();
                }
            }
 
        }
 
 
 
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
 
            if (m_Points > 0)
                list.Add("  <BASEFONT COLOR=#cc0000>{0}<BASEFONT COLOR=#001bcc> Trash points!", m_Points.ToString());
            else list.Add(" *Empty* ");
        }
 
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)m_Points);
            writer.Write((int)0); // version
        }
 
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            m_Points = reader.ReadInt();
            int version = reader.ReadInt();
        }
    }
}

Thnx in advance
 

bazspeed

Sorceror
thnx for that Bittiez. Another question now, if items are in a bag when you drag or drop on the trashbag and they are not checked for blessed etc.

can you do a line for that please?
 

Bittiez

Sorceror
That one takes a few more edits, first:

In the OnDragDropInto method, you must change:
C#:
seachbag(item);
to
C#:
seachbag(item, from);

And replace your current searchbag method with this:
C#:
        private void seachbag(Item b, Mobile from)
        {
            BaseContainer bag = (BaseContainer)b;
            List<Item> items = bag.Items;
            List<Item> delme = new List<Item>();
            List<Item> movme = new List<Item>();
            foreach (Item i in items)
            {
                if (i is Gold || i.CheckNewbied() || i.Insured || i.PayedInsurance)
                {
                    movme.Add(i);
                    continue;
                }
                if (i is BaseContainer)
                    seachbag(i, from);
                delme.Add(i);
            }
 
            foreach (Item i in movme)
            {
                if (!i.Deleted)
                    from.PlaceInBackpack(i);
            }
 
            foreach (Item i in delme)
            {
                if (!i.Deleted)
                {
                    m_Points += i.Amount;
                    i.Delete();
                }
            }
        }

I haven't tested this, but in theory it should work, let me know if it doesn't.
 

bazspeed

Sorceror
HI, didnt work mate

CS1501: Line 51: No overload for method 'seachbag' takes '1' arguments

Also, can the blessed type be added?
 

Bittiez

Sorceror
HI, didnt work mate

CS1501: Line 51: No overload for method 'seachbag' takes '1' arguments

Also, can the blessed type be added?
Line 51:
C#:
seachbag(dropped);
to
C#:
seachbag(dropped, from);
Missed that one, sorry

i.CheckNewbied() <-- This is the blessed part
 

Bittiez

Sorceror
I have added the extra, but still deletes blessed, keeps insured tho

it also deletes gold
I don't know why you have so many issues with this, you can try adding a check for item.CheckBlessed(from), as for the gold I don't know, unless you are using custom gold it should be working.
 

otimpyre

Sorceror
Don't see any vendor included. First post says this is the vendor I allow players to spend points on. Could I possibly get that? Love all your scripts. NVM it was a clicky link in the text. :oops:
 
Top