1. Hello everyone!
    Hi Wulf =D
    So... I don't know if this is a problem of this is how it suppose to work, but here is what I've got.
    If the player is online - position outpus fine
    If the player is offline - position outputs just fine.
    If the player is online and dead - fine.
    BUT!
    If the player is offline and he is KILLED - this code gives me NRE:

    Code:
            [Command("test")]
            void test(IPlayer player, string command, string[] args)
            {
                IPlayer target = players.FindPlayer(args[0]);
                float x, y, z;
                target.Position(out x, out y, out z);
                Puts($"{x},{y},{z}");
            }
    Code:
    > test 03
    [LynchLaw] 1010.097,29.54594,259.1129
    192.168.1.1:60447/76561198002418971/Vlad-00003 disconnecting: disconnect
    > test 03
    Failed to call hook 'test' on plugin 'LynchLaw v1.0.0' (NullReferenceException:
    )
      at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
      at Oxide.Game.Rust.Libraries.Player.Position (.BasePlayer player) [0x00000] in
    <filename unknown>:0
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Position (System.Single& x,
    System.Single& y, System.Single& z) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.LynchLaw.test (IPlayer player, System.String command, System.
    String[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.LynchLaw.DirectCallHook (System.String name, System.Object& r
    et, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod 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 hook, System.Object[] arg
    s) [0x00000] in <filename unknown>:0
    Is there any way I can check if the IPlayer is alive? Only check current health?
     
    Last edited by a moderator: Jul 29, 2017
  2. Code:
    if (!target.IsSleeping && !target.IsConnected) return;
    Could give that a shot. Pretty sure if they are killed they wont be sleeping 'anymore'. Or just add a try catch and return null or something in the catch.
     
  3. I need a sleepers location too(
    I need to know then the player dies. Hm.... that's an idea, gonna use OnEntityKill for this. and then, restore location after the player respawn
    [DOUBLEPOST=1501322835][/DOUBLEPOST]Ok, got something interesting - If the player is dead and he is not connected IPlayer.Health returns 100....
     
  4. Or just use BasePlayer if this is not universal?
     
  5. Did it already - now then the player dies I"m removing his location from the list, and returning it back OnPlayerSleepEnded
    But the problem is still here. If it's not possible to retrive dead player postion - may be it's better to make IPlayer.Postion bool? So it will return false then it's impossible to get position?
     
  6. For BasePlayer it’s easier just to loop through the BasePlayer.activeSleepingPlayers list is it not? That’s quit a hacky way (presuming you’re using BasePlayer)
     
  7. I'm not using baseplayer in the first place =)
     
  8. Wulf

    Wulf Community Admin

    The error is normal, because there'd be no player object if the player is offline and dead. This would be the same for anything that would require a valid player object.
     
  9. Got it. thanks!