1. I got some code Of Robbery plugin:
    Code:
    void OnPlayerInput(BasePlayer attacker, InputState input)
            {
                if (!input.WasJustPressed(BUTTON.FIRE_PRIMARY)) return;
                if (!permission.UserHasPermission(player.UserIDString, "Abuse")) return;          
                var ray = new Ray(attacker.eyes.position, attacker.eyes.HeadForward());
                var entity = FindObject(ray, 1);
                var victim = entity as BasePlayer;
                if (victim == null) return;
                var victimToAttacker = (attacker.transform.position - victim.transform.position).normalized;
                if (Vector3.Dot(victimToAttacker, victim.eyes.HeadForward().normalized) > 0) return;
                if (attacker.GetActiveItem()?.GetHeldEntity() != null) return;
                SexAbuse(victim, attacker);
            }
    But var entity = FindObject(ray, 1); Seems not working

    PS: Its for personal use, not to copy a plugin!
     
  2. Wulf

    Wulf Community Admin

    Hopefully credit is given if that is going to be a public plugin... ;)

    Explaining my code: the ray sphere uses the distance specified in the 2nd argument, so if no object is found within that sphere, you'll get nothing. Since it is looking for a player only, the other player would need to be within that area. It also only works so that if the victim is looking at the robber, it will not work, that's what the other checks are for in there.
     
  3. error CS0103: The name `FindObject' does not exist in the current context
    [DOUBLEPOST=1452718646][/DOUBLEPOST]My error, Forgot
    static BaseEntity FindObject(Ray ray, float distance)
    {
    RaycastHit hit;
    return !Physics.Raycast(ray, out hit, distance) ? null : hit.GetEntity();
    }
     
  4. Wulf

    Wulf Community Admin

    You're missing the using statement for that then. It's part of UnityEngine, which it should prompt you for if you use Visual Studio.
     
  5. I have this code:
    Code:
    void OnPlayerInput(BasePlayer attacker, InputState input)
            {
                if (!input.WasJustPressed(BUTTON.FIRE_PRIMARY)) return;
                if (!permission.UserHasPermission(attacker.UserIDString, "job.use")) return;
                if (!permission.UserHasPermission(attacker.UserIDString, "job.robber")) return;           
                var ray = new Ray(attacker.eyes.position, attacker.eyes.HeadForward());
                var entity = FindObject(ray, 1);
                var victim = entity as BasePlayer;
                if (victim == null) return;
                var victimToAttacker = (attacker.transform.position - victim.transform.position).normalized;
                if (Vector3.Dot(victimToAttacker, victim.eyes.HeadForward().normalized) > 0) return;
                if (attacker.GetActiveItem()?.GetHeldEntity() != null) return;
                thiefpay(victim, attacker);
            }        static BaseEntity FindObject(Ray ray, float distance)
            {
                RaycastHit hit;
                return !Physics.Raycast(ray, out hit, distance) ? null : hit.GetEntity();
            }
    And visual studio but ingame, i cant trigger the event :S
     
  6. Wulf

    Wulf Community Admin

    The plugin isn't loaded if it fails to compile. The code is 1:1 with my code though, so I know it works. I'm not sure why you're getting the error with FidnObject if that is indeed the exact code you are using. Without seeing the full code, it's hard to tell what's going on exactly.
     
  7. Its working :D Thanks and can i Check if a int = 0?
    like if (Variable = 0) return;
     
  8. Wulf

    Wulf Community Admin

    if (variable == 0) return;
     
  9. Thanks So MUchh