Jump to content

attachElementToBone


HoLsTeN

Recommended Posts

client side only:

function attachElementToBone(element,ped,bone) 
local boneX,boneY,boneZ = getPedBonePosition(ped,bone) 
setElementPosition(element,boneX,boneY,boneZ) 
attachRotationAdjusted(element,ped) 
end 
  
function attachRotationAdjusted (from, to) 
    local frPosX, frPosY, frPosZ = getElementPosition(from) 
    local frRotX, frRotY, frRotZ = getElementRotation(from) 
    local toPosX, toPosY, toPosZ = getElementPosition(to) 
    local toRotX, toRotY, toRotZ = getElementRotation(to) 
    local offsetPosX = frPosX - toPosX 
    local offsetPosY = frPosY - toPosY 
    local offsetPosZ = frPosZ - toPosZ 
    local offsetRotX = frRotX - toRotX 
    local offsetRotY = frRotY - toRotY 
    local offsetRotZ = frRotZ - toRotZ 
    offsetPosX, offsetPosY, offsetPosZ = applyInverseRotation (offsetPosX, offsetPosY, offsetPosZ, toRotX, toRotY, toRotZ) 
    attachElements(from, to, offsetPosX, offsetPosY, offsetPosZ, offsetRotX, offsetRotY, offsetRotZ) 
end 
  
function applyInverseRotation (x,y,z, rx,ry,rz) 
    local DEG2RAD = (math.pi * 2) / 360 
    rx = rx * DEG2RAD 
    ry = ry * DEG2RAD 
    rz = rz * DEG2RAD 
    local tempY = y 
    y =  math.cos (rx) * tempY + math.sin (rx) * z 
    z = -math.sin (rx) * tempY + math.cos (rx) * z 
    local tempX = x 
    x =  math.cos (ry) * tempX - math.sin (ry) * z 
    z =  math.sin (ry) * tempX + math.cos (ry) * z 
    tempX = x 
    x =  math.cos (rz) * tempX + math.sin (rz) * y 
    y = -math.sin (rz) * tempX + math.cos (rz) * y 
    return x, y, z 
end 

Not sure it will work though, just an idea i came up with.

Link to comment

Why do people take SA-MP as an example? SA-MP sucks and has nothing impossible for MTA. Actually, with getPedBonePosition in MTA you can do much more than SetPlayerAttachedObject in SA-MP. If you don't want to script attachElementToBone yourself, use bone attachments resource. It has no limits for attaching objects, while in SA-MP there are only 5 object slots per player.

Link to comment

We all want MTA to be better than SA-MP and that's exactly how it is. But I find a little problem in MTA community: everyone wants somebody to come out of nowhere and do the job for them. That was the situation with bone attachments: getPedBonePosition has existed for a long time, but there still were many people who wanted bone attachment functions to be implemented. That took such a long time that they could have scripted it themselves, but they didn't. So I decided to make the resource myself. I'm glad that people like it, but I also feel a bit disappointed in them.

Link to comment
We all want MTA to be better than SA-MP and that's exactly how it is. But I find a little problem in MTA community: everyone wants somebody to come out of nowhere and do the job for them. That was the situation with bone attachments: getPedBonePosition has existed for a long time, but there still were many people who wanted bone attachment functions to be implemented. That took such a long time that they could have scripted it themselves, but they didn't. So I decided to make the resource myself. I'm glad that people like it, but I also feel a bit disappointed in them.

Its Suggestion !

He asked for new function like other do

If you dont want it ... others will want it

Its up to developers

For me yes better than nothing 8)

Link to comment
We all want MTA to be better than SA-MP and that's exactly how it is. But I find a little problem in MTA community: everyone wants somebody to come out of nowhere and do the job for them. That was the situation with bone attachments: getPedBonePosition has existed for a long time, but there still were many people who wanted bone attachment functions to be implemented. That took such a long time that they could have scripted it themselves, but they didn't. So I decided to make the resource myself. I'm glad that people like it, but I also feel a bit disappointed in them.

Its Suggestion !

He asked for new function like other do

If you dont want it ... others will want it

Its up to developers

For me yes better than nothing 8)

If I didn't want the function, why would I make it? Writing the function in Lua isn't "nothing" and I haven't seen people who care if the function is added by the resource or implemented into MTA itself.

Link to comment
  • 2 weeks later...
We all want MTA to be better than SA-MP and that's exactly how it is. But I find a little problem in MTA community: everyone wants somebody to come out of nowhere and do the job for them. That was the situation with bone attachments: getPedBonePosition has existed for a long time, but there still were many people who wanted bone attachment functions to be implemented. That took such a long time that they could have scripted it themselves, but they didn't. So I decided to make the resource myself. I'm glad that people like it, but I also feel a bit disappointed in them.

Its Suggestion !

He asked for new function like other do

If you dont want it ... others will want it

Its up to developers

For me yes better than nothing 8)

If I didn't want the function, why would I make it? Writing the function in Lua isn't "nothing" and I haven't seen people who care if the function is added by the resource or implemented into MTA itself.

well I didnt ask you to create it

MTA made by many people not by your side

btw Holsten i saw a resource do that what u want search it in community & have fun :)

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...