Jump to content

Hm, something wrong with setPedControlState?


Maurize

Recommended Posts

Posted
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?

Posted

@Maurize: That's because you have to use a timer to set it to false then to true.

@Jaysd1: You should have read his posts more carefully, he said that the ped only shoots once.

Posted

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 ) 
  

Posted

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 
) 

Posted

Yep exactly what i meant!:D Nice my punk ped is following me and if i hurt him he becames insane and beat the shit out of me:D my own "zombie" resource:D

Thanks friends youre the best!:)

Posted
Yep exactly what i meant!:D Nice my punk ped is following me and if i hurt him he becames insane and beat the :~ out of me:D my own "zombie" resource:D

Thanks friends youre the best!:)

:lol: :lol: :lol:

Nice, and np(even though I miss read :lol:)

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