Jump to content

Hm, something wrong with setPedControlState?


Maurize

Recommended Posts

addEventHandler( "onClientPedDamage", getRootElement(), 
function( attacker, weapon ) 
if ( attacker ) and ( weapon < 22 ) then 
    local helperPed = getPlayerHelper( getLocalPlayer() ) 
    setPedControlState( helperPed, "fire", true ) 
    end 
    cancelEvent() 
end ) 

but if he gets hurt he only shoot one time.. the other times he doesnt?

Link to comment

something like that?

  
addEventHandler( "onClientPedDamage", getRootElement(), 
function( attacker ) 
if ( attacker ) then 
    local helperPed = getPlayerHelper( attacker ) 
    setTimer( 
function() 
    local posX1, posY1, posZ1 = getElementPosition( attacker ) 
    local posX2, posY2, posZ2 = getElementPosition( helperPed ) 
    setPedRotation( helperPed, findRotation( posX1, posY1, posX2, posY2 ) - 180 ) 
    setPedAimTarget( helperPed, posX1, posY1, posZ1 ) 
    setPedControlState( helperPed, "fire", true ) 
    setPedControlState( helperPed, "fire", false ) 
        end, 1000, 5 ) 
    end 
end ) 
  

Link to comment

No, I said a timer to set the "fire" control state to false then to true, constantly.

addEventHandler ( "onClientPedDamage", getRootElement(), 
    function ( attacker, weapon ) 
        if ( attacker ) and ( weapon < 22 ) then 
            local helperPed = getPlayerHelper ( localPlayer ) 
            if ( helperPed ) then 
                setPedControlState ( helperPed, "fire", true ) 
                setTimer ( 
                    function ( thePed ) 
                        if ( thePed ) then 
                            setPedControlState ( thePed, "fire", false ) 
                        end 
                    end 
                    ,200, 0, helperPed 
                ) 
                setTimer ( 
                    function ( thePed ) 
                        if ( thePed ) then 
                            setPedControlState ( thePed, "fire", true ) 
                        end 
                    end 
                    ,500, 0, helperPed 
                ) 
            end 
  
        cancelEvent ( ) 
    end 
) 

Link to comment

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...