Jump to content

[Solved] DistanceTo "Coordinates"


Recommended Posts

Hi guys, I made my first mod, yay.

I press a button and my car gets fixed and washed, if it's a police vehicle and I am inside it, I know it's so simple.

But now I am stuck, I spend the entire night on google, and trying out everything I could think of to make it work, including reading a ton of C# stuff, but I can't wrap my head around how to actually do it.

 

So here goes:

I have made a mod where I can press a key and something happens, but what if I only want something to happen near one or more coordinates ?

I tried messing around with this: Game.LocalPlayer.Character.Position.Around() -- but I can't get it to accept my Vector3 without making a ton of errors.

 

To be honest I am not really sure how to put it together, I am just trying to learn 🙂 

Edited by Demuth
Solved

/Demuth

Link to comment
Share on other sites

  • Management Team

You can check if the player is near a given position like this (where 5 is the x coordinate, 6 the y coordinate, 7 the z coordinate and 20 the distance):

if (Game.LocalPlayer.Character.Position.DistanceTo(new Vector3(5, 6, 7)) < 20)
{
}

 

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...