1. Hello there,

    i've two plugins and i want from plugin 1 the dictionary in plugin 2.
    What i do:

    Plugin 1 Public function to return the Dict prison
    Code:
            public Dictionary<BasePlayer, float> return_prison()
            {
                return prison;
            }
    Plugin 2: Get Dict prison
    Code:
            [PluginReference]
            Plugin RHPrison;
                var prison = (Dictionary<BasePlayer, float>)RHPrison?.Call("return_prison");
                if (prison.ContainsKey(player))
                {
    .......
                }
    But i get everytime a (NullReferenceException: Object reference not set to an instance of an object). What do i wrong?
     
  2. Wulf

    Wulf Community Admin

    I would avoid casting or calling it if it is null, cast later and check for null before using it.
     
  3. Ah okay..
    Code:
                var prison = (Dictionary<BasePlayer, float>)RHPrison?.Call("return_prison");
                if(prison != null)
                {
                     if (prison.ContainsKey(player))
                     {                 }
                }
    ?
     
  4. Any possibilities for the entire code? It's not that easy to say what's wrong with only parts of it.
     
  5. This is the full part. plugin 1 returns the dict with baseplayer and float. But it doesnt call the fuction in the plugin. i dont understand this

    How to call a function from plugin 2 in plugin 1?

    EG:
    Plugin 1 function:
    public string(ulong id)
    {
    return string
    }

    plugin2 ?
    What to do?
     
  6. Actually just noticed you declared your method public, Call in conjunction with PluginReference is only able to call methods that are declared private. So above code should work fine if you would change your return_prison() method from public to private.
     
  7. Yeah change from public to private works fine Thanks :). But why?