Log in to reply
 

HOW TO USE GET_ENTITY_COORDS?



  • I am currently learning how to make a c# script for gta v. And I am having trouble with the method call GET_ENTITY_COORDS. According to the native database, it is a vector3 type but the log file suggests that it is a void type. Can anyone teach me how to use this method? Thank you so much!



  • @POPPINsteve If you know the type of entity, Ped, Vehicle or Prop, just use

    Vector3 _entityPosition = [entity].Position;

    For example:

    Vector3 PlayerPosition = Game.Player.Character.Position;

    Which will get the position of the Ped entity for the player.

    If you want to use that Native instead, you would do.

    Vector3 _entityposition = Function.Call<Vector3>(Hash.GET_ENTITY_COORDS, Game.Player.Character, [alive]);

    Where [alive] is a true or false that decides if the entity is alive or not... just in case you want to get the coords of a dead entity I presume.

    You have to specify the return type in the Function.Call<Vector3> part of the call.



  • @LeeC2202 Thank you so much!!!! It works! Thank you!



  • @POPPINsteve No problem. :slight_smile:



  • @LeeC2202 Are you familiar with the velocity? Caz I can't seem to make the method SET_ENTITY_VELOCITY to work.



  • @POPPINsteve I've never used that I'm afraid. Try setting it in your OnTick to see if it's something that needs to be applied every frame.

    You can also use Entity.Velocity() in ScriptHookVDotNet . Is there any particular reason why you're using natives for everything, or do you just prefer to use them instead of the ScriptHookVDotNet functions?

    I know for some things I do prefer them, as the ScriptHookVDotNet functions don't always work the same as the natives.



  • @LeeC2202 I am just a beginner lol. Don't actually know where to find those xxxx.xxxx() stuff. Is there a website or a list where I can find these things?



  • @POPPINsteve Here you go,
    http://www.dev-c.com/nativedb/

    if you want to mod, this is the bible for modders.



  • @POPPINsteve As far as ScripthookVDotNet is concerned, there is very little documentation.

    What I did when I first started, was create an instance of an entity, like Ped myPed; and then whey you type myPed. Visual Studio will show you all of the properties that a Ped has. You can do the same thing with Vehicle, Prop and even Player.

    Then when you add a property, do the same thing again. So you might do myPed.Position. and then you will get all the properties that Position has.

    I found it was a case of thinking about what you wanted to do and then using the above method to see if there was a property that allowed you to do that. With the player it is a bit more tricky because some things only apply to Game.Player and other things apply to Game.Player.Character, even though it's all referring to what you would class as simply "The Player". So if one doesn't have the property you want, try the alternate one.

    An example of that is if you want to know if the player is aiming at something, you use Game.Player.isAiming but if you want to know what weapon you are aiming with, that's Game.Player.Character.Weapons.Current. So you have two weapon related properties, but one is from the Player and the other is from the Player.Ped

    And if you can't find the answer you're looking for, ask as many questions as you need, someone will always be willing to help, provide code examples etc...

    One handy tip I would add, is the page that @ashishcw has linked to above, click Expand All at the top, select all the text on the page and then copy that into a text file and save it. While that site can be very useful, it can be a pain to search for things because you have to have every section open first, or you need to know the exact name of the Native. So I have that text document that I use to search in, then when I find the Native I want, I copy and Paste that Native function name into that webpage and get specific details about it. I find it much quicker to work that way.


  • MODERATOR

    @POPPINsteve You can browse through the Script Hook V .NET source code to find functions and variables you can use. https://github.com/crosire/scripthookvdotnet/tree/dev_v3/source/scripting



  • @Jitnaught I see World.GetGroundHeight() is still missing a critical parameter... I thought they might have fixed that for v3. :\

    And Task.ParkVehicle().


  • MODERATOR

    @LeeC2202 Are you talking about the missing boolean?



  • @Jitnaught Yeah, it's essential to have that.


  • MODERATOR

    @LeeC2202 I made a pull request to add it.



  • @Jitnaught Is that for both of those or just for the World.GetGroundHeight()?

    The ground one is the most critical, so if it's just that it won't be too bad... it just makes or breaks the function, so it was a must have... thank you.


  • MODERATOR

    @LeeC2202 This is what one of the contributors to SHV.NET replied to my pull request:
    "Every function treats missing parameters as 0, so this change doesn't affect GET_GROUND_Z_FOR_3D_COORD at all, just a visual change."
    Apparently the function works just fine without the boolean at the end.



  • I actually deleted the comment because I realised it wasn't the bool that causes the problem with World.GetGroundHeight(), it's the default height they set of 1000.0f, no matter what you set the Z value of the Vector3 to be. :(

    Native::Function::Call(Native::Hash::GET_GROUND_Z_FOR_3D_COORD, position.X, position.Y, 1000.0f, &height);

    What this means is that when you stand under something, you get this problem. The left side is not under the bridge, the right side is under the bridge. Because you can set the correct value for the Z-position in the Native, you can get a proper value for the ground height.

    I am sorry I sent you off on a wild goose-chase over that boolean... I knew there was a problem and I thought that was it. :blush:

    alt text



  • @ashishcw I know this web site and I am using this web site to modding. But it's a bit complex since every time I have to GTA.Native.Function.Call, ahaha! Thank you any way~



  • @LeeC2202 Thank you very much! Your answer is very helpful!! I have been using visual studio code for coding all the time. Never thought of using vs and get the related properties! Really appreciate your answers and your guidance. When I was searching in the Native database, I expanded all and used ctrl F and type in the possible name the method should include. Can't always find the ones I want, but it's helpful and efficient, ahahaha!



  • @Jitnaught Nice!!Thank you!!!


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.