1. Calytic

    Calytic Community Admin Community Mod

    I love this new hook, I'm just wondering how to determine the BasePlayer for the researcher from the ResearchTable class?
     
  2. You need to get 'private BasePlayer user' from ResearchTable
    Ex c#:

    Code:
    using System.Reflection;static FieldInfo userfield = typeof(ResearchTable).GetField("user", (BindingFlags.Instance | BindingFlags.NonPublic));;void SomeFunc(ResearchTable table)
    {
        BasePlayer player = userfield.GetValue(table) as BasePlayer;
    }
     
  3. Calytic

    Calytic Community Admin Community Mod

    Reflection is great! How do I do this in JS? =P

    Something like..

    Code:
    SomeFunc: function(table)
    {
        var userfield = table.GetType().GetField("user", (global.System.Reflection.BindingFlags.Instance | global.System.Reflection.BindingFlags.NonPublic));
        var player = userfield.GetValue(table);
    }
    What am I doing wrong here?
    [DOUBLEPOST=1431466442][/DOUBLEPOST]I'm having the same problem of accessing private properties on 2 other issues I have logged. Knowing how to read AND mutate private properties from JS is sorely needed otherwise I'll have to rewrite everything in C#.
     
  4. Idk how to do it in JS (never tried), but u can try to use 'rust.PrivateBindingFlag()' instead of '(global.System.Reflection.BindingFlags.Instance | global.System.Reflection.BindingFlags.NonPublic)'.
     
  5. Don't have any server files with me but I thought when I tested the hooks when I added them that I didn't use Reflection to get the player who was doing it. I'll have a look tonight and get back to you.
     
  6. Calytic

    Calytic Community Admin Community Mod

    Code:
    SomeFunc: function(table)
    {
        var userfield = table.GetType().GetField("user", rust.PrivateBindingFlag());
        var player = userfield.GetValue(table);
    }
    That actually worked when I tested it. Thanks guys.