Jump to content

Check Vehicle Health


SoundWave

Recommended Posts

Hey everyone i have a question :P

I have a /br function ==> it repairs your vehicle when you press /br

but it also repairs when the vehicle has 100% health

my question: Is there a way to check the vehicles health because i didn't find the code on mta wiki.

this means when a player types /br and his vehicle has 100% health it outputs in chatbox: Your vehicle doesn't need to be fixed.

Thanks in advance

Link to comment
function fixPlayerVeh ( ) 
        local veh = getPedOccupiedVehicle ( source ) 
        if (not veh) then return 
            if (getElementHealth(veh)) == 1000 then outputChatBox ( "Your Vehicle doesn't need to be fixed.", source )  -- not sure if this is max health (could be 100 or 1000) 
            else 
              fixVehicle ( veh ) 
            end 
        end 
    end 
end 
  
addEventHandler ( 'br', fixPlayerVeh ) 

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