I got some code Of Robbery plugin:
But var entity = FindObject(ray, 1); Seems not workingCode: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); }
PS: Its for personal use, not to copy a plugin!
Solved See if player is looking to other player
Discussion in 'Rust Development' started by TheMechanical97, Jan 13, 2016.
-
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. -
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();
} -
Wulf Community Admin
-
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(); }
-
Wulf Community Admin
-
Its working
Thanks and can i Check if a int = 0?
like if (Variable = 0) return; -
Wulf Community Admin
-
Thanks So MUchh