LiOneLMeSsIShoT Posted November 23, 2013 Share Posted November 23, 2013 createObject (1550, 0, 0, 0) exports.bone_attach:attachElementToBone (bag,thePlayer, (the question here..what x,y,z to attach elemnt in player back?)) or how to know all conditions of attaches? how to know x, y ,z of places on player ? Link to comment
glowdemon1 Posted November 23, 2013 Share Posted November 23, 2013 Perhaps getElementPosition(thePlayer) and fiddle around until you found the right spot. Link to comment
LiOneLMeSsIShoT Posted November 23, 2013 Author Share Posted November 23, 2013 Perhaps getElementPosition(thePlayer) and fiddle around until you found the right spot. but when i get the element position..it says like 2584.51641656486, 2465.54164166 a lot of numbers!!!!! and in attach element i don't need all this numbers. so what Link to comment
TAPL Posted November 23, 2013 Share Posted November 23, 2013 This is included with the script itself. attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz) : attaches element to the bone of the ped. Server and client function.element : Element which you want to attach. ped : Ped or player which you want to attach element to. bone : Bone which you want to attach element to. x,y,z : Position offset from the bone. rx,ry,rz : Rotation offset from the bone. Returns true if element was successfully attached, false otherwise. detachElementFromBone(element) : detaches element from the bone of the ped. Server and client function. element : Element which you want to detach. Returns true if element was successfully detached, false otherwise. isElementAttachedToBone(element) : checks if element is attached to a bone. Server and client function. element : Element which you want to check. Returns true if element is attached to a bone, false otherwise. getElementBoneAttachmentDetails(element) : gets ped, bone and offset of attached element. Server and client function. element : Element which you want to get attachment details of. Returns ped,bone,x,y,z,rx,ry,rz used in attachElementToBone if element is attached, false otherwise. setElementBonePositionOffset(element,x,y,z) : changes position offset of attached element. Server and client function. element : Element which you want to change offset of. x,y,z : New position offset. Returns true if position set successfully, false otherwise. setElementBoneRotationOffset(element,rx,ry,rz) : changes rotation offset of attached element. Server and client function. element : Element which you want to change offset of. rx,ry,rz : New rotation offset. Returns true if rotation set successfully, false otherwise. getBonePositionAndRotation(ped,bone) : gets position and rotation of the ped bone. Client-only function. Returns bone x,y,z position and rotation if ped is streamed in and bone number is valid, false otherwise. Bone IDs: 1: head 2: neck 3: spine 4: pelvis 5: left clavicle 6: right clavicle 7: left shoulder 8: right shoulder 9: left elbow 10: right elbow 11: left hand 12: right hand 13: left hip 14: right hip 15: left knee 16: right knee 17: left ankle 18: right ankle 19: left foot 20: right foot Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 This is included with the script itself.attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz) : attaches element to the bone of the ped. Server and client function.element : Element which you want to attach. ped : Ped or player which you want to attach element to. bone : Bone which you want to attach element to. x,y,z : Position offset from the bone. rx,ry,rz : Rotation offset from the bone. Returns true if element was successfully attached, false otherwise. detachElementFromBone(element) : detaches element from the bone of the ped. Server and client function. element : Element which you want to detach. Returns true if element was successfully detached, false otherwise. isElementAttachedToBone(element) : checks if element is attached to a bone. Server and client function. element : Element which you want to check. Returns true if element is attached to a bone, false otherwise. getElementBoneAttachmentDetails(element) : gets ped, bone and offset of attached element. Server and client function. element : Element which you want to get attachment details of. Returns ped,bone,x,y,z,rx,ry,rz used in attachElementToBone if element is attached, false otherwise. setElementBonePositionOffset(element,x,y,z) : changes position offset of attached element. Server and client function. element : Element which you want to change offset of. x,y,z : New position offset. Returns true if position set successfully, false otherwise. setElementBoneRotationOffset(element,rx,ry,rz) : changes rotation offset of attached element. Server and client function. element : Element which you want to change offset of. rx,ry,rz : New rotation offset. Returns true if rotation set successfully, false otherwise. getBonePositionAndRotation(ped,bone) : gets position and rotation of the ped bone. Client-only function. Returns bone x,y,z position and rotation if ped is streamed in and bone number is valid, false otherwise. Bone IDs: 1: head 2: neck 3: spine 4: pelvis 5: left clavicle 6: right clavicle 7: left shoulder 8: right shoulder 9: left elbow 10: right elbow 11: left hand 12: right hand 13: left hip 14: right hip 15: left knee 16: right knee 17: left ankle 18: right ankle 19: left foot 20: right foot YEah thanks but 3: spine Not Work.. i try to attach the bag to the back of the player...but the id 3 only not work... but others work. Link to comment
tosfera Posted November 24, 2013 Share Posted November 24, 2013 In his script, he's replacing the 1 till 20 with other bones, you can try to work around that and use GetPedBonePosition to get the position of bone 3,4 or 5. Whatever suits you the best. See if that works. Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 In his script, he's replacing the 1 till 20 with other bones, you can try to work around that and use GetPedBonePosition to get the position of bone 3,4 or 5. Whatever suits you the best. See if that works. I think you don't understand me ! exports.bone_attach:attachElementToBone(bagb,thePlayer,3,0,0,0,0,0,0) when i do this don't show the object...like the object's hidden...but with another id it works. like head or neck Link to comment
TAPL Posted November 24, 2013 Share Posted November 24, 2013 I tested your code and it work. Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 I tested your code and it work. try to attach object id 157 Link to comment
TAPL Posted November 24, 2013 Share Posted November 24, 2013 I tested your code and it work. try to attach object id 157 WARNING: Bad usage @ 'createObject' [invalid model id] Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 I tested your code and it work. try to attach object id 1550 Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 I tested your code and it work. try to attach object id 157 WARNING: Bad usage @ 'createObject' [invalid model id] i mean 1550..ops sorry but attach it with number 3 bone. Link to comment
TAPL Posted November 24, 2013 Share Posted November 24, 2013 ID 3 does not work with CJ skin, i don't know why. Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 ID 3 does not work with CJ skin, i don't know why. it's mta bug? Link to comment
LiOneLMeSsIShoT Posted November 24, 2013 Author Share Posted November 24, 2013 Looks like a mta bug. And this error going to be fixed or something like that? Link to comment
hstanley Posted May 6, 2014 Share Posted May 6, 2014 Can you please help me to can I use it? Link to comment
LiOneLMeSsIShoT Posted September 20, 2014 Author Share Posted September 20, 2014 Can you please help me to can I use it? What? Link to comment
haron4igg Posted January 2, 2015 Share Posted January 2, 2015 Replace function "getBoneMatrix" in file "bone_pos_rot.lua" with this implementation function getBoneMatrix(ped,bone) local x,y,z,tx,ty,tz,fx,fy,fz x,y,z = getPedBonePosition(ped,bone_0[bone]) if bone == 1 then local x6,y6,z6 = getPedBonePosition(ped,6) local x7,y7,z7 = getPedBonePosition(ped,7) tx,ty,tz = (x6+x7)*0.5,(y6+y7)*0.5,(z6+z7)*0.5 elseif bone == 3 then local x21,y21,z21, x31,y31,z31 x21,y21,z21 = getPedBonePosition(ped,21) x31,y31,z31 = getPedBonePosition(ped,31) if math.round(x21, 2) == math.round(x31, 2) and math.round(y21, 2) == math.round(y31, 2) and math.round(z21, 2) == math.round(z31, 2) then x21,y21,z21 = getPedBonePosition(ped,21) local _,_,rZ = getElementRotation(ped) tx,ty,tz = getPointInFrontOfPoint(x21, y21, z21, rZ, 0.0001) else tx,ty,tz = (x21+x31)*0.5,(y21+y31)*0.5,(z21+z31)*0.5 end else tx,ty,tz = getPedBonePosition(ped,bone_t[bone]) end fx,fy,fz = getPedBonePosition(ped,bone_f[bone]) local xx,xy,xz,yx,yy,yz,zx,zy,zz = getMatrixFromPoints(x,y,z,tx,ty,tz,fx,fy,fz) if bone == 1 or bone == 3 then xx,xy,xz,yx,yy,yz = -yx,-yy,-yz,xx,xy,xz end return xx,xy,xz,yx,yy,yz,zx,zy,zz end Also you need this one functions: function getPointInFrontOfPoint(x, y, z, rZ, dist) local offsetRot = math.rad(rZ) local vx = x + dist * math.cos(offsetRot) local vy = y + dist * math.sin(offsetRot) return vx, vy, z end function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now