botshara Posted November 27, 2013 Posted November 27, 2013 When I get out and enter in vehicle while he is damaged i can start engine, but before i damaged car and i had not get out of the car i could not start engine, why ? addCommandHandler( "toggleengine", function( player, commandName ) if exports.players:isLoggedIn( player ) then local vehicle = getPedOccupiedVehicle( player ) if vehicle and getVehicleOccupant( vehicle ) == player and doesVehicleHaveEngine( vehicle ) then local data = vehicles[ vehicle ] if data then if data.vehicleID < 0 or exports.sql:query_free( "UPDATE vehicles SET engineState = 1 - engineState WHERE vehicleID = " .. data.vehicleID ) then if math.floor( getElementHealth( vehicle ) + 0.5 ) > 301 then setVehicleEngineState( vehicle, not data.engineState ) data.engineState = not data.engineState else outputChatBox( "(( Vehicle motor is broken ))", player, 255, 0, 0 ) end end end end end end ) addEventHandler( "onVehicleDamage", root, function( loss ) if getElementHealth( source ) <= 301 then setElementHealth( source, 300 ) setVehicleDamageProof( source, true ) setVehicleEngineState( source, false ) if getVehicleOccupant( source ) then outputChatBox( "(( You broken your vehicle motor. ))", getVehicleOccupant( source ), 255, 204, 0 ) end end end ) addEventHandler( "onVehicleEnter", root, function( ) if isVehicleDamageProof( source ) and math.floor( getElementHealth( source ) + 0.5 ) > 301 then setVehicleDamageProof( source, false ) end end )
Castillo Posted November 27, 2013 Posted November 27, 2013 I don't really understand what is the problem.
botshara Posted November 27, 2013 Author Posted November 27, 2013 I have broken engine and i cant start engine but when i get out and then enter in vehicle i can start engine, where is the problem ?
Castillo Posted November 27, 2013 Posted November 27, 2013 addCommandHandler( "toggleengine", function( player, commandName ) if exports.players:isLoggedIn( player ) then local vehicle = getPedOccupiedVehicle( player ) if vehicle and getVehicleOccupant( vehicle ) == player and doesVehicleHaveEngine( vehicle ) then local data = vehicles[ vehicle ] if data then if data.vehicleID < 0 or exports.sql:query_free( "UPDATE vehicles SET engineState = 1 - engineState WHERE vehicleID = " .. data.vehicleID ) then if math.floor( getElementHealth( vehicle ) + 0.5 ) > 301 then setVehicleEngineState( vehicle, not data.engineState ) data.engineState = not data.engineState else outputChatBox( "(( Vehicle motor is broken ))", player, 255, 0, 0 ) end end end end end end ) addEventHandler( "onVehicleDamage", root, function( loss ) if getElementHealth( source ) <= 301 then setElementHealth( source, 300 ) setVehicleDamageProof( source, true ) setVehicleEngineState( source, false ) if getVehicleOccupant( source ) then outputChatBox( "(( You broken your vehicle motor. ))", getVehicleOccupant( source ), 255, 204, 0 ) end end end ) addEventHandler( "onVehicleEnter", root, function( ) if isVehicleDamageProof( source ) and math.floor( getElementHealth( source ) + 0.5 ) > 301 then setVehicleDamageProof( source, false ) else setVehicleEngineState( source, false ) end end ) Try it.
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