1. I've got an array I've stored in a Config in my plugin.

    My idea involve players opting into something and as they do this array gets populated and as players opt out they get removed.

    I'm initialising the array like so:
    Code:
    string[] queueParticipants = {};
    Config["queueParticipants"] = queueParticipants;
    But I'm struggling to find a means to add and remove items from the array. A pointer in any direction would be good :)


    Thanks.
     
  2. Example for removing at position 0, this could maybe do it:
    Code:
    int index = 0;
    var removed = queueParticipants.ToList().RemoveAt(index);
    queueParticipants = removed.ToArray();
     
  3. What format does the Config get returned as - is it just an object?

    When I do this:
    Code:
    void QueueSplice(int index, string chat) {    string[] participantArray = Config["queueParticipants"]; //<< line 435    var removed = participantArray.ToList().RemoveAt(index);//<< line 438
        participantArray = removed.ToArray();    Config["queueParticipants"] = participantArray;    ...
    I get the error below:

    Code:
    [SERVER v1.0.24] Console: Queue.cs(436,38): error CS0266: Cannot implicitly convert type `object' to `string[]'. An explicit conversion exists (are you missing a cast?)
    Queue.cs(439,4): error CS0815: An implicitly typed local variable declaration cannot be initialized with `void'
     
  4. Code:
    string[] participantArray = (string[])Config["queueParticipants"];
     
  5. Thanks, that's great :)

    Any thoughts on how to fix the second issue? I tried changing var for a variety of other stuff but still didn't work. But then I didn't know if I actually needed to change the return type for the method instead. I'm not actually returning anything...
     
  6. Only methods different then void need a return type.
    using as type object you have mainly, on example of boolean, three different return values you could return and check against:
    Code:
    true, false, null
     
  7. In the end I got around both issues by having a local copy of the Config values and the saved version - so after each local change I now save it to the Config also for future reference if I need to reload the plugin.

    Thanks for your help.