1. Make sure you have at the begining this:
    Code:
    using System.Collections.Generic;
    using Oxide.Core;
    DATA STORAGE:
    Code:
        class StoredData
        {
            //add a variable named "playervariable" to the StoredData Class (F.E: Kills)
            public Dictionary<ulong, double> playervariable = new Dictionary<ulong, double>();
        }        StoredData storedData;
    
    SET THE DATA ON PLUGIN LOAD:
    Code:
    void Loaded()
        {
            //set storedData so it can be read or modified
            storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>("DATAFILENAME");
        }
    
    READ THE DATA:
    Code:
    ...
    double _playervariable; //THE VARIABLE THAT WILL GET THE VALUE OF STORED VARIABLE (OUT _PLAYERVARIABLE)
    if (storedData.playervariable.TryGetValue(playerID, out _playervariable))//SEE IF DATA IS NULL (EXISTS)
        {
            //if the data exists do something with it
            storedData.playervariable[playerID] = _playervariable + 1; //INCREASE THE VARIABLE BY 1;
            Interface.Oxide.DataFileSystem.WriteObject("DATAFILENAME", storedData); //SAVE THE VARIABLE(s) TO DATAFILE NAMED DATAFILENAME
            return;
        }
            //IF DATA IS NULL; (PLAYER HAS NO VALUE FOR A VARIABLE)
            storedData.playervariable[playerID] = 0; //SETS THE VARIABLE TO 0
            Interface.Oxide.DataFileSystem.WriteObject("DATAFILENAME", storedData); //SAVE THE VARIABLE TO DATAFILE NAMED DATAFILENAME
            return;
    
    You can make a variable to be 0 by default by using this code:
    Code:
    void OnPlayerInit(BasePlayer player)
    {
    double _playervariable; //THE VARIABLE THAT WILL GET THE VALUE OF STORED VARIABLE (OUT _PLAYERVARIABLE)
    if (storedData.playervariable.TryGetValue(playerID, out _playervariable)) return;//SEE IF DATA IS NULL (EXISTS)
    storedData.playervariable[playerID] = 0; //SETS THE VARIABLE TO 0
    Interface.Oxide.DataFileSystem.WriteObject("DATAFILENAME", storedData); //save it
    }
    
     
  2. Wulf

    Wulf Community Admin

    The Docs already has.
     
  3. Well, Docs are not the same :D I learned this code from other plugins ^^
     
  4. Wulf

    Wulf Community Admin

    The basics are the same. ;)
     
  5. yeah :D But hope it helps someone