Might be a really stupid question but.....
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?
Solved Updating config automatically
Discussion in 'Rust Development' started by Taffy, Oct 21, 2014.
-
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
-
-
Wulf Community Admin
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
-