Exemple #1
0
        /// <summary>
        /// Returns a list of all elements of type T
        /// </summary>
        public static List <T> GetByType <T>(Element startAt) where T : Element
        {
            List <T> elements = new List <T>();

            if (!ElementTypeNames.ContainsKey(typeof(T)))
            {
                return(elements);
            }
            List <dynamic> mtaElements = MtaShared.GetListFromTable(MtaServer.GetElementsByType(ElementTypeNames[typeof(T)], startAt.MTAElement), "element");

            foreach (dynamic mtaElement in mtaElements)
            {
                Element element = ElementManager.Instance.GetElement((MtaElement)mtaElement);
                if (element != null && element is T)
                {
                    elements.Add((T)element);
                }
            }

            return(elements);
        }
        /// <summary>
        /// Get a list of all classes of a specific element
        /// </summary>
        public List <T> GetByType <T>(Element startAt, bool streamedIn = false) where T : Element
        {
            List <T> elements = new List <T>();

            if (!defaultElementTypeNames.ContainsKey(typeof(T)))
            {
                return(elements);
            }

            List <dynamic> mtaElements = MtaShared.GetListFromTable(MtaClient.GetElementsByType(defaultElementTypeNames[typeof(T)], startAt?.MTAElement, streamedIn), "element");

            foreach (dynamic mtaElement in mtaElements)
            {
                T element = GetElement <T>(mtaElement);
                if (element != null)
                {
                    elements.Add(element);
                }
            }

            return(elements);
        }
Exemple #3
0
        /// <summary>
        /// Get if a skin id is valid
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool IsValidSkin(int model)
        {
            List <int> models = MtaShared.GetListFromTable(MtaShared.GetValidPedModels(), "System.Int32");

            return(models.Contains(model));
        }