1. What I'm doing wrong? :D

    Code:
    using System.Collections.Generic;
    using System;
    using System.Reflection;
    using System.Text;
    using UnityEngine;
    using Oxide.Core;namespace Oxide.Plugins {
        [Info("TDCCore", "Insane", "0.0.1", ResourceId = 851)]    class TDCCore: RustPlugin    { 
                
          [HookMethod("testm")]
          public String testm() {
                return "WORKING HOOK";
            }
        }
    }
    
    Code:
    using System.Collections.Generic;
    using System;
    using System.Reflection;
    using System.Text;
    using UnityEngine;using Oxide.Core;
    using Oxide.Core.Configuration;
    using Oxide.Core.Plugins;namespace Oxide.Plugins {
        [Info("InfoPlugin", "Insane", "0.0.1", ResourceId = 851)]    class InfoPlugin: RustPlugin    {
            [PluginReference("TDCCore")]
            private Plugin TDCCore;        [ChatCommand("help")]
            void help(BasePlayer player, string command, string[] args) {
                // ... .... .... /
                try {
                    player.ChatMessage(TDCCore.CallHook("testm", null).ToString());
                } catch (Exception ex) {
                    Puts(ex.ToString());
                }
            }
        }
    }
    
    Code:
    [Oxide] 12:44 AM [Info] System.NullReferenceException: Object reference not set to an instance of an object  at Oxide.Plugins.InfoPlugin.help (.BasePlayer player, System.String command, System.String[] args) [0x00000] in <filename unknown>:0 

    Solution:
    Code:
    [PluginReference("TDC_Core")] Plugin PTDCCore;
    ...
    PTDCCore.Call("method", arg1, arg2, arg3);
    
     
    Last edited by a moderator: May 21, 2015
  2. Check if tddcore is null also make your hook method private.
     
  3. tdccore is null
    How can I fix this?
     
    Last edited by a moderator: May 21, 2015
  4. The plugin reference only needs a value if you can't use the class (or filename when referencing a Lua/Py/JS plugin) of the plugin as the variable so in most cases something like this will be sufficient to create a reference to the plugin MyPlugin.cs with the class MyPlugin:
    Code:
    [PluginReference] Plugin MyPlugin;
    If you would try to reference to the teleportation plugin m-Teleportation.lua you would have to use a value:
    Code:
    [PluginReference("m-Teleportation")] Plugin Teleporter;
    This should create the plugin reference if both plugins are loaded. To actually call a method in the referenced plugin you use the method Call(method, args[])
    Code:
    bool running = MyPlugin?.Call("IsRunning");
    string msg = MyPlugin?.Call("GetMessage", "WelcomeMessage");
    Something you always need to be aware of is that the call will only work for private methods. If you want some more examples you could have a look at the plugin overview of the DeadPlayersList where I've added examples how to call the methods of DeadPlayersList from another plugin. (http://oxidemod.org/plugins/deadplayerslist.696/)
     
  5. Thank you so far.
    Another question:
    To send arguments, the normal way should be sth. like
    .Call("method", new Object[]{"string",12})
    How can I do this with Oxide Plugin System?


    Edit: K, simply add arg to arg with commas :D
     
    Last edited by a moderator: May 21, 2015