1. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    I've been perplexed as to why a simple time stamp function was not working properly and found to my dismay the following error in the Telnet window when someone logged off. It appears that the hook isn't hooking due to a null reference.

    Telnet console session reports:
    ========================
    2016-06-10T19:39:27 14530.845 INF Chat: 'Mirror': Be back a bit later.
    Code (Text):
    [Oxide] 19:39 [Error] Failed to call hook 'OnPlayerDisconnected' on plugin 'Sheriff v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
    [Oxide] 19:39 [Debug]   at Oxide.Plugins.Sheriff.OnPlayerDisconnected (.EntityPlayer _eplayer) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Sheriff.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0
    Thinking that it was something in my code, I copied and pasted the code from the Docs on the Oxide API and still get the same error. Here's the C# Hook as it appears in my code; it's not getting called.

    Code (Text):
           
    void OnPlayerDisconnected(EntityPlayer ePlayer)
            {        
                PrintToChat("Someone left!");
            }
     
     
    Last edited by a moderator: Jun 11, 2016
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    I need to overhaul all of the hooks for the game as they were never fully fleshed out.
     
  3. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    I should clarify - it is getting called, it's just that the ePlayer is showing up as null, and this is causing the error.

    Cheers.
     
  4. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    I'm hoping you will find some time to look at the hooks, and while you do, I'm loading my MSDN copy of Visual Studio 2015 Pro on my home PC in hopes that I can load up the Oxide source and Unity DLL's and get some intellisense going, as coding without it sucks rocks.

    That, and just maybe I can look at the hook myself and see if it's just a fat-finger error made somewhere that can be easily fixed.
     
  5. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    Well, I guess this is why it's null:

    Code (Text):
            public virtual bool DirectCallHook(string name, out object ret, object[] args)
            {
                ret = null;    <----
                return false;
            }
    RE: Oxide

    I'm running Visual Studio 2015 Professional using .NET 4.6.2 -- there are 98 compile errors against multiple projects with the latest git clone. Is there somewhere I can pull a clean clone that will compile? A sampling of the compile errors are below (I'm relatively new to 2015 and C#, so It's probably something I'm not doing, but I've tried all I know.)

    These are the most common: can't get CSharpPlugin project to compile (comes up for all projects)

    Error Metadata file 'F:\Source\DEV\Oxide\Extensions\Oxide.Ext.CSharp\bin\Debug\Oxide.Ext.CSharp.dll' could not be found ReignOfKings F:\Source\DEV\Oxide\Games\Unity\Oxide.Game.ReignOfKings\CSC


    And lots of these:

    Error CS7069 Reference to type 'Func<,>' claims it is defined in 'mscorlib', but it could not be found Blockstorm F:\Source\DEV\Oxide\Games\Unity\Oxide.Game.Blockstorm\BlockstormCore.cs 71 Active

    Error CS7069 Reference to type 'Action<,>' claims it is defined in 'mscorlib', but it could not be found HideHoldOut F:\Source\DEV\Oxide\Games\Unity\Oxide.Game.HideHoldOut\Libraries\Command.cs 146 Active
     
  6. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    Update: So I hatcheted the rest of the games from the Oxide solution and paired it down to only 7Days to die and it now compiles. The only issue is that you have to hold its hand - it won't successfully Rebuild by itself, because it always chokes on "The type or namespace 'Core' does not exist in the namespace 'Oxide' (are you missing an assembly reference?) "

    When you double-click on all but one of these, they self-resolve. The only way I can build the project though, is to build the individual modules one by one. It appears somewhere in the build dependencies, specifically in the build order, one of the modules is overwriting the CSharp extension directory because I can watch it build, then vanish, then error out and complain that it cant find the CSharp.dll.
     
  7. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Oxide is compiled with .NET 3.5 for the majority of games other than Space Engineers, so using or having .NET 4.6.1 should not matter. If there are compile issues, it is either due to missing files or .NET not having the 3.5 profile. Either way, when running the plugin on the server itself, you shouldn't have any issues. I've been supporting Oxide for 2 years now without any issues compiling. ;)
     
  8. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    This thread can be marked solved as the OnPlayerDisconnect() hook has been patched as of the 7DTD 14.7 update release. The hook will provide a populated ClientInfo object of the player leaving the game: OnPlayerDisconnect(ClientInfo _cInfo) { your code here }
    --- Double Post Merged, Jun 22, 2016 ---
    By the way - I wiped the git repo and did a fresh clone (as I usually do) and lo and behold, I didn't have to do any gymnastics this time to get the entire project to compile. First time, right out of the gate. No setting changes, nothing, nada. Compiled first time with only 37 warnings. You don't want to know how many FXCOP violations, but nobody cares ;-) Nice job.
     
  9. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Nothing changed with the project, so not sure why. :p