Jump to content

[help]crouched and standing


#RooTs

Recommended Posts

You could use bindKey()

  
-- "useful function", see [url=https://wiki.multitheftauto.com/wiki/BindControlKeys]https://wiki.multitheftauto.com/wiki/BindControlKeys[/url] 
bindControlKeys("crouch", "down", function() 
  if isPedDucked(localPlayer) then 
  -- ducked 
  else 
  -- unducked 
  end 
end) 
  

Have not tested (maybe isPedDucked does not return true immediately after pressing the button)

Alternatives for isPedDucked() though no reason to use these:

getPedMoveState(localPlayer) 
getPedTask(localPlayer, "secondary", 1) 

Link to comment

thanks man,i will try

bindControlKeys("crouch", "down", function() 
   if isPedDucked(localPlayer) then 
   dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, 'crouched.png', angle, 0, -120 ) 
   else 
   dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, 'standing.png', angle, 0, -120 ) 
   end 
end) 

that's right?

Link to comment
If you are using it on screen render event, then you don't need an event for couch-state-change indeed (assuming isPedDucking is not very expensive).
if  isPedDucked(localPlayer) then 
dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, 'crouched.png', angle, 0, -120 ) 
else 
dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, 'standing.png', angle, 0, -120 ) 
end 

just use this function within the render, that already works?

okay, I get it. Thanks :wink:

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