Xwad Posted January 24, 2016 Share Posted January 24, 2016 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 ) Link to comment
Chris!i! Posted January 24, 2016 Share Posted January 24, 2016 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 ) Link to comment
Xwad Posted January 24, 2016 Author Share Posted January 24, 2016 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 ) Link to comment
Chris!i! Posted January 24, 2016 Share Posted January 24, 2016 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 ) Link to comment
Castillo Posted January 24, 2016 Share Posted January 24, 2016 attachElements uses offsets, not world positions. Link to comment
Xwad Posted January 24, 2016 Author Share Posted January 24, 2016 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 ) Link to comment
Chris!i! Posted January 25, 2016 Share Posted January 25, 2016 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 ) Link to comment
Xwad Posted January 25, 2016 Author Share Posted January 25, 2016 not working:(( The weapon is not rotating when i attach the weapon to the player! pls help Link to comment
Chris!i! Posted January 26, 2016 Share Posted January 26, 2016 U can see the weapon?? or there is no weapon? is there any errors? 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