EnumSection() 공개 메소드

Enumerates all lines for given section.
public EnumSection ( String sectionName ) : String[]
sectionName String Section to enum.
리턴 String[]
예제 #1
0
        private void LoadPermissions()
        {
            if (!File.Exists(Path.Combine(ModuleFolder, "PermissionsData.ini")))
            {
                UnityEngine.Debug.Log("[Permissions] Creating new PermissionsData file...");
                File.Create(Path.Combine(ModuleFolder, "PermissionsData.ini")).Dispose();
                permissionsData = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
                permissionsData.AddSetting("Groups", "Admin", "server.*, permission.*");
                permissionsData.AddSetting("Groups", "Moderator", "server.kick, server.mute, server.unmute, server.chat, server.build");
                permissionsData.AddSetting("Groups", "User", "server.chat, server.build");
                permissionsData.AddSetting("PlayerGroups", "50FA20E2708B2B2D97A0F092025EBCF3C1AF957D71154425431C00DC99F9A484", "Admin");
                permissionsData.Save();
            }
            permissionsData = new IniParser(Path.Combine(ModuleFolder, "PermissionsData.ini"));

            foreach (string group in permissionsData.EnumSection("Groups"))
            {
                List <string> _groupdata = new List <string>();
                foreach (string perm in permissionsData.GetSetting("Groups", group).ToLower().RemoveWhiteSpaces().Split(','))
                {
                    _groupdata.Add(perm);
                }
                if (!GroupData.ContainsKey(group))
                {
                    GroupData.Add(group, _groupdata);
                }
            }

            foreach (string hwid in permissionsData.EnumSection("PlayerGroups"))
            {
                PlayerGroup.Add(hwid, permissionsData.GetSetting("PlayerGroups", hwid));
            }
            UnityEngine.Debug.Log("[Permissions] Permissions loaded");
        }
예제 #2
0
 public void GiveLoadout(RoyaleUser pl)
 {
     string[] en = ini.EnumSection("Items");
     foreach (var item in en)
     {
         int hi     = Convert.ToInt32(ini.GetSetting("Items", item));
         int amount = hi;
         pl.Inventory.AddItem(item, amount);
     }
 }
예제 #3
0
        public string[] getListNameInConfigFile(string configFilePath)
        {
            IniParser newIni = new IniParser(configFilePath);

            string[] listSection = newIni.EnumSection("FormerFolder");
            int      count       = 0;
            string   url;

            foreach (string ls in listSection)
            {
                url   = newIni.GetSetting("FormerFolder", ls);
                count = count + Directory.GetFiles(url).Count();
            }
            string[] listNameInConfigFile = new string[count];
            int      countFile            = 0;

            foreach (string ls in listSection)
            {
                url = newIni.GetSetting("FormerFolder", ls);
                string[] allFIleInFolder = Directory.GetFiles(url);
                foreach (string fd in allFIleInFolder)
                {
                    listNameInConfigFile[countFile] = fd;
                    countFile++;
                }
            }

            return(listNameInConfigFile);
        }
예제 #4
0
        public void LoadConfig()
        {
            if (!File.Exists(Path.Combine(ModuleFolder, "Config.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "Config.ini")).Dispose();
                config = new IniParser(Path.Combine(ModuleFolder, "Config.ini"));
                config.Save();
                foreach (ItemDataBlock item in Bundling.LoadAll <ItemDataBlock>())
                {
                    if (itemList.ItemList.Contains(item.name))
                    {
                        config.AddSetting("Config", item.name + ":" + item.uniqueID.ToString(), item._maxUses.ToString());
                    }
                }
                config.Save();
            }
            config = new IniParser(Path.Combine(ModuleFolder, "Config.ini"));

            foreach (string itemid in config.EnumSection("Config"))
            {
                int id     = int.Parse(itemid.Split(':')[1]);
                int amount = int.Parse(config.GetSetting("Config", itemid));
                _stackSizes.Add(id, amount);
                DatablockDictionary.GetByUniqueID(id)._maxUses = amount;
            }
        }
예제 #5
0
 private void BoundIniToList()
 {
     foreach (string key in Boundini.EnumSection("BoundIDandHWID"))
     {
         _boundSteamIDs.Add(key, Boundini.GetSetting("BoundIDandHWID", key));
     }
 }
예제 #6
0
        private void Set()
        {
            IniParser ini = Plugin.GetIni("ItemDefs");

            foreach (ItemDefinition itemDef in ItemManager.GetItemDefinitions())
            {
                foreach (string key in ini.EnumSection(itemDef.displayName.english))
                {
                    if (ItemManager.FindItemDefinition(key) == null)
                    {
                        Util.Log("Failed to set " + itemDef.displayName.english + key);
                        continue;
                    }
                    //stacks
                    int sizes = int.Parse(ini.GetSetting("stackable", key));
                    ItemManager.FindItemDefinition(key).stackable = sizes;
                    //amountType
                    string type = ini.GetSetting("amountType", key);
                    ItemManager.FindItemDefinition(key).amountType.ToString() = type;
                    //max condition
                    float max = float.Parse(ini.GetSetting("condition.max", key));
                    ItemManager.FindItemDefinition(key)
                }
            }
        }
예제 #7
0
        void Command(Player pl, string cmd, string[] args)
        {
            if (cmd == "stp" && pl.Admin)
            {
                if (args.Length < 1)
                {
                    pl.MessageFrom(Name, "Try /stp ID");

                    string[] en = locs.EnumSection("Locs");
                    // Loops trough the ini folder and sends all id into a list
                    foreach (var n in en)
                    {
                        pl.MessageFrom(Name, n);
                    }
                }
                else
                {
                    if (locs.ContainsSetting("Locs", args[0]))
                    {
                        string  j   = locs.GetSetting("Locs", args[0]);
                        Vector3 loc = Util.GetUtil().ConvertStringToVector3(j); // makes vector3 of the location which is saved into string
                        pl.TeleportTo(loc);
                        pl.InventoryNotice(loc.ToString());
                    }
                }
            }
        }
예제 #8
0
 public string[] ValuesInSection(string section)
 {
     if (parser != null)
     {
         return(parser.EnumSection(section));
     }
     return(null);
 }
예제 #9
0
        public void LoadBanlist()
        {
            try
            {
                Logger.Log("[EnhancedBanSystem-Data] Loading bans from data file...");

                Stopwatch sw = new Stopwatch();
                sw.Start();

                int count       = 0;
                int globalcount = 0;
                foreach (var x in banlist.EnumSection("MinuteBans"))
                {
                    int bantime = int.Parse(banlist.GetSetting("MinuteBans", x)) * 60000;
                    StartMinuteTimer(x, bantime);
                    count++;
                    globalcount++;
                }
                Logger.Log(string.Format("[EnhancedBanSystem-Data] Succesfully loaded {0}  minute bans", count.ToString()));
                count = 0;
                foreach (var x in banlist.EnumSection("DayBans"))
                {
                    int bantime = int.Parse(banlist.GetSetting("DayBans", x)) * 86400000;
                    StartDayTimer(x, bantime);
                    count++;
                    globalcount++;
                }
                Logger.Log(string.Format("[EnhancedBanSystem-Data] Succesfully loaded {0} hour bans", count.ToString()));
                count = 0;
                foreach (var x in banlist.EnumSection("HourBans"))
                {
                    int bantime = int.Parse(banlist.GetSetting("HourBans", x)) * 3600000;
                    StartHourTimer(x, bantime);
                    count++;
                    globalcount++;
                }
                Logger.Log(string.Format("[EnhancedBanSystem-Data] Succesfully loaded {0} day bans", count.ToString()));
                count = 0;
                sw.Stop();
                Logger.Log(string.Format("[EnhancedBanSystem-StopWatch] We loaded {0} banned users in: {1} ", globalcount.ToString(), (Math.Round(sw.Elapsed.TotalSeconds))));
            }
            catch (Exception ex)
            {
                Logger.LogError("[EnhancedBanSystem-Error] Oops we caught a error while loading ban data. Report this error to the author. Error: " + ex.Message);
            }
        }
예제 #10
0
        public override void Initialize()
        {
            _instance = this;
            if (!File.Exists(ModuleFolder + "\\Data.ini"))
            {
                File.Create(ModuleFolder + "\\Data.ini").Dispose();
            }

            AuthLogPath = ModuleFolder + "\\Logs";
            if (!Directory.Exists(AuthLogPath))
            {
                Directory.CreateDirectory(AuthLogPath);
            }

            AuthLogger.LogWriterInit();
            ReloadConfig();
            DataStore.GetInstance().Flush("AuthMeLogin");

            Auths = new IniParser(ModuleFolder + "\\Data.ini");

            Thread t = new Thread(() =>
            {
                foreach (string id in Auths.EnumSection("Login"))
                {
                    string userpw = Auths.GetSetting("Login", id);
                    try
                    {
                        ulong uid    = ulong.Parse(id);
                        string[] spl = userpw.Split(new string[] { "---##---" }, StringSplitOptions.None);
                        Credentials.Add(uid, new Credential(spl[0].ToLower(), spl[1]));
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("[AuthMe] Invalid data at: " + id + " " + userpw + " Error: " + ex);
                    }
                }
            });

            t.IsBackground = true;
            t.Start();

            Hooks.OnCommand            += OnCommand;
            Hooks.OnPlayerHurt         += OnPlayerHurt;
            Hooks.OnPlayerDisconnected += OnPlayerDisconnected;
            Hooks.OnItemRemoved        += OnItemRemoved;
            Hooks.OnChat                     += OnChat;
            Hooks.OnEntityHurt               += OnEntityHurt;
            Hooks.OnPlayerConnected          += OnPlayerConnected;
            Hooks.OnPlayerSpawned            += OnPlayerSpawned;
            Hooks.OnEntityDeployedWithPlacer += OnEntityDeployedWithPlacer;
            Hooks.OnCrafting                 += OnCrafting;
            Hooks.OnResearch                 += OnResearch;
            Hooks.OnItemAdded                += OnItemAdded;
            Hooks.OnConsoleReceived          += OnConsoleReceived;
            Hooks.OnModulesLoaded            += OnModulesLoaded;
        }
예제 #11
0
 public override void Initialize()
 {
     ReloadConfig();
     Randomizer = new Random();
     foreach (var x in Settings.EnumSection("Positions"))
     {
         try
         {
             string  data     = Settings.GetSetting("Positions", x);
             int     loottype = int.Parse(data);
             Vector3 v        = Util.GetUtil().ConvertStringToVector3(x);
             LootPositions[v] = (LootType)loottype;
         }
         catch (Exception ex)
         {
             Logger.LogError("[LootSpawner] Failed to read position: " + ex);
         }
     }
     Hooks.OnServerLoaded  += OnServerLoaded;
     Hooks.OnModulesLoaded += OnModulesLoaded;
     Hooks.OnCommand       += OnCommand;
 }
예제 #12
0
 public void ReloadZonesJuli()
 {
     ZonesDictionary.Clear();
     ZonesFile = new IniParser(Path.Combine(ModuleFolder, "Zones.ini"));
     foreach (var section in ZonesFile.Sections)
     {
         foreach (var inikey in ZonesFile.EnumSection(section))
         {
             var inivalue = ZonesFile.GetSetting(section, inikey);
             ZonesDictionary.Add(inikey, inivalue);
         }
     }
     return;
 }
예제 #13
0
        private void LoadConfig()
        {
            if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini")))
            {
                Logger.LogDebug("[BuildingRestriction] Creating new settings file...");
                File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose();
                _settingsini = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
                _settingsini.AddSetting("Bypass Limits", "Admins", "True");
                _settingsini.AddSetting("Bypass Limits", "Moderators", "False");
                _settingsini.AddSetting("Refund", "Enabled", "True");
                _settingsini.AddSetting("Settings", "Maximum Wood Height", "5");
                _settingsini.AddSetting("Settings", "Maximum Metal Height", "5");
                _settingsini.AddSetting("Settings", "Maximum Wood Foundations", "16");
                _settingsini.AddSetting("Settings", "Maximum Metal Foundations", "16");
                _settingsini.Save();
            }
            _settingsini = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));

            try
            {
                _adminsCanBypass     = _settingsini.GetBoolSetting("Bypass Limits", "Admins");
                _moderatorsCanBypass = _settingsini.GetBoolSetting("Bypass Limits", "Moderators");
                _refund = _settingsini.GetBoolSetting("Refund", "Enabled");
            }
            catch (Exception e)
            {
                _internalError = true;
                Logger.LogError("[BuildingRestriction] Error converting string to bool");
                Logger.LogError(e.Message);
            }

            foreach (var value in _settingsini.EnumSection("Settings"))
            {
                try
                {
                    _settings.Add(value, float.Parse(_settingsini.GetSetting("Settings", value)));
                }
                catch (Exception e)
                {
                    _internalError = true;
                    Logger.LogError("[BuildingRestriction] Error converting " + value + " setting to a number");
                    Logger.LogError(e.Message);
                }
            }
            if (!_internalError)
            {
                Logger.LogDebug("[BuildingRestriction] Loaded settings file.");
            }
        }
예제 #14
0
        public string ReturnACNByName2(string name)
        {
            IniParser ini = GlobalBanList;
            string    l   = name.ToLower();
            var       ids = ini.EnumSection("NameIds");

            foreach (string id in ids)
            {
                if (l.Equals(id.ToLower()))
                {
                    return(id);
                }
            }
            return(null);
        }
예제 #15
0
        public string ReturnACNByName(string name)
        {
            IniParser ini = GlobalBanList;
            string    l   = name.ToLower();
            var       ips = ini.EnumSection("NameIps");

            foreach (string ip in ips)
            {
                if (l.Equals(ip.ToLower()))
                {
                    return(ip);
                }
            }
            return(null);
        }
예제 #16
0
        public void Init(IApi api, string dllpath)
        {
            _api     = api;
            _dllpath = dllpath;
            try
            {
                _ini = new IniParser(_configPath);
            }
            catch (Exception ex)
            {
                throw new SimpleMessagesException(String.Format("Error loading config: {0}", ex.Message));
            }

            _enabled = _ini.GetBoolSetting("SimpleMessages", "Enabled");
            if (!_enabled)
            {
                throw new SimpleMessagesException(String.Format("{0} has been disabled", Name));
            }

            Int32 _interval;

            try
            {
                _interval = Convert.ToInt32(_ini.GetSetting("SimpleMessages", "Interval", "60"));
            }
            catch
            {
                _interval = 60;
            }

            _prefix = _ini.GetSetting("SimpleMessages", "Prefix");

            _repeat = _ini.GetBoolSetting("SimpleMessages", "Repeat");
            var _random = _ini.GetBoolSetting("SimpleMessages", "Random");

            _messages = _ini.EnumSection("Messages");
            if (_random)
            {
                var rnd = new Random();
                _messages = _messages.OrderBy(x => rnd.Next()).ToArray();
            }
            _timer = new Timer {
                Interval = (_interval * 1000)
            };
            _timer.Elapsed += _timer_Elapsed;
            _timer.Enabled  = true;
        }
예제 #17
0
        public void LoadConfig()
        {
            try
            {
                Config = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
                Range  = new IniParser(Path.Combine(ModuleFolder, "Range.ini"));
                Bodies = new IniParser(Path.Combine(ModuleFolder, "Bodies.ini"));

                foreach (string key in Bodies.EnumSection("bodyparts"))
                {
                    string part = Bodies.GetSetting("bodyparts", key);
                    BodiesData[key] = part;
                }

                foreach (string key in Range.EnumSection("range"))
                {
                    string part = Range.GetSetting("range", key);
                    RangeData[key] = int.Parse(part);
                }

                DeathMSGName       = Config.GetSetting("Settings", "DeathMSGName");
                Bullet             = Config.GetSetting("Settings", "msg");
                KillLog            = int.Parse(Config.GetSetting("Settings", "killog"));
                ean                = int.Parse(Config.GetSetting("Settings", "enableanimalmsg"));
                animal             = Config.GetSetting("Settings", "animalkill");
                esn                = int.Parse(Config.GetSetting("Settings", "enablesuicidemsg"));
                suicide            = Config.GetSetting("Settings", "suicide");
                autoban            = int.Parse(Config.GetSetting("Settings", "autoban"));
                essn               = int.Parse(Config.GetSetting("Settings", "enablesleepermsg"));
                dkl                = int.Parse(Config.GetSetting("Settings", "displaykilllog"));
                sleeper            = Config.GetSetting("Settings", "SleeperKill");
                huntingbow         = Config.GetSetting("Settings", "huntingbow");
                banmsg             = Config.GetSetting("Settings", "banmsg");
                tpamsg             = Config.GetSetting("Settings", "TpaMsg");
                spike              = Config.GetSetting("Settings", "spike");
                explosion          = Config.GetSetting("Settings", "explosionmsg");
                bleeding           = Config.GetSetting("Settings", "bmsg");
                tpbackmsg          = Config.GetSetting("Settings", "tpbackmsg");
                EnableConsoleKills = int.Parse(Config.GetSetting("Settings", "EnableConsoleKills"));
            }
            catch (Exception ex)
            {
                Logger.LogError("[DeathMSG] Failed to read config! " + ex);
            }
        }
예제 #18
0
        private void InitializeSettings()
        {
            // load general
            HideLinesLower = settingsParser.GetSetting <int>("General", "hideLinesLower");
            MajorLineEvery = settingsParser.GetSetting <int>("General", "majorLineEvery");

            // load colors
            string[] colorArray = settingsParser.EnumSection("Colors");

            foreach (string colorKey in colorArray)
            {
                string   rgb       = settingsParser.GetSetting <string>("Colors", colorKey);
                string[] rgbValues = rgb.Split(new char[] { ',' }, 3);
                int      r         = Int32.Parse(rgbValues[0]);
                int      g         = Int32.Parse(rgbValues[1]);
                int      b         = Int32.Parse(rgbValues[2]);

                Colors.Add(colorKey, Color.FromArgb(255, r, g, b));
            }
        }
예제 #19
0
 public void FromIni(IniParser ini)
 {
     foreach (string section in ini.Sections)
     {
         foreach (string key in ini.EnumSection(section))
         {
             string setting = ini.GetSetting(section, key);
             float  valuef;
             int    valuei;
             if (float.TryParse(setting, out valuef))
             {
                 Add(section, key, valuef);
             }
             else if (int.TryParse(setting, out valuei))
             {
                 Add(section, key, valuei);
             }
             else if (ini.GetBoolSetting(section, key))
             {
                 Add(section, key, true);
             }
             else if (setting.Equals("False", StringComparison.InvariantCultureIgnoreCase))
             {
                 Add(section, key, false);
             }
             else if (setting == "__NullReference__")
             {
                 Add(section, key, null);
             }
             else
             {
                 Add(section, key, ini.GetSetting(section, key));
             }
         }
     }
 }
예제 #20
0
        public async Task <ICollection <IDetectionResultItem> > Scan()
        {
            //await Task.FromResult(0);

            var result = new Collection <IDetectionResultItem>();

            //"control.ini"
            //Should only be valid for Windows 95, 98, ME, 2000 and XP.
            //It is used to customize and change how the Control Panel operates and what is seen in the Control Panel.

            var path     = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
            var fileName = Path.Combine(path, "control.ini");

            if (File.Exists(fileName))
            {
                using (var iniParser = new IniParser(fileName))
                {
                    var keys = iniParser.EnumSection(INI_SECTION);

                    if (keys.Any())
                    {
                        foreach (var key in keys)
                        {
                            //Anything hidden (that isn't "yes") should be flagged...
                            var value = iniParser.GetSetting(INI_SECTION, key);
                            if (!string.IsNullOrEmpty(value) && !value.Equals("yes", StringComparison.InvariantCultureIgnoreCase))
                            {
                                result.Add(new ControlIniResult(fileName, key, value));
                            }
                        }
                    }
                }
            }

            return(result);
        }
예제 #21
0
        public void On_PluginInit()
        {
            Author  = "Pluton Team";
            Version = "0.1.4 (beta)";
            About   = "All non-core Pluton commands and functions all rolled into a plugin.";

            //Create Config if doesnt exist else load it
            if (Plugin.IniExists("PlutonEssentials"))
            {
                Debug.Log("PlutonEssentials config loaded!");
            }
            else
            {
                IniParser ConfigFile = Plugin.CreateIni("PlutonEssentials");
                Debug.Log("PlutonEssentials config created!");
                Debug.Log("The config will be filled with the default values.");
                ConfigFile.AddSetting("Config", "craftTimescale", "1.0");
                ConfigFile.AddSetting("Config", "resourceGatherMultiplier", "1.0");

                ConfigFile.AddSetting("Config", "permanentTime", "-1.0");
                ConfigFile.AddSetting("Config", "timescale", "30.0");

                ConfigFile.AddSetting("Config", "broadcastInterval", "600000");
                ConfigFile.AddSetting("Config", "Broadcast", "true");
                ConfigFile.AddSetting("Config", "Help", "true");
                ConfigFile.AddSetting("Config", "Welcome", "true");

                ConfigFile.AddSetting("Config", "StructureRecorder", "false");

                ConfigFile.AddSetting("Config", "Server_Image", "");
                ConfigFile.AddSetting("Config", "Server_Description", "This server is running Pluton Framework and is awesome!");
                ConfigFile.AddSetting("Config", "Server_Url", "");

                ConfigFile.AddSetting("Config", "NoChatSpam", "true");
                ConfigFile.AddSetting("Config", "NoVacBans", "false");
                ConfigFile.AddSetting("Config", "PvE", "true");

                ConfigFile.AddSetting("Commands", "ShowMyStats", "mystats");
                ConfigFile.AddSetting("Commands", "ShowStatsOther", "statsof");

                ConfigFile.AddSetting("Commands", "ShowLocation", "whereami");
                ConfigFile.AddSetting("Commands", "ShowOnlinePlayers", "players");

                ConfigFile.AddSetting("Commands", "Help", "help");
                ConfigFile.AddSetting("Commands", "Commands", "commands");

                ConfigFile.AddSetting("Commands", "Description", "whatis");
                ConfigFile.AddSetting("Commands", "Usage", "howto");
                ConfigFile.AddSetting("Commands", "About", "about");

                ConfigFile.AddSetting("Commands", "StartStructureRecording", "srstart");
                ConfigFile.AddSetting("Commands", "StopStructureRecording", "srstop");
                ConfigFile.AddSetting("Commands", "BuildStructure", "srbuild");

                ConfigFile.AddSetting("HelpMessage", "1", "");

                ConfigFile.AddSetting("BroadcastMessage", "1", "This server is powered by Pluton, the new servermod!");
                ConfigFile.AddSetting("BroadcastMessage", "2", "For more information visit our github repo: github.com/Notulp/Pluton or our forum: pluton-team.org");

                ConfigFile.AddSetting("WelcomeMessage", "1", "This server is powered by Pluton!");
                ConfigFile.AddSetting("WelcomeMessage", "2", "Visit pluton-team.org for more information or to report bugs!");

                ConfigFile.AddSetting("NoChatSpam", "NoChatSpamCooldown", "2000");
                ConfigFile.AddSetting("NoChatSpam", "NoChatSpamMaxMessages", "4");
                ConfigFile.AddSetting("NoChatSpam", "NoChatSpamIgnoreMod", "false");

                ConfigFile.AddSetting("NoVacBans", "MaxAllowed", "2");

                ConfigFile.Save();
            }

            IniParser GetConfig = Plugin.GetIni("PlutonEssentials");

            //Set Callbacks for commands
            Commands.Register(GetConfig.GetSetting("Commands", "ShowMyStats")).setCallback(Mystats);
            Commands.Register(GetConfig.GetSetting("Commands", "ShowStatsOther")).setCallback(Statsof);
            Commands.Register(GetConfig.GetSetting("Commands", "ShowLocation")).setCallback(Whereami);
            Commands.Register(GetConfig.GetSetting("Commands", "ShowOnlinePlayers")).setCallback(Players);
            Commands.Register(GetConfig.GetSetting("Commands", "Help")).setCallback(Help);
            Commands.Register(GetConfig.GetSetting("Commands", "Commands")).setCallback(CommandS);
            Commands.Register(GetConfig.GetSetting("Commands", "Description")).setCallback(Whatis);
            Commands.Register(GetConfig.GetSetting("Commands", "Usage")).setCallback(Howto);
            Commands.Register(GetConfig.GetSetting("Commands", "About")).setCallback(AboutCMD);

            //Structure Recorder
            StructureRecorder = bool.Parse(GetConfig["Config"]["StructureRecorder"]) == false;
            if (StructureRecorder)
            {
                Commands.Register(GetConfig.GetSetting("Commands", "StartStructureRecording")).setCallback(Srstart);
                Commands.Register(GetConfig.GetSetting("Commands", "StopStructureRecording")).setCallback(Srstop);
                Commands.Register(GetConfig.GetSetting("Commands", "BuildStructure")).setCallback(Srbuild);
            }

            DataStore.Flush("StructureRecorder");
            DataStore.Flush("StructureRecorderEveryone");

            if (Server.Loaded)
            {
                Structures = new Dictionary <string, Structure>();
                LoadStructures();
            }

            //Broadcast settings
            if (GetConfig.GetBoolSetting("Config", "Broadcast"))
            {
                int broadcast_time = int.Parse(GetConfig.GetSetting("Config", "broadcastInterval", "600000"));
                Plugin.CreateTimer("Advertise", broadcast_time);
                foreach (string key in GetConfig.EnumSection("BroadcastMessage"))
                {
                    if (key == null)
                    {
                        return;
                    }
                    BroadcastMessage.Add(GetConfig.GetSetting("BroadcastMessage", key));
                }
            }

            //Help Message
            if (GetConfig.GetBoolSetting("Config", "Help", true))
            {
                foreach (string key in GetConfig.EnumSection("HelpMessage"))
                {
                    if (key == null)
                    {
                        return;
                    }
                    HelpMessage.Add(GetConfig.GetSetting("HelpMessage", key));
                }
            }

            //Welcome Message
            Welcome = GetConfig.GetBoolSetting("Config", "Welcome", true);
            if (Welcome)
            {
                foreach (string key in GetConfig.EnumSection("WelcomeMessage"))
                {
                    if (key == null)
                    {
                        return;
                    }
                    WelcomeMessage.Add(GetConfig.GetSetting("WelcomeMessage", key));
                }
            }

            //NoChatSpam Global variable
            NoChatSpam            = GetConfig.GetBoolSetting("Config", "NoChatSpam", true);
            NoChatSpamCooldown    = int.Parse(GetConfig.GetSetting("NoChatSpam", "NoChatSpamCooldown", "2000"));
            NoChatSpamMaxMessages = int.Parse(GetConfig.GetSetting("NoChatSpam", "NoChatSpamMaxMessages", "4"));
            NoChatSpamIgnoreMod   = GetConfig.GetBoolSetting("NoChatSpam", "NoChatSpamIgnoreMod");

            //Set New Server Settings
            ConVar.Server.pve         = GetConfig.GetBoolSetting("Config", "PvE", true);
            ConVar.Server.description = GetConfig.GetSetting("Config", "Server_Description");
            ConVar.Server.headerimage = GetConfig.GetSetting("Config", "Server_Image");
            ConVar.Server.url         = GetConfig.GetSetting("Config", "Server_Url");

            //Check for updates
            var getjson = JSON.Object.Parse(Web.GET(latest)).GetString("plutonVersion");
            var getver  = Pluton.Bootstrap.Version;

            if (getjson != getver)
            {
                UpdateAvailable = true;
            }

            //NoVacBans
            NoVacBans  = GetConfig.GetBoolSetting("Config", "NoVacBans", false);
            MaxVacBans = int.Parse(GetConfig.GetSetting("NoVacBans", "MaxVacBans", "2"));
        }
예제 #22
0
        public override void Initialize()
        {
            _inst = this;
            if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose();
                Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
                Settings.AddSetting("Settings", "UseDayLimit", "True");
                Settings.AddSetting("Settings", "MaxDays", "14");
                Settings.AddSetting("Settings", "UseDecay", "False");
                Settings.AddSetting("Settings", "DecayTimer", "30");
                Settings.AddSetting("Settings", "WipeCheckTimer", "30");
                Settings.AddSetting("Settings", "Broadcast", "True");
                Settings.AddSetting("Settings", "UserDataPath", "\\rust_server_Data\\userdata\\");
                Settings.Save();
            }
            else
            {
                Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
            }
            if (!File.Exists(Path.Combine(ModuleFolder, "WhiteList.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "WhiteList.ini")).Dispose();
                WhiteList = new IniParser(Path.Combine(ModuleFolder, "WhiteList.ini"));
                WhiteList.AddSetting("WhiteList", "1234212312312", "1");
                WhiteList.Save();
            }
            if (!File.Exists(Path.Combine(ModuleFolder, "Players.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "Players.ini")).Dispose();
                Check = true;
            }
            else
            {
                IniParser players = new IniParser(Path.Combine(ModuleFolder, "Players.ini"));
                string[]  enumm   = players.EnumSection("Objects");
                if (enumm.Length > 0)
                {
                    foreach (var x in enumm)
                    {
                        try
                        {
                            ulong  id   = ulong.Parse(x);
                            string date = players.GetSetting("Objects", x);
                            // dd/MM/yyyy
                            string[] spl = date.Split('/');
                            CollectedIDs[id] = new DateTime(int.Parse(spl[2]), int.Parse(spl[1]), int.Parse(spl[0]));
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("[Wiper] Failed to parse datetime for " + x + " Error: " + ex);
                        }
                    }
                }
            }
            ReloadConfig();

            LoadDecayList();
            Fougerite.Hooks.OnCommand         += OnCommand;
            Fougerite.Hooks.OnPlayerConnected += OnPlayerConnected;
            Fougerite.Hooks.OnServerSaved     += OnServerSaved;
            Fougerite.Hooks.OnServerLoaded    += OnServerLoaded;
            GameO = new GameObject();
            GameO.AddComponent <WiperHandler>();
            UnityEngine.Object.DontDestroyOnLoad(GameO);
        }
예제 #23
0
        private bool ReloadConfig()
        {
            if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose();
                Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
                Settings.AddSetting("Settings", "UseDayLimit", "True");
                Settings.AddSetting("Settings", "MaxDays", "14");
                Settings.AddSetting("Settings", "UseDecay", "False");
                Settings.AddSetting("Settings", "DecayTimer", "30");
                Settings.AddSetting("Settings", "WipeCheckTimer", "30");
                Settings.AddSetting("Settings", "Broadcast", "True");
                Settings.AddSetting("Settings", "UserDataPath", "\\rust_server_Data\\userdata\\");
                Settings.Save();
            }
            if (!File.Exists(Path.Combine(ModuleFolder, "WhiteList.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "WhiteList.ini")).Dispose();
                WhiteList = new IniParser(Path.Combine(ModuleFolder, "WhiteList.ini"));
                WhiteList.AddSetting("WhiteList", "1234212312312", "1");
                WhiteList.Save();
            }
            if (!File.Exists(Path.Combine(ModuleFolder, "Players.ini")))
            {
                File.Create(Path.Combine(ModuleFolder, "Players.ini")).Dispose();
                CollectedIDs.Clear();
                foreach (var x in Server.GetServer().Players)
                {
                    CollectedIDs[x.UID] = DateTime.Today;
                }
            }


            Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini"));
            try
            {
                MaxDays        = int.Parse(Settings.GetSetting("Settings", "MaxDays"));
                DecayTimer     = int.Parse(Settings.GetSetting("Settings", "DecayTimer"));
                WipeCheckTimer = int.Parse(Settings.GetSetting("Settings", "WipeCheckTimer"));
                UseDayLimit    = Settings.GetBoolSetting("Settings", "UseDayLimit");
                UseDecay       = Settings.GetBoolSetting("Settings", "UseDecay");
                Broadcast      = Settings.GetBoolSetting("Settings", "Broadcast");
                UserDataPath   = @Settings.GetSetting("Settings", "UserDataPath");
            }
            catch (Exception ex)
            {
                Fougerite.Logger.LogError("[Wiper] Failed to read config, possible wrong value somewhere! Ex: " + ex);
                return(false);
            }
            LoadDecayList();


            WhiteList = new IniParser(Path.Combine(ModuleFolder, "WhiteList.ini"));
            string[] enumm = WhiteList.EnumSection("WhiteList");
            if (enumm.Length > 0)
            {
                foreach (var x in enumm)
                {
                    try
                    {
                        ulong id = ulong.Parse(x);
                        WList.Add(id);
                    }
                    catch
                    {
                        Logger.LogError("[Wiper] Failed to parse whitelist for " + x);
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #24
0
        public void HandleCommand(Player pl, string cmd, string[] args)
        {
            switch (cmd)
            {
            case "rank":
                switch (args.Length)
                {
                case 0:
                    pl.MessageFrom(this.n, "[COLOR#00EB7E]Rank++ 2.2 [COLOR#FFFFFF]by Snake");
                    pl.MessageFrom(this.n, "----------------------------");
                    pl.MessageFrom(this.n, "Use '/rank' to see this info");
                    pl.MessageFrom(this.n, "Use '/stats' to check your own stats");
                    pl.MessageFrom(this.n, "Use '/stats playername' to check a player's stats");
                    pl.MessageFrom(this.n, "Use '/top category' to see the top 5 most valuable players");
                    pl.MessageFrom(this.n, "Valid Top Categories : kills, deaths, headshots, time, pve, gathering");
                    if (!pl.get_Admin())
                    {
                        return;
                    }
                    pl.MessageFrom(this.n, "[COLOR#FB9A50]---------- Admin Only Commands ----------");
                    pl.MessageFrom(this.n, "Use '/rank resetall' to reset all stats");
                    pl.MessageFrom(this.n, "Use '/rank backup' to back up all the stats");
                    pl.MessageFrom(this.n, "Use '/rank restore' to back up all the stats");
                    return;

                case 1:
                    if (!pl.get_Admin())
                    {
                        return;
                    }
                    switch (args[0])
                    {
                    case "resetall":
                        string str1 = this.backupStats();
                        this.deleteStats();
                        pl.MessageFrom(this.n, "[COLOR#00EB7E]Rank++ Stats deleted except Time");
                        pl.MessageFrom(this.n, "[COLOR#00EB7E]Emergency Rank++ Back-up saved as : [COLOR#FFA500]" + str1);
                        break;

                    case "backup":
                        string str2 = this.backupStats();
                        pl.MessageFrom(this.n, "[COLOR#00EB7E]Rank++ Back-up saved as : [COLOR#FFA500]" + str2);
                        break;
                    }
                    return;

                case 2:
                    switch (args[0])
                    {
                    case "restore":
                        if (pl.get_Admin())
                        {
                            string path = this.get_ModuleFolder() + "\\" + args[1];
                            if (!path.EndsWith(".ini"))
                            {
                                path += ".ini";
                            }
                            if (File.Exists(path))
                            {
                                IniParser iniParser = new IniParser(path);
                                foreach (string section in iniParser.get_Sections())
                                {
                                    foreach (string str3 in iniParser.EnumSection(section))
                                    {
                                        this.ds.Add("Rank++" + section, (object)str3, (object)iniParser.GetSetting(section, str3));
                                    }
                                }
                                pl.MessageFrom(this.n, "[COLOR#00EB7E]Rank++ Stats restored from [COLOR#FFA500]" + path);
                                return;
                            }
                            pl.MessageFrom(this.n, "[COLOR#00EB7E]The file [COLOR#FFA500]" + path + "[COLOR#00EB7E] was not found");
                            return;
                        }
                        pl.MessageFrom(this.n, "[COLOR#00EB7E]Only admins can acces this command");
                        return;

                    case null:
                        return;

                    default:
                        return;
                    }

                default:
                    return;
                }

            case "stats":
                switch (args.Length)
                {
                case 0:
                    string steamId = pl.get_SteamID();
                    double num1    = double.Parse(this.ds.Get("Rank++Kills", (object)steamId).ToString());
                    double num2    = double.Parse(this.ds.Get("Rank++Deaths", (object)steamId).ToString());
                    double num3    = double.Parse(this.ds.Get("Rank++Headshots", (object)steamId).ToString());
                    double ms1     = double.Parse(this.ds.Get("Rank++Time", (object)steamId).ToString());
                    double num4    = double.Parse(this.ds.Get("Rank++PVE", (object)steamId).ToString());
                    double num5    = double.Parse(this.ds.Get("Rank++Gathering", (object)steamId).ToString());
                    double num6    = Math.Round(num3 / num1 * 100.0, 1);
                    double num7    = num2 != 0.0 ? Math.Round(num1 / num2, 2) : num1;
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]" + pl.get_Name() + " Rank++ Stats [COLOR#FFFFFF]-----");
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]K : [COLOR#00EB7E]" + (object)num1 + "[COLOR#FFFFFF] | D : [COLOR#00EB7E]" + (object)num2 + "[COLOR#FFFFFF] | Headshots : [COLOR#00EB7E]" + (object)num3 + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)num6 + "[COLOR#FFFFFF]%) | K/D Ratio : [COLOR#00EB7E]" + (object)num7);
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]Time Played : [COLOR#00EB7E]" + this.msToTime(ms1) + "[COLOR#FFFFFF] | PVE Kills : [COLOR#00EB7E]" + (object)num4 + "[COLOR#FFFFFF] | Resources Gathered : [COLOR#00EB7E]" + (object)num5);
                    return;

                case 1:
                    bool flag = false;
                    foreach (object key in this.ds.Keys("LastName"))
                    {
                        string str3 = this.ds.Get("LastName", key).ToString();
                        if (str3.Equals(args[0], StringComparison.OrdinalIgnoreCase))
                        {
                            flag = true;
                            double num8  = double.Parse(this.ds.Get("Rank++Kills", key).ToString());
                            double num9  = double.Parse(this.ds.Get("Rank++Deaths", key).ToString());
                            double num10 = double.Parse(this.ds.Get("Rank++Headshots", key).ToString());
                            double ms2   = double.Parse(this.ds.Get("Rank++Time", key).ToString());
                            double num11 = double.Parse(this.ds.Get("Rank++PVE", key).ToString());
                            double num12 = double.Parse(this.ds.Get("Rank++Gathering", key).ToString());
                            double num13 = Math.Round(num10 / num8 * 100.0, 1);
                            double num14 = num9 != 0.0 ? Math.Round(num8 / num9, 2) : num8;
                            pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]" + str3 + " Rank++ Stats [COLOR#FFFFFF]-----");
                            pl.MessageFrom(this.n, "[COLOR#FFFFFF]K : [COLOR#00EB7E]" + (object)num8 + "[COLOR#FFFFFF] | D : [COLOR#00EB7E]" + (object)num9 + "[COLOR#FFFFFF] | Headshots : [COLOR#00EB7E]" + (object)num10 + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)num13 + "[COLOR#FFFFFF]%) | K/D Ratio : [COLOR#00EB7E]" + (object)num14);
                            pl.MessageFrom(this.n, "[COLOR#FFFFFF]Time Played : [COLOR#00EB7E]" + this.msToTime(ms2) + "[COLOR#FFFFFF] | PVE Kills : [COLOR#00EB7E]" + (object)num11 + "[COLOR#FFFFFF] | Resources Gathered : [COLOR#00EB7E]" + (object)num12);
                        }
                    }
                    if (flag)
                    {
                        return;
                    }
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]The player [COLOR#00EB7E]" + args[1] + "[COLOR#FFFFFF] was not found");
                    return;

                default:
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]The player [COLOR#00EB7E]" + args[1] + "[COLOR#FFFFFF] was not found");
                    return;
                }

            case "top":
                if (args.Length == 1)
                {
                    switch (args[0])
                    {
                    case "kills":
                        Dictionary <int, RankModule.TopPlayer> dictionary1 = this.calcTop("Kills");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most Kills [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary1[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary1[0].count + "[COLOR#FFFFFF] kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary1[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary1[1].count + "[COLOR#FFFFFF] kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary1[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary1[2].count + "[COLOR#FFFFFF] kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary1[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary1[3].count + "[COLOR#FFFFFF] kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary1[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary1[4].count + "[COLOR#FFFFFF] kills)");
                        return;

                    case "deaths":
                        Dictionary <int, RankModule.TopPlayer> dictionary2 = this.calcTop("Deaths");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most Deaths [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary2[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary2[0].count + "[COLOR#FFFFFF] deaths)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary2[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary2[1].count + "[COLOR#FFFFFF] deaths)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary2[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary2[2].count + "[COLOR#FFFFFF] deaths)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary2[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary2[3].count + "[COLOR#FFFFFF] deaths)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary2[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary2[4].count + "[COLOR#FFFFFF] deaths)");
                        return;

                    case "headshots":
                        Dictionary <int, RankModule.TopPlayer> dictionary3 = this.calcTop("Headshots");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most Headshots [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary3[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary3[0].count + "[COLOR#FFFFFF] headshots)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary3[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary3[1].count + "[COLOR#FFFFFF] headshots)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary3[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary3[2].count + "[COLOR#FFFFFF] headshots)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary3[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary3[3].count + "[COLOR#FFFFFF] headshots)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary3[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary3[4].count + "[COLOR#FFFFFF] headshots)");
                        return;

                    case "time":
                        Dictionary <int, RankModule.TopPlayer> dictionary4 = this.calcTop("Time");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most Time Played [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary4[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + this.msToTime((double)dictionary4[0].count) + "[COLOR#FFFFFF])");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary4[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + this.msToTime((double)dictionary4[1].count) + "[COLOR#FFFFFF])");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary4[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + this.msToTime((double)dictionary4[2].count) + "[COLOR#FFFFFF])");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary4[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + this.msToTime((double)dictionary4[3].count) + "[COLOR#FFFFFF])");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary4[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + this.msToTime((double)dictionary4[4].count) + "[COLOR#FFFFFF])");
                        return;

                    case "pve":
                        Dictionary <int, RankModule.TopPlayer> dictionary5 = this.calcTop("PVE");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most PVE Kills [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary5[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary5[0].count + "[COLOR#FFFFFF] PVE Kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary5[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary5[1].count + "[COLOR#FFFFFF] PVE Kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary5[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary5[2].count + "[COLOR#FFFFFF] PVE Kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary5[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary5[3].count + "[COLOR#FFFFFF] PVE Kills)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary5[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary5[4].count + "[COLOR#FFFFFF] PVE Kills)");
                        return;

                    case "gathering":
                        Dictionary <int, RankModule.TopPlayer> dictionary6 = this.calcTop("Gathering");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]------ [COLOR#00EB7E]TOP 5 Most Resources Gathered [COLOR#FFFFFF]------");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]1. [COLOR#00EB7E]" + dictionary6[0].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary6[0].count + "[COLOR#FFFFFF] resources)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]2. [COLOR#00EB7E]" + dictionary6[1].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary6[1].count + "[COLOR#FFFFFF] resources)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]3. [COLOR#00EB7E]" + dictionary6[2].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary6[2].count + "[COLOR#FFFFFF] resources)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]4. [COLOR#00EB7E]" + dictionary6[3].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary6[3].count + "[COLOR#FFFFFF] resources)");
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]5. [COLOR#00EB7E]" + dictionary6[4].name + "[COLOR#FFFFFF] ([COLOR#00EB7E]" + (object)dictionary6[4].count + "[COLOR#FFFFFF] resources)");
                        return;

                    default:
                        pl.MessageFrom(this.n, "[COLOR#FFFFFF]Valid TOPs : [COLOR#00EB7E]kills , deaths , headshots , time , pve , gathering");
                        return;
                    }
                }
                else
                {
                    pl.MessageFrom(this.n, "[COLOR#FFFFFF]Valid TOPs : [COLOR#00EB7E]kills , deaths , headshots , time , pve , gathering");
                    break;
                }
            }
        }
예제 #25
0
파일: Settings.cs 프로젝트: ripkens/MBCon
        public Settings(IniParser ini)
        {
            string beconfig;

            if (!IPAddress.TryParse(ini.GetSetting("General", "IP").Trim(), out _address))
            {
                throw new SettingsException("Port is not set.");
            }

            try
            {
                _port = Convert.ToInt32(ini.GetSetting("General", "Port").Trim());
                if (_port > 65535)
                {
                    throw new SettingsException("Port is too high.");
                }
            }
            catch (Exception ex)
            {
                throw new SettingsException(String.Format("Port is not set or invalid: {0}", ex.Message));
            }

            try
            {
                _bepath = ini.GetSetting("General", "BEPath").Trim();
                if (!Directory.Exists(_bepath))
                {
                    throw new SettingsException("BEPath does not exist.");
                }
                beconfig = Path.Combine(_bepath, "BEServer.cfg");
                if (!File.Exists(beconfig))
                {
                    var files = Directory.GetFiles(_bepath, "*.cfg")
                                .Where(path => path.Contains("BEServer_active_"))
                                .ToList();
                    if (files.Count == 0)
                    {
                        throw new SettingsException("Cound not find BEServer.cfg.");
                    }
                    beconfig = Path.Combine(_bepath, files[0]);
                }
            }
            catch (Exception ex)
            {
                throw new SettingsException(String.Format("BEPath is invalid: {0}", ex.Message));
            }

            try
            {
                var    file = new StreamReader(beconfig);
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    if (line.StartsWith("RConPassword "))
                    {
                        _rconpass = line.Replace("RConPassword ", "");
                        break;
                    }
                }
                if (_rconpass == null)
                {
                    throw new SettingsException("Could not find rcon password in BEServer.cfg.");
                }
            }
            catch (Exception ex)
            {
                throw new SettingsException(String.Format("Error reading BEServer.cfg: {0}", ex.Message));
            }

            try
            {
                _pluginpath = ini.GetSetting("General", "PluginPath").Trim();
                if (_pluginpath == "")
                {
                    _pluginpath = Path.Combine(Core.BasePath, "plugins");
                }
                if (!Directory.Exists(_pluginpath))
                {
                    Directory.CreateDirectory(_pluginpath);
                }
            }
            catch (Exception ex)
            {
                throw new SettingsException(String.Format("Error reading plugin directory: {0}", ex.Message));
            }

            try
            {
                _admins = new Dictionary <string, string>();
                var adminsList = ini.EnumSection("Admins");
                foreach (var guid in adminsList)
                {
                    var name = ini.GetSetting("Admins", guid);
                    _admins.Add(guid.Trim(), name.Trim());
                }
            }
            catch (Exception ex)
            {
                throw new SettingsException(String.Format("Error reading settings: {0}", ex.Message));
            }
        }
예제 #26
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            IniParser parser = new IniParser(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Config.ini");

            var     instruments = new List <Tuple <ClodDataLink.GameCommunications.ParameterTypes, String, int> >();
            var     debugString = parser.GetSetting("Debug", "debug");
            Boolean debug       = false;

            if (debugString != null)
            {
                debug = Boolean.Parse(debugString.Trim());
            }

            foreach (String instrumentName in parser.EnumSection("Devices"))
            {
                String[] instrumentValues = parser.GetSetting("Devices", instrumentName.Trim()).Split(new char[] { ',' });
                var      instrument       = (ClodDataLink.GameCommunications.ParameterTypes)Enum.Parse(typeof(ClodDataLink.GameCommunications.ParameterTypes), instrumentValues[0].Trim(), true);
                var      position         = Int32.Parse(instrumentValues[1].Trim());
                instruments.Add(new Tuple <ClodDataLink.GameCommunications.ParameterTypes, String, int>(instrument, instrumentName.Trim(), position));
                addText("Adding=" + instrument.ToString() + "," + instrumentName.Trim() + "," + position.ToString());
            }

            String ip    = parser.GetSetting("Network", "IP").Trim();
            Int32  port  = Int32.Parse(parser.GetSetting("Network", "Port").Trim());
            Int32  sleep = Int32.Parse(parser.GetSetting("Network", "Delay").Trim());

            addText("Sending data to: " + ip + " on port " + port.ToString());
            addText("Sleep set to: " + sleep.ToString());

            Socket     sock       = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPAddress  serverAddr = IPAddress.Parse(ip);
            IPEndPoint endPoint   = new IPEndPoint(serverAddr, port);

            GameCommunications gc = new GameCommunications();

            IFormatProvider noCommas = new System.Globalization.CultureInfo("en-US");


            Boolean firstLine = true;

            while (true)
            {
                Boolean       firstComma = true;
                StringBuilder data       = new StringBuilder("{");
                for (int i = 0; i < instruments.Count; i++)
                {
                    var    t     = instruments[i];
                    double value = gc.GetParameter(t.Item1, t.Item3);
                    //when reading wrong values they get very large, 10000000 should be enough for everybody
                    if (debug || (-10000000 < value && value < 10000000))
                    {
                        if (!firstComma)
                        {
                            data.Append(", ");
                        }
                        firstComma = false;
                        data.Append("\"");
                        data.Append(t.Item2);
                        data.Append("\":");
                        data.Append(string.Format(noCommas, "{0:0.00}", value));
                    }
                }
                data.Append("}");
                if (firstLine)
                {
                    firstLine = false;
                    addText(data.ToString());
                }
                Byte[] sendBytes = Encoding.ASCII.GetBytes(data.ToString());
                sock.SendTo(sendBytes, endPoint);
                System.Threading.Thread.Sleep(sleep);
            }
        }
예제 #27
0
        public void Command(User pl, string cmd, string[] args)
        {
            if(cmd == "esshelp")
            {
                pl.Message("Fougerite-Essentials " + Version + " by ice cold");
                pl.Message("/help - see all commands");
                pl.Message("/rules - see all the rules");
                pl.Message("/info - See info about this plugin");
                pl.Message("/friendhelp - See all information about the friends system");
                pl.Message("/sharehelp - See all help about the share system");
                if(EnableHome) { pl.Message("/home - See all help about the home system"); }
                if(EnableRemove) { pl.Message("/remove - Enables/disables remover tool"); }
                if(Enabletpr) { pl.Message("/tpr name - sends teleport request to that user"); pl.Message("/tpa - Accepts an teleport reqequest"); }
                if(EnableWarps) { pl.Message("/warphelp - See all the help for the warping system"); }
                if(pl.Admin || pl.Moderator)
                {
                    pl.Message("/prod - Shows the owner of the object you are looking at");
                    pl.Message("/country player - Shows from which country a player comes");
                    pl.Message("/download url filename - downloads that object and put it in the the Downloaded folder EXAMPLE: (/download http://myitem.com myitem.zip)");
                    pl.Message("/addnewspawn - adds a new spawns to the overwrite spawn list");
                }              
            }
            else if(cmd == "country")
            {
                if(pl.Admin || pl.Moderator)
                {
                    if(args.Length != 1) { pl.Message("Usage /country player"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    string country = PlayerDatabase.GetSetting(target.SteamID, "Country");
                    pl.Message("[color #ffb90f]" + target.Name  + " is located from [color #c1ffc1]" + country);
                }
            }
            else if(cmd == "download")
            {
                if(pl.Admin)
                {
                    if(args.Length != 2) { pl.Message("Usage /download url filename - EXAMPLE: (/download http://myitem.com myitem.zip)"); return; }
                    using (WebClient web = new WebClient())
                    {
                        web.DownloadFileAsync(new Uri(args[0]), Util.GetRootFolder() + "\\Save\\Fougerite-Essentials\\Downloaded\\" + args[1]);
                        pl.Message("[color #00ced1]Downloading " + args[1] + " to downloaded folder");
                    }
                }
            }
            else if(cmd == "addnewspawn")
            {
                if(pl.Admin)
                {
                    if(EnableNewSpawns)
                    {
                        string[] c = SpawnsOverwrite.EnumSection("SpawnLocations");
                        string co = (Convert.ToInt32(c[c.Length - 1]) + 1).ToString();
                        SpawnsOverwrite.AddSetting("SpawnLocations", co, pl.Location.ToString());
                        SpawnsOverwrite.Save();
                    }                 
                }
            }
            else if(cmd == "warphelp")
            {
                pl.Message("Fougerite-Essentials WarpSystem by ice cold");
                pl.Message("/warp name - Warps you to that location");
                pl.Message("/warps - See all the current warps");
                if(pl.Admin)
                {
                    pl.Message("/warp_set Name");
                    pl.Message("/warp_remove Name");
                }
            }
            else if(cmd == "warp")
            {
                if(args.Length != 1) { pl.Message("Usage /warp name"); return; }
                if(Warps.ContainsSetting("Warps", args[0]))
                {
                    if (pl.Admin)
                    {
                        Vector3 loc = Util.GetUtil().ConvertStringToVector3(Warps.GetSetting("Warps", args[0]));
                        pl.TeleportTo(loc);
                        pl.Message("[color#00bfff]Warped to " + args[0]);
                    }
                    else
                    {
                        if(!warpcd.Contains(pl.UID))
                        {
                            var dict = new Dictionary<string, object>();
                            dict["pl"] = pl;
                            warpcd.Add(pl.UID);
                            Warpcooldown(WarpCooldown * 1000, dict).Start();
                            Warpdelaytimer(WarpDelay * 1000, dict).Start();
                            string message = WarpDelayMessage.Replace("{warpname}", args[0]);
                        }
                        else
                        {
                            pl.Message(WarpCooldownMessage);
                        }
                    }
                }             
            }
            else if(cmd == "warps")
            {
                pl.Message("WarpsList");
                string[] l = Warps.EnumSection("Warps");
                foreach(var num in l)
                {
                    pl.Message(num);
                }
            }
            else if(cmd == "warp_set")
            {
                if(pl.Admin)
                {
                    if(args.Length != 1) { pl.Message("Usage /warp_set Name"); return; }
                    if(Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is already a warp with the name " + args[0]); return; }
                    Warps.AddSetting("Warps", args[0], pl.Location.ToString());
                    Warps.Save();
                    pl.Message("Warp saved");
                }
            }
            else if(cmd == "warp_remove")
            {
                if(pl.Admin)
                {
                    if(args.Length != 1) { pl.Message("Usage /warp_remove Name"); return; }
                    if(!Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is no warp with the name " + args[0]); return; }
                    Warps.DeleteSetting("Warps", args[0]);
                    Warps.Save();
                    pl.Message("The warp " + args[0] + " has been succesfully removed");
                }
            }
            else if(cmd == "help")
            {
                if(EnableHelp)
                {
                    foreach (var h in HelpList.EnumSection("Help"))
                    {
                        string d = HelpList.GetSetting("Help", h);
                        pl.MessageFrom("Help", d);
                    }
                }
                
            }
            else if(cmd == "rules")
            {
                if(EnableRules)
                {
                    foreach (var r in RulesList.EnumSection("Rules"))
                    {
                        string d = RulesList.GetSetting("Help", r);
                        pl.MessageFrom("Help", d);
                    }
                }          
            }
            else if(cmd == "info")
            {
                pl.MessageFrom(Name, "[color #87cefa][Fougerite-Essentials " + Version + " plugin brought by ice cold");
                pl.MessageFrom(Name, "[color #20b2aa]Wanna support ice cold? https://www.patreon.com/uberrust");
                pl.MessageFrom(Name, "[color #8470ff]You can download this plugin at ");
            }
            else if(cmd == "friendhelp")
            {
                pl.Message("[Fougerite-Essentials] Friends system brought by ice cold");
                pl.Message("/addfriend Name - ads player to your friends list");
                pl.Message("/unfriend Name - Unfriend someone");
                pl.Message("/friends - See all your friends");
            }
            else if(cmd == "sharehelp")
            {
                pl.Message("[Fougerite-Essentials] Share system brought by ice cold");
                pl.Message("/share Name - Door/structure share the player");
                pl.Message("/unshare Name - unshare someone");
                pl.Message("/sharelist - See all the people you have shared");
            }
            else if(cmd == "addfriend")
            {
                if(EnableFriendsSystem)
                {
                    if (args.Length != 1) { pl.Message("Usage /addfriend Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if (target == null) { pl.Message("Couldn't find the target user"); return; }
                    if (friends.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadyFriendedMessage.Replace("{friend}", target.Name); pl.Message(message); return; }
                    string me = AddFriendMessage.Replace("{friend}", target.Name);
                    pl.Message(me);
                    friends.AddSetting(pl.SteamID, target.SteamID, target.Name);
                    friends.Save();
                }
             
            }
            else if(cmd == "unfriend")
            {
                if(EnableShareSystem)
                {
                    if (args.Length != 1) { pl.Message("Usage /unfriend Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    if(!friends.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message(target.Name + " Isnt in your friends list"); return; }
                    friends.DeleteSetting(pl.SteamID, target.SteamID);
                    friends.Save();
                    string message = UnfriendMessage.Replace("{target}", target.Name);
                    pl.Message(message);
                    friends.DeleteSetting(pl.SteamID, target.SteamID);
                    friends.Save();
                }
               
            }
            else if(cmd == "friends")
            {
                if(EnableFriendsSystem)
                {
                    pl.Message("===FriendsList===");
                    foreach (var id in friends.EnumSection(pl.SteamID))
                    {
                        string m = friends.GetSetting(pl.SteamID, id);
                        pl.Message("_ " + m);
                    }
                }
            }
            else if(cmd == "share")
            {
                if(EnableShareSystem)
                {
                    if(args.Length != 1) { pl.Message("Usage /share Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if (target == null) { pl.Message("Couldn't find the target user");  return; }
                    if(share.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadySharedMessage.Replace("{player}", target.Name); pl.Message(message); return; }
                    share.AddSetting(pl.SteamID, target.SteamID, target.Name);
                    share.Save();
                    string me = SharedMessage.Replace("{player}", target.Name);
                    pl.Message(me);
                }
            }
            else if(cmd == "unshare")
            {
                if(EnableShareSystem)
                {
                    if(args.Length != 1) { pl.Message("Usage /unshare Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    if(!share.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message("You are not sharing with " + target.Name); return; }
                    share.DeleteSetting(pl.SteamID, target.SteamID);
                    share.Save();
                    string message = UnSharedMessage.Replace("{player}", target.Name);
                    pl.Message(message);
                }
            }
            else if(cmd == "sharelist")
            {
                if(EnableShareSystem)
                {
                    pl.Message("===ShareList===");
                    foreach(var id in share.EnumSection(pl.SteamID))
                    {
                        string m = share.GetSetting(pl.SteamID, id);
                        pl.Message("- " + m);
                    }
                }
            }
            else if(cmd == "prod")
            {
                if(pl.Admin || pl.Moderator)
                {
                    cachedCharacter = pl.PlayerClient.rootControllable.idMain.GetComponent<Character>();
                    if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { pl.Message("He Hello thats the sky bro"); return; }

                    if(cachedhitInstance != null)
                    {
                        cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
                        if (cachedCollider == null) { pl.Message("Sorry but i cannot prod that"); return; }
                        cachedStructure = cachedCollider.GetComponent<StructureComponent>();

                        if (cachedStructure != null && cachedStructure._master != null)
                        {
                            cachedMaster = cachedStructure._master;
                            var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name");
                            pl.Message(string.Format("{object} - {ID} - {name}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "Unknown" : name.ToString()));
                        }
                    }
                    else
                    {

                        cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();

                        if(cachedDeployable != null)
                        {
                            var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name");
                            pl.Message(string.Format("{object} - {ID} - {name}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
                        }
                    }
                    pl.Message("Failed to prod " + cachedRaycast.collider.gameObject.name);
                }
            }
            else if(cmd == "home")
            {
                if(EnableHome)
                {
                    if(args.Length != 1)
                    {
                        pl.Message("[Fougerite-Essentials] Home system brought by ice cold");
                        if(!SleepingHome)
                        {
                            pl.Message("/home Name - teleports you the home");
                            pl.Message("/sethome Name - Enabled sethome mode (hit a foundation or ceiling to save your home)");
                            pl.Message("/delhome Name - Deletes that home");
                            pl.Message("/homes - Shows the list of homes");
                        }
                        else
                        {
                            pl.Message("/homeon - Enables home mode (place a Sleepingbag or Bed to save that as your current home)");
                            pl.Message("/gohome - Teleports you to your sleepingBag or Bed");
                        }
                    }
                    else
                    {
                        if(!SleepingHome)
                        {
                            if(!homecd.Contains(pl.UID))
                            {
                                if (StructureHome.ContainsSetting(pl.SteamID, args[0]))
                                {
                                    var homeloc = StructureHome.GetSetting(pl.SteamID, args[0]);
                                    var dict = new Dictionary<string, object>();
                                    dict["pl"] = pl;
                                    dict["homeloc"] = homeloc;
                                    HomeTimer(HomeDelay * 1000, dict).Start();
                                    string message = HomeDelayMessage.Replace("{home}", args[0]).Replace("{delay}", HomeDelay.ToString());
                                    pl.Message(message);
                                    HomeCooldown(HomeCooldown * 1000, dict).Start();
                                    homecd.Add(pl.UID);
                                }
                                else
                                {
                                    string message = NoHomeMessage.Replace("{home}", args[0]);
                                    pl.Message(message);
                                }
                            }
                            else
                            {
                                string message = HomeCooldownMessage.Replace("{cooldown}", HomeCooldown.ToString());
                                pl.Message(message);
                            }
                        }
                    }
                }
            }
            else if(cmd == "sethome")
            {
                if(EnableHome)
                {
                    if(!homemode.Contains(pl.UID))
                    {
                        if (args.Length != 1) { pl.Message("Usage /sethome Name"); return; }
                        string[] l = StructureHome.EnumSection(pl.SteamID);
                        if ((Convert.ToBoolean(l.Length == MaxHomes)))
                        {
                            pl.Message(MaxHomesMessage);
                        }
                        else
                        {
                            homemode.Add(pl.UID);
                            pl.Message("Sethome mode activated hit a foundation/ceiling to set your home");
                            homenum.Add(pl.UID, args[0]);
                        }
                    }
                    else
                    {
                        pl.Message("Please do /homestop first");
                    }
                  
                }
            }
            else if(cmd == "")
        }
예제 #28
0
 public void Command(Player pl, string cmd, string[] args)
 {
     if (cmd == "tploc")
     {
         if (pl.Admin || Hasflag(pl, FLAG_USE))
         {
             if (args.Length == 0)
             {
                 pl.MessageFrom(Name, "Try out /tploc name");
                 string[] en = ini.EnumSection("Locations");
                 {
                     foreach (var locs in en)
                     {
                         pl.MessageFrom(Name, locs);
                     }
                 }
             }
             else
             {
                 if (ini.ContainsSetting("Locations", args[0]))
                 {
                     string  j   = ini.GetSetting("Locations", args[0]);
                     Vector3 loc = Util.GetUtil().ConvertStringToVector3(j); // makes a Vector3 of string
                     pl.TeleportTo(loc);
                     pl.InventoryNotice(args[0]);
                 }
                 else
                 {
                     pl.MessageFrom(Name, "There is no location called " + args[0]);
                 }
             }
         }
     }
     else if (cmd == "tplocadd")
     {
         if (pl.Admin || Hasflag(pl, FLAG_USE))
         {
             if (args.Length == 0)
             {
                 pl.MessageFrom(Name, "Syntax /tplocadd name");
                 return;
             }
             if (ini.ContainsSetting("Locations", args[0]))
             {
                 pl.MessageFrom(Name, "There is already a location called " + args[0]);
             }
             else
             {
                 ini.AddSetting("Locations", args[0], pl.Location.ToString());
                 pl.MessageFrom(Name, "New location called " + args[0] + " added at " + pl.Location);
                 ini.Save();
             }
         }
     }
     else if (cmd == "tplocremove")
     {
         if (pl.Admin || Hasflag(pl, FLAG_USE))
         {
             if (args.Length == 0)
             {
                 pl.MessageFrom(Name, "Syntax /tplocremove name");
                 return;
             }
             if (ini.ContainsSetting("Locations", args[0]))
             {
                 ini.DeleteSetting("Locations", args[0]);
                 ini.Save();
                 pl.MessageFrom(Name, "The location " + args[0] + " has been deleted");
             }
         }
     }
 }
예제 #29
0
        public void On_PluginInit()
        {
            Author  = "Corrosion X";
            Version = "1.0.5";
            About   = "Requires players to accept rules or be disconnected.";
            ServerConsoleCommands.Register("kick.player")
            .setCallback(Kickplayer)
            .setDescription("Kicks player if they disagree to rules.")
            .setUsage("None");
            if (!Plugin.IniExists("rules"))
            {
                IniParser ini = Plugin.CreateIni("rules");
                ini.AddSetting("Rules", "1", "No Cheating.");
                ini.AddSetting("Rules", "2", "No Hacking.");
                ini.AddSetting("Rules", "3", "No Racism/Hate/Offensive text/symbols/images.");
                ini.Save();
            }
            IniParser getini = Plugin.GetIni("rules");

            ruleslist = "<color=white>Welcome to " + ConVar.Server.hostname + " !</color> \n <color=red>By joining this server you agree to the following rules:</color> \n \n";
            foreach (string arg in getini.EnumSection("Rules"))
            {
                ++i;
                ruleslist += "<color=white>" + i + "</color>" + ". <color=red>" + getini.GetSetting("Rules", arg) + "</color> \n";
            }
            json = @"[	
                        {
                            ""name"": ""AcceptRules"",
                            ""parent"": ""HUD/Overlay"",
                            ""components"":
                            [
                                {
                                     ""type"":""UnityEngine.UI.Image"",
                                     ""color"":""0.1 0.1 0.1 1"",
                                }, 
                                {    
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0 0"",
                                    ""anchormax"": ""1 1""
                                },
                                {  
                                    ""type"":""NeedsCursor""
                                }
                            ]
                        },
                        {
                            ""parent"": ""AcceptRules"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.Text"",
                                    ""text"":""{ruleslist}"",
                                    ""fontSize"":20,
                                    ""align"": ""MiddleCenter"",
                                },
                                { 
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0 0.1"",
                                    ""anchormax"": ""1 0.9""
                                }
                            ]
                        }, 
                        {
                            ""name"": ""BtnAccept"",
                            ""parent"": ""AcceptRules"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.Button"",
                                    ""close"":""AcceptRules"",
                                    ""color"": ""0.08 0.71 0.12 0.2"",
                                    ""imagetype"": ""Tiled""
                                },
                                {
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0.2 0.16"",
                                    ""anchormax"": ""0.4 0.20""
                                }
                            ]
                        },
                        {
                            ""parent"": ""BtnAccept"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.Text"",
                                    ""text"":""Accept"",
                                    ""fontSize"":20,
                                    ""align"": ""MiddleCenter""
                                }
                            ]
                        },
                        {
                            ""name"": ""BtnDontAccept"",
                            ""parent"": ""AcceptRules"",
                            ""components"":
                            [
                                {
                                    ""close"":""AcceptRules"",
                                    ""command"":""kick.player"",
                                    ""type"": ""UnityEngine.UI.Button"",
                                    ""color"": ""0.9 0.23 0.23 0.2"",
                                    ""imagetype"": ""Tiled""
                                },
                                {
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0.6 0.16"",
                                    ""anchormax"": ""0.8 0.20""
                                }
                            ]
                        },
                        {
                            ""parent"": ""BtnDontAccept"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.Text"",
                                    ""text"":""Dont Accept"",
                                    ""fontSize"":20,
                                    ""align"": ""MiddleCenter""
                                }
                            ]
                        }
                    ]";
        }