Jump to content

Help


Lulz

Recommended Posts

Posted

Im creating speedometer and i have problem why event handler with getRootElement works but with localPlayer doesn't work

addEventHandler("onClientVehicleEnter", getRootElement(), showSpeedometer) 

Posted

Why do you want to bind it to the localPlayer if getRootElement() does the same trick. all you have to do is check if the first parameter equals to localPlayer.

Posted

When i use getRootElement() players that are not drivers see speedometer too even if i check that

  
function showSpeedometer(player, seat) 
    if seat == 0 then 
        addEventHandler("onClientPreRender", getRootElement(), Speedometer) 
    end 
end 
  

Posted
When i use getRootElement() players that are not drivers see speedometer too even if i check that

  
function showSpeedometer(player, seat) 
    if seat == 0 then 
        addEventHandler("onClientPreRender", getRootElement(), Speedometer) 
    end 
end 
  

try this;

addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer, seat )  
        if ( thePlayer == getLocalPlayer() and seat == 0 ) then 
            addEventHandler ( "onClientPreRender", getRootElement(), Speedometer ); 
        end 
    end 
); 

Make sure to make the same one for onClientVehicleExit but then with removeEventHandler.

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