Deep thinker Posted December 14, 2016 Share Posted December 14, 2016 hello i was making a script which is depending on the rotation but i was trying to rotate it when i press a button the full script is to create a minigun and attach it to the player's body and allow him to rotate the weapon without aiming it. function createMinigunWeapon() -- Create the weapon 1 meter above the player local x, y, z = getElementPosition(getLocalPlayer()) local weapon = createWeapon("minigun", x, y, z + 5) local rotX, rotY, rotZ = getElementRotation(weapon) bindKey("num_6","down", function() setElementRotation(weapon,0,0,rotZ+10) end ) also i have read the wiki ,i tried to follow its instructions but i totally failed :3 notice : i have just posted the part i need in the script Link to comment
iPrestege Posted December 14, 2016 Share Posted December 14, 2016 Try this : local x,y,z = getElementPosition ( localPlayer ); local weapon = createWeapon( 'minigun',x,y,z+2 ); bindKey ( 'num_6','down', function ( ) if not weapon then return end; local _,_,rotZ = getElementRotation ( weapon ); setElementRotation ( weapon,0,0,rotZ+10 ); end ); Link to comment
Deep thinker Posted December 14, 2016 Author Share Posted December 14, 2016 10 minutes ago, iPrestege said: Try this : local x,y,z = getElementPosition ( localPlayer ); local weapon = createWeapon( 'minigun',x,y,z+2 ); bindKey ( 'num_6','down', function ( ) if not weapon then return end; local _,_,rotZ = getElementRotation ( weapon ); setElementRotation ( weapon,0,0,rotZ+10 ); end ); actually it works efficiently :3 but i want to check if the player is in vehicle then attach the minigun into the car Link to comment
Dimos7 Posted December 14, 2016 Share Posted December 14, 2016 isPedInVehicle attachElements Link to comment
Deep thinker Posted December 14, 2016 Author Share Posted December 14, 2016 34 minutes ago, Dimos7 said: isPedInVehicle attachElements actually i tried to use getPedOccupiedVehicle it worked but attaching the elements didn't work at all addCommandHandler("bobo", function () local position = Vector3(getElementPosition (localPlayer)) local weapon = createWeapon( 'minigun',position.x, position.y, position.z + 3 ); if ( isCar ) then local car = getPedOccupiedVehicle ( source ) attachElements ( weapon, car, 0, 0, 1, 0, 90, 0 ) end there is anther parts but i just posted what i need Link to comment
Dimos7 Posted December 14, 2016 Share Posted December 14, 2016 addCommandHandler("bobo", function () local position = Vector3(getElementPosition (localPlayer)) local weapon = createWeapon( 'minigun',position.x, position.y, position.z + 3 ); if ( isPedInVehicle(localPlayer )) then local car = getPedOccupiedVehicle ( localPlayer ) attachElements ( weapon, car, 0, 0, 1, 0, 90, 0 ) end Link to comment
Deep thinker Posted December 14, 2016 Author Share Posted December 14, 2016 4 minutes ago, Dimos7 said: addCommandHandler("bobo", function () local position = Vector3(getElementPosition (localPlayer)) local weapon = createWeapon( 'minigun',position.x, position.y, position.z + 3 ); if ( isPedInVehicle(localPlayer )) then local car = getPedOccupiedVehicle ( localPlayer ) attachElements ( weapon, car, 0, 0, 1, 0, 90, 0 ) end it worked but i can't rotate now 1 hour ago, iPrestege said: Try this : local x,y,z = getElementPosition ( localPlayer ); local weapon = createWeapon( 'minigun',x,y,z+2 ); bindKey ( 'num_6','down', function ( ) if not weapon then return end; local _,_,rotZ = getElementRotation ( weapon ); setElementRotation ( weapon,0,0,rotZ+10 ); end ); Link to comment
Dimos7 Posted December 14, 2016 Share Posted December 14, 2016 addCommandHandler("bobo", function () local position = Vector3(getElementPosition (localPlayer)) local weapon = createWeapon( 'minigun',position.x, position.y, position.z + 3 ); if ( isPedInVehicle(localPlayer )) then local car = getPedOccupiedVehicle ( localPlayer ) local _,_, rotZ = getElementRotation(weapon) setElementRotation(weapon, 0, 0 , rotZ+10) attachElements ( weapon, car, 0, 0, 1, 0, 90, 0 ) end end) Link to comment
Deep thinker Posted December 14, 2016 Author Share Posted December 14, 2016 alright but now the weapon only shown and damage 1 player i want to make it for the hole players. Link to comment
Dimos7 Posted December 14, 2016 Share Posted December 14, 2016 you want show to all and damage them? Link to comment
Deep thinker Posted December 14, 2016 Author Share Posted December 14, 2016 exactly notice: i couldn't rotate the weapon. can we talk in pm ? i want to show you the full script 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