1. Might be a really stupid question but..... :p

    So I set HasConfig = true

    Script creates config based on what I have in my LoadDefaultConfig function

    If the config already exists, the LoadDefaultConfig function does nothing

    So short of deleting the config file and loosing any changes the user might have made, how do you go about adding additional config entries?
     
  2. There is a LoadConfig() and SaveConfig() function in Oxide.
    I havent tested this yet but i assume you could do something like
    Code:
    function PLUGIN:ConfigHandler()
        self:LoadConfig()
        -- check the config entries and add or remove some if needed
        self:SaveConfig()
    end
    and call the function in the init hook.
     
  3. Shall give it a go thanks, much appreciated
     
  4. Wulf

    Wulf Community Admin

    Here is what I use that works:
    Code:
    -- Plugin initialization
    function PLUGIN:Init()
        -- Load and update configuration if needed
        self:LoadDefaultConfig()
    end
    Code:
    -- Load default configuration
    function PLUGIN:LoadDefaultConfig()
        -- General settings
        self.Config.Settings = self.Config.Settings or {}
        self.Config.Settings.ChatName = self.Config.Settings.ChatName or "HURT"
        self.Config.Settings.ChatCommand = self.Config.Settings.ChatCommand or "hurt"
        self.Config.Settings.AuthLevel = self.Config.Settings.AuthLevel or "2"    -- Message strings
        self.Config.Messages = self.Config.Messages or {}
        self.Config.Messages.NoPermission = self.Config.Messages.NoPermission or "You do not have permission to use this command!"
        self.Config.Messages.HelpText = self.Config.Messages.HelpText or "Use /hurt player amount (amount being optional, default is 100)"    -- Save and reload the configuration
        self:SaveConfig()
    end
    Basically that will upload the config on Init, adding any missing values or correcting invalid ones. If you want to remove a config option, just set it to nil; ex. self.Config.Settings.ChatCommand = nil.
     
  5. Brilliant :) Glad I asked now, thanks a lot