Log in to reply

How to return/use value from Native - Bones

  • I'm comfortable working with Set, in both C# and preferably VB.NET, but I'm having trouble with Get.
    I searched for documentation on Bone Index and easily found the index values for peds, but can't find anything for vehicles, just the name.
    In addition to available docs for peds, I can easily attach a prop to a ped in Menyoo, save it as .xml, and then find the bone index in the .xml.
    No such functionality exists for vehicle bones.
    So without that, I guess it leaves me to use this native
    Function.Call(Hash.GET_ENTITY_BONE_INDEX_BY_NAME, Vehicle1, "chassis");
    I thought I could do this like this:
    var Bone = Function.Call(Hash.GET_ENTITY_BONE_INDEX_BY_NAME, Vehicle1, "chassis");
    but that just returns a compiler error instead of the integer I'm looking for.

    Once I have the bone index, I can plug it into
    I was going to create a tool to increment the bone index but I realized what a total waste of time that would be when the function can return the value, and ofc having the bone index as documentation would be ideal.

    Interestingly the Attach function calls for an integer but will accept a string without a compiler error - on load it will crash the game.

    The bone names themselves can be found on pastebins, or here:


  • Ok, i think i figured it out. Should be:
    var Bone = Function.Call<int>(Hash.GET_ENTITY_BONE_INDEX_BY_NAME, Vehicle1, "chassis");

    Update: value is returned but it seems to be -1 or 6.
    That's for it tonight.

  • Seems it was just bad luck, selected bones that didn't make sense with the chosen vehicle or just were wrong for attaching the camera - specifically using chassis.

    So I got this to work and taught myself the proper way to return a value with get and then pass it properly to attach function (like set).

    In the video, i'm just trying out different bone names - the ones I chose were definitely not good views - so will experiment later or just loop through the list of bones.

    I think I should stop and take a break at this point and focus on making some movies - ideally educational movies - which was my original intent. Realized I'm not cut out to be writing scripts, but still happy with what i've been able to do with the help of some great people here.

  • If you're on SHVDNv3, use Entity.Bones["boneName"] instead of GET_ENTITY_BONE_INDEX_BY_NAME.

    If the returned index is -1, it is invalid. If you use Entity.Bones["boneName"], use IsValid to check that the vehicle indeed has that bone.

    If you are completely sure the vehicle has the bone you want to use, you should be able to use the index directly: https://pastebin.com/LpyUwv5k

  • @Jitnaught That's great thanks. Honestly I looked everywhere for the bone indices and all i could find were the names. Great time saver for me. Cheers. Having said that, at least i learned the proper syntax to return a value and convert it to a string to show as message and ofc pass it back to my function.

    This had all the bones, but just the names for the vehicles.

  • If you wanted to get an overview of the available bones, you could use a loop to go through all of the bones then draw a marker on each one of them. Something like this (pseudo-code):

    string[] boneNames = {
        //bone names here
    foreach (string boneName in boneNames)
        var bone = entity.Bones[boneName];
        if (bone.IsValid)
            World.DrawMarker(... bone.Position ...);

  • @Jitnaught That's very cool. I'm at the point on the learning curve where I know what I don't know. And unfortunately, what I don't know is considerable.

  • @Jitnaught I noticed something strange. I selected about 10 names to use as strings in the array and fed them through the foreach loop, but with subtitles.
    "window_lf" returned a 7 for example, but the pastebin has 7 assigned to handle_dside_f?

    And then I noticed, from the previous video that i had posted, that 7 showed a view from above?? WTH. LOL.

    Anyway, wanted to thank you again for your help, patience, and support. I have good ideas now for where to put the camera and the next part is adjusting the vector coordinates properly.

  • @JohnFromGWN Yeah those numbers must not be the bone indices as I thought. Tested it myself, the bone indices vary between vehicles.

  • @Jitnaught BTW, I was not sure how to use the World.DrawMarker function - which has quite a few parameters. The bone.Position I assume will replace the 3 parameters after the marker type - but I tried different combinations without success.
    World.DrawMarker(MarkerType.HorizontalCircleSkinny, bone2.Position, 0?,0?,0?,1?, Color.Blue);

    alt text

  • //              marker type,                        position,       direction,   rotation,      scale,                         color
    World.DrawMarker(MarkerType.HorizontalCircleSkinny, bone2.Position, Vector3.Zero, Vector3.Zero, new Vector3(0.1f, 0.1f, 0.1f), Color.Blue);

    Example from a script: https://gitlab.com/Jitnaught/ropecreator-gta5/-/blob/b9d0677f4caa704757b22ddf74a2acb7d0747729/RopeCreator/Markers.cs#L95

  • @Jitnaught Thumbs up, both for the example and the link. I need to find a way to refine my google searches for anything GTA V script related - because I'm finding more garbage than gems. Thankfully we have these forums and people like you.

  • @Jitnaught You we're right that the bones can vary significantly based on vehicle - from convertible to bus. Gives some promising views though, for example possibility to view passengers on tour bus (TASK_WARP_PED_INTO_VEHICLE).

Log in to reply

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