Jump to content

"SetPlayerAttachedObject"


Hyunsu

Recommended Posts

sorry to my bad english.

i want to be added "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

It has been possible to script for a long time - even before it was added in SA-MP. You simply need to get joint positions using getPedBonePosition and set object position to the same every frame. If you want the object to have the same rotation which bone has, you also need to get position of 1 or 2 more bones and use trigonometry to calculate rotations.

Link to comment

  
  
local eLight = createObject(335,0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 
setElementCollisionsEnabled(eLight, false); 
  
addEventHandler("onClientPreRender", getRootElement(), 
function() 
  
  
    local x,y,z = getPedBonePosition(getLocalPlayer(), 22); 
    local x2,y2,z2 = getPedBonePosition(getLocalPlayer(), 23); 
     
    local x3,y3,z3 = getPedBonePosition(getLocalPlayer(), 26); 
  
    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); 
  
    setElementPosition(eLight, x3,y3,z3); 
  
end 
); 
  
  

i made similar script. (holding knife)

but it's not perfect like samp.

if you know method, write script here. plz

Link to comment
  • Recently Browsing   0 members

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