1. Hi. I try to read a value inside a datafile of another plugin but don't know how to check it. Plugin has code to create data:

    Code:
            class StoredData
            {
                public Dictionary<string, ProfileInfo> ProfileDatabase = new Dictionary<string, ProfileInfo>();
            }
       
            class ProfileInfo
            {
                public string UserId;
                public string Name;
                public int Level;            public ProfileInfo() { }            public ProfileInfo(BasePlayer player)
                {
                    UserId = player.userID.ToString();
                    Name = player.displayName;
                    Level = 1;
               
                }
            }
            StoredData storedData;
    In my new plugin I try to make a IF condition like this:
    Code:
    ProfileInfo info = storedData.ProfileDatabase[player.userID.ToString()];if (info.Level == 1) return true;
    That works if data is from the same plugin. How can I use same type of code if it's another plugin? I know about
    [PluginReference]
    Plugin Languages;

    I found a line
    Code:
    object playerData = Profile.Call("GetUserData", player.userID.ToString());
    Is it well used? if plugin name is Profile?

    but im confused :(
    [DOUBLEPOST=1441256713,1441164804][/DOUBLEPOST]Only thing I find to read data from external plugin is economy which use lua (yay..). I dont know if I can use the same syntax as that LuaFunction and my plugins are all cs.

    Code:
            private Dictionary<string, LuaFunction> EconomyApi = new Dictionary<string, LuaFunction>();
            void OnServerInitialized()
            {
                InitializeTable();
                if (!Economics)
                {
                    PrintWarning("Economics plugin not found. " + this.Name + "will not function!");
                    return;
                }
                var apiFuncs = Economics.Call("GetEconomyAPI") as LuaTable;
                foreach (KeyValuePair<object, object> method in apiFuncs)
                {
                    var value = method.Value as LuaFunction;
                    if (value != null) EconomyApi.Add(method.Key.ToString(), value);
                }
            }
    How do I convert that lua call to csharp? Anyone knows the answer?
     
  2. Wulf

    Wulf Community Admin

  3. Ok thanks ill have a look. Do you know one plugins that read an external datafile? I could read and learn from it. I kinda just saw the Plugin.Call functions or that Lua Table from economics :S
     
  4. Wulf

    Wulf Community Admin

    I don't know any off hand, sorry. The Plugin.Call, Plugin.Exists, and other methods like that are more for calling specific functions in other plugins. It'd be easier just to read the config directly I think.
     
  5. reading the configs YES
    reading the data NO
    because most plugins save data only on server save
    so if you read data before a server save you will have out dated data in the data file.
    [DOUBLEPOST=1441268552][/DOUBLEPOST]that's why it's better to call the plugin and request for the data
     
  6. Call the plugin using call function and using a void that returns a value right?
     
  7. A void does not return anything. It will need to be of the type you want to return. For example string.