Jump to content

[help]actuated brake[solved] ;)


#RooTs

Recommended Posts

what is the function may I see if the vehicle It is with brake activated.

WP0GfpB.jpg

I wanted to do it in an "if"

EX

if function then 
dxDrawImage(....red image........ 
else 
dxDrawImage(...white image.... 
end 

I want to make sure it is activated or not in an "if function"

Thanks by help :wink:

Edited by Guest
Link to comment

If I recall correctly what I did for my ABS prototype, whenever a player connected I retrieved all the keys they had bound to the control "brake". Using getBoundKeys.

What you then can do is check that whenever a player is in a vehicle, whenever either of these keys are pressed down - draw the red one, otherwise draw the red one.

I'd give you my ABS prototype but I can't remember where I stored the uncompiled version. It might have been on my laptop which I formated :lol:

Link to comment

Using the information Hornet gave you, you'll be able to draw the image yourself. To make sure that they are updated at the same time as you press the handbrake/reverse you can put them in your onClientRender just like your other drawn things for your vehicle's GUI ( if you have any ).

I'm not sure if I understood your question, but you can try one of these control checkers.
if(getControlState("handbrake")) then end 
if(getControlState("brake_reverse")) then end 

To give you a small example, you can do something similar to this;

addEventHandler ( "onClientRender", root, 
    function () 
        if ( isPedInVehicle ( localPlayer ) ) then 
            if ( getControlState ( "handbrake" ) or getControlState ( "brake_reverse" ) ) then 
                -- draw the red image 
            else 
                -- draw the white image 
            end 
        end 
    end 
); 

Since this will always run in the background, I would strongly advise you to only add the onClientRender when the player actually enters a vehicle and turn it off when he leaves it.

function drawVehicleGUI () 
    if ( getControlState ( "handbrake" ) or getControlState ( "brake_reverse" ) ) then 
        -- draw the red image 
    else 
        -- draw the white image 
    end 
end 
  
addEventHandler ( "onClientVehicleEnter", root, 
    function ( thePlayer, seat ) 
        if ( seat == 0 ) then 
            addEventHandler ( "onClientRender", getRootElement(), drawVehicleGUI ); 
        end 
    end 
); 
  
addEventHandler ( "onClientVehicleExit", root, 
    function ( thePlayer, seat ) 
        if ( seat == 0 ) then 
            removeEventHandler ( "onClientRender", getRootElement(), drawVehicleGUI ); 
        end 
    end 
); 

Link to comment
function drawVehicleGUI () 
    if ( getControlState ( "handbrake" ) or getControlState ( "brake_reverse" ) ) then 
        -- draw the red image 
    else 
        -- draw the white image 
    end 
end 
  
addEventHandler ( "onClientVehicleEnter", root, 
    function ( thePlayer, seat ) 
        if ( seat == 0 ) then 
            addEventHandler ( "onClientRender", getRootElement(), drawVehicleGUI ); 
        end 
    end 
); 
  
addEventHandler ( "onClientVehicleExit", root, 
    function ( thePlayer, seat ) 
        if ( seat == 0 ) then 
            removeEventHandler ( "onClientRender", getRootElement(), drawVehicleGUI ); 
        end 
    end 
); 

Perfect example.

Link to comment

@tosfera and @Hornet, Thanks man.

Worked perfect :wink:

if ( getControlState ( "handbrake" ) or getControlState ( "brake_reverse" ) ) then 
        -- draw the red image 
    else 
        -- draw the white image 
    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...