WiBox Posted March 7, 2019 Share Posted March 7, 2019 Hey, I need to know how I can make an Ped shoot at the same spot as I do, addEventHandler( "onClientPlayerWeaponFire", root function ( hitElement, hitX, hitY, hitZ ) --set ped shoot as the same hitElement, example: setPedShootOn( thePed, hitElement ) end ) I appreciate who'll help... Thanks. Plus I need that Ped to follow me where ever I go, is that possible? Link to comment
KillerX Posted March 7, 2019 Share Posted March 7, 2019 (edited) try using this function : function setPedShootOn( ped , element ) local available_types = { [ 'vehicle' ] = true , [ 'ped' ] = true , [ 'player' ] = true , } if( isTimer( renderTimer ) ) then killTimer( renderTimer ); end if( isElement( ped ) and getElementType( ped ) == "ped" and isElement( element ) and available_types[ getElementType( element ) ] ) then renderTimer = setTimer( function( ) local px , py , pz = getElementPosition( ped ); local posX , posY , posZ = getElementPosition( element ); local rotZ = -math.deg( math.atan2( posX - px , posY - py ) ); if( rotZ < 0 ) then rotZ = rotZ + 360; end setElementRotation( ped , 0 , 0 , rotZ , "default" , true ); setPedAimTarget( ped , posX , posY , posZ ); setPedControlState( ped , "fire" , not getPedControlState( ped , "fire" ) ); end , 50 , 0 ); end return false end -- by KillerX -- Edited March 7, 2019 by KillerX 1 Link to comment
WiBox Posted March 8, 2019 Author Share Posted March 8, 2019 Thanks you mate, working but about that verification code: " and isElement( element ) and available_types[ getElementType( element ) ] ) then " I had to remove it so it work, it's something in available_types, but nvm I've fix that error in it, thanks. 1 Link to comment
KillerX Posted March 8, 2019 Share Posted March 8, 2019 (edited) you are welcome Edited March 8, 2019 by KillerX 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