1. I have EquippedHandlerBase and EquippedHanderServer and GunItemEquippedState, how can i get the player session?
    Code:
    void OnFire(EquippedHandlerServer handler, GunItemEquippedState state)
            {
                EquippedHandlerBase equippedHandler = handler as EquippedHandlerBase;
              
                hurt.BroadcastChat("OnTakeDamage");
            }
     
    Last edited by a moderator: Mar 19, 2016
  2. Wulf

    Wulf Community Admin

    Look for GetSession in either Oxide's source of the game's Assembly-CSharp.dll. You'd need some way to convert what you have available to a session, so you'd need to dig around EquippedHandlerServer or GunItemEquippedState to see if there are any entity or other player references that could be used to get a session linked to those.
     
  3. I tried to do this:
    Code:
    PlayerSession player = GameManager.Instance.GetSession(handler.networkView.owner);
    But i have got an error:
    Code:
    13:36 [Error] Failed to call hook 'OnFire' on plugin 'AdminFunctions v0.2.0' (NullReferenceException: Object reference not set to an instance of an object)
    13:36 [Debug]   at Oxide.Plugins.AdminFunctions.OnFire (.EquippedHandlerServer handler, .GunItemEquippedState state) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AdminFunctions.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
    13:36 [Warning] CallHook 'OnFire' on plugin 'AdminFunctions v0.2.0' took: 1549ms
    Do you know why?
     
  4. Wulf

    Wulf Community Admin

    That means that handler.networkView.owner is not set with anything, so it's null.
     
  5. Do you know any ways to get NetworkPlayer in my situation?
     
  6. Guys i need to get session in this function, changes in method name are impossible!
    Code:
    protected virtual void FireServer(EquippedHandlerServer handler, GunItemEquippedState state)
    {
        Vector3 point = state.CamPivot.rotation * Vector3.forward;
        Vector3 position = state.CamPivot.position;
        IProjectile projectile = state.PreloadedProjectile.Dequeue();
        projectile.GetImpactBehavior().EntityEffects = this._entityEffects;
        Quaternion inacuracyDirection = this.GetInacuracyDirection(state);
        projectile.Launch(position, Quaternion.identity, inacuracyDirection * point * this._shotPower, handler.gameObject, false, 0f);
        state.TimeTillReady = this._refireTime;
        state.Character.DisableSprintTimeout(this._refireTime);
        state.NotifyOnEmpty = true;
    }
    [DOUBLEPOST=1458462629,1458412619][/DOUBLEPOST]I don't understand one moment. Code:
    Code:
    if(handler.networkView.owner == null)
                {
                    hurt.BroadcastChat("null");
                }
                PlayerSession session = Singleton<GameManager>.Instance.GetSession(handler.networkView.owner);
                //PlayerIdentity identity = Singleton<GameManager>.Instance.GetIdentity(handler.networkView.owner);
                hurt.BroadcastChat("OnFire");
    handler.networkView.owner isn't null, because it doesn't send a broadcast to chat, but if i try to get identity or session i have an error:
    Code:
    Failed to call hook 'OnFire' on plugin 'AdminFunctions v0.2.0' (NullReferenceException: Object reference not set to an instance of an object)
     
  7. EquippedHandlerServer doesn't have "networkView" variable
     
  8. Okey. Do you have any ideas to get what i need? I very very need this.
     
  9. Guys, i have made i hook with help of Oxide Patcher. But this hook doesn't contain PlayerSession, how can i add this argument? In Oxide Patcher i can not edit my hook.
    [DOUBLEPOST=1458499688,1458401962][/DOUBLEPOST]UP
     
  10. Wulf

    Wulf Community Admin

    I am not familiar with that hook location, so not right now. I'll be adding a hook in the future to handle what you are wanting, but for right now all I can suggest is to dig around to see the existing methods for converting from one type to another.
     
  11. Wulf

    Wulf Community Admin

    If PlayerSession does not exist in the hook location, you'd need to wrap the hook in HurtworldCore like I mentioned before and try to convert it from what is available in the hooked location. You may never be able to get PlayerSession if there is nothing to reference though.
     
  12. But there are not 100% to convert it? Because i dig all around what i have and i couldn't convert.
     
  13. Wulf

    Wulf Community Admin

    I don't know without looking, but unless you can find either a Steam ID, GameObject/entity, or something else that is linked to the session, you can't.
     
  14. When you will have time, look please. I'll be wery pleased.
    [DOUBLEPOST=1458506336][/DOUBLEPOST]
    And i have antoher one hook. I have session of player who take damage, but how can i get session of player who make this damage. I want to make FriendlyFire and i have seen that one guy made this, but he didn't want to speak with me on this thread :(
    Code of hook:
    Code:
    public void TakeDamage(Vector3 direction, float amount)
    {
    this._hasDirection = direction.sqrMagnitude > 0.1f;
    direction = direction.normalized;
    this._focusedPlayer = Singleton<GameManager>.Instance.FocusedPlayer.GetComponent<CharacterMotorSimple>();
    if (this._hasDirection)
    {
    Quaternion quaternion = Quaternion.LookRotation(-direction);
    this._directionalOffset = quaternion.eulerAngles.y;
    }
    this.SetLevel(1f);
    this._level = 2f;
    this._targetLevel = 0f;
    }
    [DOUBLEPOST=1458573452,1458506036][/DOUBLEPOST]If anybody know an idea how to get something about player or worldplayeridentity in my situation, that i described in the top (TakeDamage), help please.