IniParser

Mar 22, 2016
IniParser
  • For reference, see the Plugin class.

    Methods:

    Code (C#):
    AddSetting(string sectionName, string settingName):void
    AddSetting(string sectionName, string settingName, string settingValue):void
    ContainsSetting(string sectionName, string settingName) :bool
    Count():int
    DeleteSetting(string sectionName, string settingName):void
    EnumSection(string sectionName):string[]
    GetSetting(string sectionName, string settingName, string defaultValue = ""):string
    GetBoolSetting(string sectionName, string settingName, bool defaultValue = false):bool
    Save():void
    SaveSettings(string newFilePath):void
    SetSetting(string sectionName, string settingName, string value):void
    Pointers:
    Code (C#):
    Name:string
    Sections:string[]
    Example:

    Python:

    Code (Python):
    def BroadcastIni(self):
            if not Plugin.IniExists("BroadcastIni"):
                BroadcastIni = Plugin.CreateIni("BroadcastIni")
                BroadcastIni.AddSetting("Settings", "BroadCast", "Welcome!")
                BroadcastIni.Save()
            return Plugin.GetIni("BroadcastIni")

    def On_PlayerConnected(self, Player):
            ini = self.BroadcastIni()
            message = ini.GetSetting("Settings", "BroadCast")
            Player.Message(message)
    JavaScript:

    Code (Javascript):
    function BroadcastIni() {
            if (!Plugin.IniExists("BroadcastIni")) {
                var BroadcastIni = Plugin.CreateIni("BroadcastIni");
                BroadcastIni.AddSetting("Settings", "BroadCast", "Welcome!");
                BroadcastIni.Save();
            }
            return Plugin.GetIni("BroadcastIni");
    }

    function On_PlayerConnected(Player) {
            var ini = BroadcastIni();
            var message = ini.GetSetting("Settings", "BroadCast");
            Player.Message(message);
    }