1. When I use the SaveConfig on Python it turns all the values to NULL.

    happens after updating the config file and calling self.SaveConfig()

    Code:
    {
      "GroupItems": {
        "admin": [
          null,
          null,
          null,
          null,
          null
        ],
        "moderator": [
          null
        ],
        "player": [
          null
        ]
      }
    }
    Any idea what I am doing wrong?
     
  2. Wulf

    Wulf Community Admin

    It'd probably help to show the code you are using.
     
  3. Code:
        def Init(self):
            command.AddChatCommand('syncgroups', self.Plugin, '_SyncGroups_')    def LoadDefaultConfig(self):
            self.Config['GroupItems'] = ({
           
                                 'admin':({'item_shortname':'attire.hide.boots', 'Amount':1, 'Container':'Wear'},
                                           {'item_shortname':'attire.hide.pants', 'Amount':1, 'Container':'Wear'},
                                           {'item_shortname':'rock', 'Amount':1, 'Container':'Belt'},
                                           {'item_shortname':'bow.hunting', 'Amount':1, 'Container':'Belt'},
                                           {'item_shortname':'arrow.hv', 'Amount':25, 'Container':'Main'},),
                            
                                 'moderator':({},),
                            
                                 'player':({},)
                              })    def _SyncGroups_(self, player, command, args):
            ConfigGroups = []
            for g in self.Config['GroupItems']:
                ConfigGroups.append(g.ToString())        g = None
            del g
            for g in permission.GetGroups():
                if g in ConfigGroups:
                    pass
                else:
                    self.Config['GroupItems'][g.ToString()] = ({},)
            self.SaveConfig()
            rust.SendChatMessage(player, 'Config file has been updated!')
    [DOUBLEPOST=1457222474][/DOUBLEPOST]If you just call self.SaveConfig() even if you don't change anything on the config file still set all the values to null.
    [DOUBLEPOST=1457228899][/DOUBLEPOST]
    [DOUBLEPOST=1457230110,1457222326][/DOUBLEPOST]Wulf, it only happens when there are tuples on the config file. This does not happens when the config file is first created by calling the function "LoadDefaultConfig" but only when calling the SaveConfig.
     

    Attached Files:

  4. Wulf

    Wulf Community Admin

    Weird. @Nogrod would probably know more about it, I'm not really a Python guy.
     
  5. The problem does not seem to be Python but the SaveConfig method. Try to do a test on any other programming language, the issue is when you create a list inside the json file. This does not happens when the json file is created but when the SaveConfig is called. I am pretty sure is a bug on the SaveConfig. The SaveConfig method is turning Lists into null values.
     
  6. Wulf

    Wulf Community Admin

    Not sure, but I've not had any problems with lists in the default config. I think we would have noticed it if it was an issue with other languages.
     
  7. It must be Python then. I will keep trying to see if I can find a work around this if not Ill leave this function alone and try something different. Thanks Wulf.
     
  8. Wulf

    Wulf Community Admin

    Let me know if you find anything. I'll poke Nogrod about it too.
     
  9. Sounds good, thanks.