ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getPedBonePosition

Function

getPedBonePosition

Server and clientPedsIdentical to MTA:SA

Returns the world position of a chosen skeleton bone of a ped, such as the head or a hand. On the client the position is exact and follows the animation (the bone is read from the game). The server does not know the ped's pose, so it returns an approximation: a fixed bone offset of a standing ped, rotated to match its heading. Bone numbers are the ones from getBoneIDs (e.g. 8 head, 25 right hand, 35 left hand); on the client a game bone index also works.

Syntax

float, float, float getPedBonePosition(ped ped, int bone)

Arguments

pedped
A player or an NPC.
boneint
Bone number: 1-2 pelvis, 3 spine, 4 upper torso, 5 neck, 6-8 head (8 = head centre), 21-26 right arm (22 shoulder, 23 elbow, 24 wrist, 25 hand), 31-36 left arm (35 = hand), 41-44 left leg (44 = foot), 51-54 right leg (54 = foot). On the client a game bone index also works.

Returns

The bone's x, y, z coordinates, or false.

Example

addEventHandler("onClientRender", root, function()
    local x, y, z = getPedBonePosition(localPlayer, 8)
    if x then
        local sx, sy = getScreenFromWorldPosition(x, y, z + 0.3)
        if sx then dxDrawText("Ja", sx, sy) end
    end
end)

See also