dragonofdark Posted June 17, 2011 Share Posted June 17, 2011 Hello, I would like to make an automatic radar wich fade the player's screen for 0.5 secondes if his vehicle's speed is > than 90 km/h. I took the code wich calculate the vehicle's speed in km/h in the MTA-paradise speedometer but it seem to dont work. Here is my code : myMarker1 = createMarker(1630.8,154.3,34.1,"cylinder",15,255,255,10,0) function MarkerHit1 ( hitElement, matchingDimension ) if getElementType( hitElement ) == "vehicle" then vehicle = hitElement controller = getVehicleController ( vehicle ) speed = ( function( x, y, z ) return math.floor( math.sqrt( x*x + y*y + z*z ) * 155 ) end )( getElementVelocity( vehicle ) ) function vitesse () if speed then if speed > 90 then function flash (controller) fadeCamera ( controller, false, 1.0, 0, 0, 0, 255 ) setTimer ( fadeCamera, 500, 0.5, controller, true, 0.5) end end end end end end addEventHandler( "onMarkerHit", myMarker1, MarkerHit1 ) My screen don't fade if I pass at 110mk/h on the marker. Could you help me ? Thanks. Link to comment
Aibo Posted June 17, 2011 Share Posted June 17, 2011 because your "vitesse" function is never called. and why are creating yet another function inside that function and never call it either? you dont need to create a function every line, you know. myMarker1 = createMarker(1630.8,154.3,34.1,"cylinder",15,255,255,10,0) function MarkerHit1 ( hitElement, matchingDimension ) if getElementType( hitElement ) == "vehicle" then local vehicle = hitElement local controller = getVehicleController ( vehicle ) local speed = ( function( x, y, z ) return math.floor( math.sqrt( x*x + y*y + z*z ) * 155 ) end )( getElementVelocity( vehicle ) ) if speed and speed > 90 then fadeCamera ( controller, false, 1.0, 0, 0, 0, 255 ) setTimer ( fadeCamera, 500, 0.5, controller, true, 0.5) end end end addEventHandler( "onMarkerHit", myMarker1, MarkerHit1 ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now