Иконка ресурса

FREE Shop : 0.0.2 0.0.2

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Oxide.Core.Libraries;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Oxide.Game.Rust.Libraries;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Shop","Mystery","0.0.2")]
    class Shop : RustPlugin
    {

        [PluginReference] private Plugin ImageLibrary, Eco;
        public static string S = "Shop_UI";
        public string Api = "https://rustplugins.top/api/";

        void UiShop(BasePlayer player)
        {
            CuiHelper.DestroyUi(player, S);
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.00 0.10 1.00" },
            }, "Overlay", S);
            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0.9", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.00 0.25 1.00" },
            }, S,S+"Title");
            container.Add(new CuiElement
            {
                Parent = S + "Title",
                Components =
                {
                    new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", player.UserIDString) },
                    new CuiRectTransformComponent { AnchorMin = "0.002 0.05", AnchorMax = "0.06 0.95" }
                }
            });
            container.Add(new CuiElement
            {

                Parent = S + "Title",
                Components =
                {
                    new CuiTextComponent {Text = $"{player.displayName}\n{player.UserIDString}", Align = TextAnchor.MiddleLeft, FontSize = 15, Color = "0.72 0.83 0.71 1.00"},
                    new CuiRectTransformComponent { AnchorMin = "0.07 0", AnchorMax = $"0.2 1" },
                    new CuiOutlineComponent { Color = "0 0 0 0.5", Distance = "0.5 0.5" }
                }
            }); 
            container.Add(new CuiButton
            {
                RectTransform = { AnchorMin = "0.965 0.3", AnchorMax = $"0.99 0.7" },
                Button = { Close = S, Sprite = "assets/icons/close.png", Color = "1 0 0 1" },
                Text = { Text = $"" }
            }, S + "Title");
            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0.125 0", AnchorMax = "1 0.89", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.00 0.25 1" },
            }, S, S + "item");
            container.Add(new CuiElement
            {

                Parent = S + "item",
                Components =
                {
                    new CuiTextComponent {Text = $"{player.displayName}\n{player.UserIDString}", Align = TextAnchor.MiddleCenter, FontSize = 15, Color = "0.72 0.83 0.71 1.00"},
                    new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = $"1 1" },
                    new CuiOutlineComponent { Color = "0 0 0 0.5", Distance = "0.5 0.5" }
                }
            });



            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "0.12 0.89", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.00 0.25 1.00" },
            }, S, S + "Point");
            CuiHelper.AddUi(player, container);
            Points(player);
        }
        void Items(BasePlayer player,string it, int page = 0)
        {
            int x = 0, y = 0, i = 15 * page;
            CuiHelper.DestroyUi(player, S + "item");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0.125 0", AnchorMax = "1 0.89", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.00 0.25 1" },
            }, S, S + "item");
            foreach(var iii in Settings.Ite)
            {
                if(iii.Key == it)
                {
                    foreach(var ii in iii.Value.Res.Skip(15*page).Take(15))
                    {
                        var image = ii.Shortname;
                        if (ii.Command) image = ii.Image;
                        container.Add(new CuiPanel
                            {
                                CursorEnabled = true,
                                RectTransform = { AnchorMin = $"{0.005 + (x * 0.2)} {0.8 - (y * 0.2)}", AnchorMax = $"{0.193 + (x * 0.2)} {0.98 - (y * 0.2)}" },
                                Image = { Color = "0.00 0.00 0.10 1" },
                            }, S + "item", S + $"item.{ii.Name}");
                            container.Add(new CuiElement
                            {
                                Parent = S + $"item.{ii.Name}",
                                Components =
                                                {
                                                    new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", image, ii.SkinId)},
                                                    new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0.5 1" },
                                                }
                            });

                        i++;
                        x++;
                        if (x == 5)
                        {
                            x = 0;
                            y++;
                        }
                        if (y == 5 && x == 0)
                            break;
                    }
                    
                }
            }





            CuiHelper.AddUi(player, container);
        }
       
        [ChatCommand("shop")]
        private void CmdChatStore(BasePlayer player, string command, string[] args)
        {
            UiShop(player);
        }
        [ConsoleCommand("shop")]
        private void CmdConsoleRustMenu(ConsoleSystem.Arg args)
        {
            var player = args.Player();
            if (player == null || !args.HasArgs(1)) return;

            switch (args.Args[0].ToLower())
            {
                case "find":
                    {
                        var i = args.Args[1];
                        Items(player, i);
                        //Points(player, i);
                        break;
                    }
                case "page":
                    {
                        Items(player, args.Args[1]);
                        break;
                    }

            }
        }
        void Points(BasePlayer player)
        {
           // CuiHelper.DestroyUi(player, "point");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" },
                Image = { Color = "0.00 0.20 0.25 0.00" },
            },S + "Point", "point");
            float marginTop = -2;

            float originalHeight = 35;
            float freeHeight = 35;

            float padding = 3;
            foreach (var i in Settings.Ite)
            {
                CuiHelper.DestroyUi(player, "point" + i);
                Puts(i.Key);
                string color = "0.72 0.83 0.71 1.00";
                string color1 = "0.0 0.0 0.10 1";
                float elementHeight = i.Key.Length > 0 ? originalHeight : freeHeight;
                container.Add(new CuiButton
                {
                    RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"4 {marginTop - elementHeight}", OffsetMax = $"150 {marginTop}" },
                    Button = { Command = $"shop find {i.Key}", Color = color1 },
                    Text = { Text ="  " +i.Key, Align = TextAnchor.MiddleLeft, Font = "robotocondensed-bold.ttf", FontSize = 20, Color = color }
                },"point","point"+i.Key);
                
                
                    container.Add(new CuiElement
                    {

                        Parent = "point" + i.Key,
                        Components =
                {
                    new CuiTextComponent {Text = $"{i.Value.Res.Count}", Align = TextAnchor.MiddleCenter, FontSize = 12, Color = "0.50 1.00 0.50 1.00"},
                    new CuiRectTransformComponent { AnchorMin = "0.88 0", AnchorMax = $"1 0.5" },
                    new CuiOutlineComponent { Color = "0 0 0 0.5", Distance = "0.5 0.5" }
                }
                    });
                
                
                marginTop -= elementHeight + padding;
            }

            CuiHelper.AddUi(player, container);
        }



        float Price(float price)
        {
            float p = 10;
            price = price / 100 * p;
            return price;
        }
        float eco(BasePlayer player)
        {
            var eco = 10;
            if(eco == null) return 0;
            return eco;
        }
        void GiveItem(BasePlayer player, string ShortName, int Amount, ulong SkinID)
        {
            var info = ItemManager.FindItemDefinition(ShortName);
            var item = ItemManager.Create(info, Amount, SkinID);
            player.GiveItem(item, BaseEntity.GiveItemReason.PickedUp);
        }
        void GiveCommand(BasePlayer player, string Command)
        {
            rust.RunServerCommand(Command.Replace("%SteamID%",$"{player.userID}"));
        }
        void OnServerInitialized()
        {
            foreach(var i in Settings.Ite.Values)
            {
                foreach(var ii in i.Res)
                {
                    ImageLibrary.Call("AddImage", Api + "image/" + ii.Shortname+ ".png", ii.Shortname + "Mystery", ii.SkinId);
                    ImageLibrary.Call("AddImage", ii.Image, ii.Image);
                }
                
            }
            
            BasePlayer.activePlayerList.ToList().ForEach(p => { UiShop(p); });
        }
        void Unload()
        {
            BasePlayer.activePlayerList.ToList().ForEach(p =>
            {
                CuiHelper.DestroyUi(p, S);

            });
        }
        class res
        {
            public string Name;
            public string Shortname;
            public ulong SkinId;
            public int Amount;
            [JsonProperty("command????")]
            public bool Command;
            [JsonProperty("command       %SteamID%  = player SteamID")]
            public string Commands;
            public string Image;
            public float price;
        }
        class Item
        {
            [JsonProperty("Item")]
            public List<res> Res = new List<res>();
        }
       
        private class Configuration
        {
            
            [JsonProperty("Point Shop")]
            public Dictionary<string, Item> Ite = new Dictionary<string, Item>();
            [JsonProperty("Discount")]
            public Dictionary<string, float> Dis = new Dictionary<string, float>();
            
            public static Configuration Generate()
            {
                return new Configuration
                {
                    Dis = new Dictionary<string, float> 
                    {
                        ["Shop.-10"] = 10,
                        ["Shop.-20"] = 20,
                        ["Shop.-30"] = 30,
                        ["Shop.-40"] = 40,
                        ["Shop.-50"] = 50,
                        ["Shop.-60"] = 60,
                        ["Shop.-70"] = 70
                      
                    },


                    
                    Ite = new Dictionary<string, Item>
                    {

                        ["Privilege"] = new Item
                        {
                            Res = new List<res>
                            {
                                new res
                                {
                                    Command = true,
                                    Name = "VIP 7 DAY",
                                    Image = "https://rustplugins.top/api/image/wood.png",
                                    Commands = "grant.group %SteamID% VIP 7d",
                                    price = 10.50f
                                }
                            },
                        },
                        ["Resources"] = new Item
                        {
                            Res = new List<res>
                            {
                                new res
                                {
                                    Name = "WOOD",
                                    Shortname = "wood",
                                    SkinId = 0,
                                    Amount = 100,
                                    price = 1.50f
                                }
                            },
                        },
                        ["Tool"] = new Item
                        {
                           Res = new List<res>
                           {
                               new res
                               { 
                                   Name = "Fire jackhammer",
                                   Shortname = "jackhammer",
                                   SkinId = 1512412983,
                                   Amount = 1,
                                   price = 25.80f
                               },
                               new res
                               {
                                    Name = "Jackhammer",
                                    Shortname = "jackhammer",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 5.80f
                               }
                           }
                        },
                        ["Food"] = new Item
                        {
                            Res = new List<res>
                            {
                                new res
                                {
                                    Name = "Cactus",
                                    Shortname = "cactusflesh",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.01f
                                },
                                new res
                                {
                                    Name = "Corn",
                                    Shortname = "corn",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.20f
                                },
                                new res
                                {
                                    Name = "Pumpkin",
                                    Shortname = "pumpkin",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.20f
                                },
                                new res
                                {
                                    Name = "Chicken",
                                    Shortname = "chicken.cooked",
                                    SkinId = 0,
                                    Amount = 100,
                                    price = 0.10f
                                },
                                new res
                                {
                                    Name = "Beans",
                                    Shortname = "can.beans",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.20f
                                },
                                new res
                                {
                                    Name = "Granolabar",
                                    Shortname = "granolabar",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.10f
                                },
                                new res
                                {
                                    Name = "Chocolate",
                                    Shortname = "chocolate",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.25f
                                },
                                new res
                                {
                                    Name = "Apple",
                                    Shortname = "apple",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.15f
                                },
                                new res
                                {
                                    Name = "Fish",
                                    Shortname = "fish.cooked",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.25f
                                },
                                new res
                                {
                                    Name = "Blueberries",
                                    Shortname = "blueberries",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.50f
                                },
                                new res
                                {
                                    Name = "Potato",
                                    Shortname = "potato",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.25f
                                },
                                new res
                                {
                                    Name = "Raspberries",
                                    Shortname = "black.raspberries",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.50f
                                },
                                new res
                                {
                                    Name = "Wolfmeat",
                                    Shortname = "wolfmeat.cooked",
                                    SkinId = 0,
                                    Amount = 1,
                                    price = 0.20f
                                },
                               

                            },
                        },



                    }

                }; 
            }
        }
        private static Configuration Settings;

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                Settings = Config.ReadObject<Configuration>();
            }
            catch
            {
                PrintWarning($"Error reading config, creating one new config!");
                LoadDefaultConfig();
            }

            SaveConfig();
        }

        protected override void LoadDefaultConfig() => Settings = Configuration.Generate();
        protected override void SaveConfig() => Config.WriteObject(Settings);
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху