Insert Coin

Member
Hello!Just getting some issues trying to install this system on a fresh servuo repo.
Issue is in:
C#:
public static bool IsEquipped(Item item)
        {
            if (item.Parent != null)
            {
                object parent = item.Parent;
               if (parent is Mobile)
                {
                    Mobile parent_m = (Mobile)parent;
                    if (parent_m.Items.Contains(this))
                        return true;
                }
            }
           return false;
        }

And error is:
C#:
 CS0026: Line 82: La palabra clave 'this' no es válida en una propiedad, método o inicializador de campo estáticos
CS1502: Line 82: La mejor coincidencia de método sobrecargado para 'System.Collections.Generic.List<Server.Item>.Contains(Server.Item)' tiene algunos argumentos no válidos
CS1503: Line 82: Argumento 1: no se puede convertir de 'Server.Items.ItemSets' a 'Server.Item'
Scripts: One or more scripts failed to compile or no script files were found.
Thank you!
 
If you could attach the whole script so that someone could see how the word "this" is defined in this script it will probably make it easier for someone to help you figure it out more easily.
 
C#:
CS1503: Line 82: Argumento 1: no se puede convertir de 'Server.Items.ItemSets' a 'Server.Item'

if (parent_m.Items.Contains(this))

the this in this case is ItemSets, not sure what that class is or what it does. But you try to use a method wrong there
 
Sure,thank you all!Still getting error.Here the script:

C#:
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

using Server;
using Server.Mobiles;

namespace Server.Items
{
    public class ItemSets
    {
        private static Dictionary<Type, ItemSet> m_Registry = new Dictionary<Type, ItemSet>();
        public static Dictionary<Type, ItemSet> Registry { get { return m_Registry; } }

        private static Dictionary<Type, List<ItemSet>> m_PartRegistry = new Dictionary<Type, List<ItemSet>>();
        public static Dictionary<Type, List<ItemSet>> PartRegistry { get { return m_PartRegistry; } }

        public static void Initialize()
        {
            Type[] types = Assembly.GetAssembly(typeof(ItemSet)).GetTypes();

            foreach (Type type in types)
            {
                if (type != null && type.IsSubclassOf(typeof(ItemSet)) && !type.IsAbstract)
                {
                    ItemSet set = (ItemSet)type.GetConstructor(new Type[0]).Invoke(new object[0]);

                    if (set == null)
                        continue;

                    Register(set);
                }
            }
        }

        private static void Register(ItemSet set)
        {
            //Console.WriteLine("Registering: {0} - {1}", set.Name, set.TypeOf.Name);

            if (!m_Registry.ContainsKey(set.TypeOf))
                m_Registry.Add(set.TypeOf, set);

            foreach (SetPart part in set.Parts)
            {
                //Console.WriteLine("Registering Part: {0} - {1}", part.Name, part.TypeOf.Name);

                if (!m_PartRegistry.ContainsKey(part.TypeOf))
                    m_PartRegistry.Add(part.TypeOf, new List<ItemSet>());

                if (m_PartRegistry[part.TypeOf] == null)
                    m_PartRegistry[part.TypeOf] = new List<ItemSet>();

                m_PartRegistry[part.TypeOf].Add(set);
            }
        }

        public static void Invalidate(Mobile owner)
        {
            foreach (Item part in owner.Items)
            {
                if (part == null || part.Deleted)
                    continue;

                if (IsEquipped(part))
                    CheckPartAdded(owner, part);
                else
                    CheckPartRemoved(owner, part);
            }
        }

        public static bool IsEquipped(Item item)
        {
            if (item.Parent != null)
            {
                object parent = item.Parent;

                if (parent is Mobile)
                {
                    Mobile parent_m = (Mobile)parent;

                    if (parent_m.Items.Contains(this))
                        return true;
                }
            }

            return false;
        }

        public static void Activate(Mobile owner)
        {
            foreach (Item part in owner.Items)
            {
                if (part == null || part.Deleted)
                    continue;

                List<ItemSet> sets = ItemSets.Find(part);

                if (sets == null)
                    return;

                foreach (ItemSet set in sets)
                {
                    if (set == null)
                        continue;

                    int partCount = set.Invalidate(owner, false);

                    set.Activate(owner, partCount);
                }
            }
        }

        public static void Deactivate(Mobile owner)
        {
            foreach (Item part in owner.Items)
            {
                if (part == null || part.Deleted)
                    continue;

                List<ItemSet> sets = ItemSets.Find(part);

                if (sets == null)
                    return;

                foreach (ItemSet set in sets)
                {
                    if (set == null)
                        continue;

                    set.Deactivate(owner, 0);
                }
            }
        }

        public static void CheckPartAdded(Mobile owner, Item part)
        {
            //Console.WriteLine("Equip Part: {0} - {1}", part.Name, part.GetType().Name);

            List<ItemSet> sets = ItemSets.Find(part);

            if (sets == null)
                return;

            foreach (ItemSet set in sets)
            {
                if (set == null)
                    continue;

                //Console.WriteLine("Found Set: {0} - {1}", set.Name, set.TypeOf.Name);

                set.PartAdded(owner, part);
            }
        }

        public static void CheckPartRemoved(Mobile owner, Item part)
        {
            //Console.WriteLine("Remove Part: {0} - {1}", part.Name, part.GetType().Name);

            List<ItemSet> sets = ItemSets.Find(part);

            if (sets == null)
                return;

            foreach (ItemSet set in sets)
            {
                if (set == null)
                    continue;

                //Console.WriteLine("Found Set: {0} - {1}", set.Name, set.TypeOf.Name);

                set.PartRemoved(owner, part);
            }
        }

        public static List<ItemSet> Find(Item part)
        {
            Type partType = part.GetType();

            //Console.WriteLine("Finding Sets From Part: {0} - {1}", part.Name, partType.Name);

            if (m_PartRegistry.ContainsKey(partType))
            {
                if (m_PartRegistry[partType] == null)
                    m_PartRegistry[partType] = new List<ItemSet>();

                return m_PartRegistry[partType];
            }

            return new List<ItemSet>();
        }

        public static void EquipTo(Mobile owner, Type setType)
        {
            try
            {
                ItemSet set = ItemSets.GetInstance(setType);

                if (set == null)
                    return;

                for (int i = 0; i < set.Parts.Length; i++)
                {
                    SetPart part = set.Parts[i];

                    if (part == null || !part.Valid)
                        continue;

                    Item item = part.TypeOf.GetConstructor(new Type[0]).Invoke(new object[0]) as Item;

                    owner.AddItem(item);
                }

                set.Invalidate(owner, true);
            }
            catch { }
        }

        public static Item GetRandomPart(Type setType)
        {
            try
            {
                ItemSet set = ItemSets.GetInstance(setType);

                if (set == null)
                    return null;

                SetPart part = set.Parts[Utility.Random(set.Parts.Length)];

                while (!part.Valid)
                {
                    part = set.Parts[Utility.Random(set.Parts.Length)];
                }

                Item item = part.TypeOf.GetConstructor(new Type[0]).Invoke(new object[0]) as Item;

                if (item != null && !item.Deleted)
                    return item;
            }
            catch { }

            return null;
        }

        public static Type GetRandomPartType(Type setType)
        {
            ItemSet set = ItemSets.GetInstance(setType);

            SetPart part = set.Parts[Utility.Random(set.Parts.Length)];

            while (!part.Valid)
            {
                part = set.Parts[Utility.Random(set.Parts.Length)];
            }

            return part.TypeOf;
        }

        public static ItemSet GetInstance(Type setType)
        {
            if (m_Registry.ContainsKey(setType))
                return m_Registry[setType];

            return null;
        }
    }
}

This script is designed for runuo,attached the full script.
 

Attachments

  • Armor set.rar
    4 KB · Views: 0

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back