Beispiel #1
0
        public List <MenuItem> GetRecentSkinMenu()
        {
            var menu         = new List <MenuItem>();
            var actionPrefix = "playerskin";

            if (Config.ContainsKey("RecentSkins"))
            {
                List <int> recentSkins = PlayerSection.ParseRecentSkins(Config["RecentSkins"]);

                foreach (var modelHash in recentSkins)
                {
                    PedModelListItem info = PedModelList.GetItemByHash(modelHash);

                    if (info != null)
                    {
                        menu.Add(new MenuItem()
                        {
                            text   = info.Name,
                            key    = info.ModelHash.ToString(),
                            action = $"{actionPrefix} {info.Model}",
                        });
                    }
                }
            }

            if (menu.Count == 0)
            {
                menu.Add(new MenuItem()
                {
                    text = "No recent skins yet!",
                });
            }

            return(menu);
        }
        public void UpdateRecentSkinsList(Model model)
        {
            var modelInfo = PedModelList.GetItemByHash(model.Hash);

            if (modelInfo == null)
            {
                return;
            }

            RecentSkins.Insert(0, model.Hash);
            // Remove duplicates
            RecentSkins = RecentSkins.Union(RecentSkins).ToList();

            if (RecentSkins.Count > maxRecentSkins)
            {
                RecentSkins.RemoveRange(maxRecentSkins, RecentSkins.Count - maxRecentSkins);
            }

            Config["RecentSkins"] = string.Join(",", RecentSkins);
        }