Hyunsu Posted July 18, 2011 Share Posted July 18, 2011 sorry to my bad english. i want to make "SetPlayerAttachedObject" function in mta. Already, this function exist in samp. this function attach object to player's bone. Then, the object's position and rotation are changed by the bone's movement. i will make this fuction in MTA. but i can't make anything about this function. Now, can MTA's script make this function? (natural, like SAMP) Link to comment
[DemoN] Posted July 18, 2011 Share Posted July 18, 2011 You should calculate angles to attach an element to player bones. https://wiki.multitheftauto.com/wiki/GetPedBonePosition ^ You can find bone IDs with that link. Link to comment
BinSlayer1 Posted July 18, 2011 Share Posted July 18, 2011 https://wiki.multitheftauto.com/wiki/GetPedBonePosition https://wiki.multitheftauto.com/wiki/AttachElements However, this getPedBonePosition will return 3 floats (position of bones) and not a bone object/element, and an element is required for attachElements to work. You'll need to make a workaround here, see https://wiki.multitheftauto.com/wiki/CreateElement or https://wiki.multitheftauto.com/wiki/CreateObject if you use createObject make sure you make it invisible with setElementAlpha() Link to comment
denny199 Posted July 18, 2011 Share Posted July 18, 2011 Do you mean this???: function test () ped = createPed ( 111, 0, 0, 4 ) -- example a ped object = createObject ( 987, 0, 0, 4 ) attachElements ( object, ped, 0, 0, 0 ) -- this attach the object to the ped end addCommandHandler ( "test", test ) But it can to be this: function attach (plyer) object = createObject ( 987, 0, 0, 0 ) -- create a object:a gate attachElements ( object, player, 0, 0, 0 ) end addCommandHandler ( "test", attach ) IDK IF IT WORK Link to comment
Hyunsu Posted July 18, 2011 Author Share Posted July 18, 2011 these are attaching to player. not bodypart(bone). the function is attaching to players' bone. 3.local eLight = createObject(335,0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 4.setElementCollisionsEnabled(eLight, false); 5. 6.addEventHandler("onClientPreRender", getRootElement(), 7.function() 8. 9. 10. local x,y,z = getPedBonePosition(getLocalPlayer(), 22); 11. local x2,y2,z2 = getPedBonePosition(getLocalPlayer(), 23); 12. 13. local x3,y3,z3 = getPedBonePosition(getLocalPlayer(), 26); 14. 15. setElementRotation(eLight, math.deg(math.atan2(z2 - z, math.sqrt((x2-x)*(x2-x) + (y2-y)*(y2-y)))), 0.0, math.deg(math.atan2(-(x2-x), y2-y)) + 40); 16. 17. setElementPosition(eLight, x3,y3,z3); 18. 19.end 20.); 21. i made similar script. (holding knife) but it's not perfect like samp. Link to comment
denny199 Posted July 18, 2011 Share Posted July 18, 2011 You can always try this! https://community.multitheftauto.com/index.php?p=resources&s=details&id=1846 Link to comment
Hyunsu Posted July 18, 2011 Author Share Posted July 18, 2011 You can always try this!https://community.multitheftauto.com/index.php?p=resources&s=details&id=1846 it's attaching to player. not bone. 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