Jump to content

Attaching Player to an object


Xwad

Recommended Posts

Posted

Hi Community! So im trying to attach the player to the m4 weapon but its not working.. Im using AttachElements.

client

  
local weapon = createWeapon("m4", -2376.80, -578.50, 132.3) 
    setWeaponClipAmmo(weapon, 200) 
    setWeaponState(weapon, "ready") 
  
  
  
function bindFire (source) 
  local x, y, z = getElementPosition ( source )  
  attachElements ( source, weapon, 0, 0, 5 ) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire ) 
  
  
  
  

Posted
local weapon = createWeapon("m4", -2376.80, -578.50, 132.3) 
    setWeaponClipAmmo(weapon, 200) 
    setWeaponState(weapon, "ready") 
  
  
  
function bindFire (source) 
  local x, y, z = getElementPosition ( source ) 
  attachElements ( weapon, source, 0, 0, 5 ) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire ) 

Posted

GetElementPosition and attachElements bad arguentum:/

i made this function in the script to test that if the weapon is rotating the the player is moving too. but its not working

  
  
function pedRotate ( ) 
    local rotX, rotY, rotZ = getElementRotation(weapon) 
    setElementRotation(weapon,0,0,rotZ+50,"default",true) 
end 
addCommandHandler ( "t", pedRotate ) 
  

Posted
local weapon = createWeapon("m4", -2376.80, -578.50, 132.3) 
    setWeaponClipAmmo(weapon, 200) 
    setWeaponState(weapon, "ready") 
  
  
  
function bindFire (source) 
  local x, y, z = getElementPosition ( source ) 
  attachElements ( weapon, source, x, y, z ) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire )  

Posted

Chrisi its not working with your script:/ I removed source and now its working but now i have another problem.. When the weapon is attaching to the player then the weapon has another rotation.. I i tryed to rotate it but its not working..pls help.

  
function bindFire () 
  local x, y, z = getElementPosition ( source ) 
  local rotX, rotY, rotZ = getElementRotation(weapon)     
  attachElements ( weapon, source, 0, 0.3, 0.2 ) 
  setElementRotation(weapon,rotX,rotY,rotZ+43) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire ) 
  

Posted
function bindFire () 
  local x, y, z = getElementPosition ( source ) 
  local rotX, rotY, rotZ = getElementRotation(source)     
  attachElements ( weapon, source, 0, 0.3, 0.2 ) 
  setElementRotation(weapon,rotX,rotY,rotZ+43) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire ) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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