Jump to content

Check Vehicle Health


gerlachmax123

Recommended Posts

How I can check the Vehicle Health?

I have it serverside online but getElementHealth must be clientside :(

function reparierungszieltut(thePlayer) 
        if ( getElementHealth(pruefungsrepVehicle) == 800 ) then 
                outputChatBox ( "Nice Job!", player, 125, 0, 0 ) 
        destroyElement(pruefungsrepVehicle) 
        setElementPosition ( player, 1172.158, 1350.906, 10.922 ) 
                setElementDimension ( player, 0 )  
        end 
end 

Pleas help me.

Link to comment
function reparierungszieltut(thePlayer) 
        if ( getElementHealth(pruefungsrepVehicle) == 800 ) then 
                outputChatBox ( "Nice Job!", player, 125, 0, 0 ) 
        destroyElement(pruefungsrepVehicle) 
        setElementPosition ( player, 1172.158, 1350.906, 10.922 ) 
                setElementDimension ( player, 0 ) 
        end 
end 

Ok, when the car (pruefungsrepVehicle) set on 800 then

outputChatBox ( "Nice Job!", player, 125, 0, 0 )

But it will come not ....

Link to comment
function reparierungszieltut(thePlayer) 
        if ( getElementHealth(pruefungsrepVehicle) == 800 ) then 
                outputChatBox ( "Nice Job!", player, 125, 0, 0 ) 
        destroyElement(pruefungsrepVehicle) 
        setElementPosition ( player, 1172.158, 1350.906, 10.922 ) 
                setElementDimension ( player, 0 ) 
        end 
end 

Ok, when the car (pruefungsrepVehicle) set on 800 then

outputChatBox ( "Nice Job!", player, 125, 0, 0 )

But it will come not ....

Where is the event or whatever the way you calling the function reparierungszieltut?

Link to comment
function reparierungszieltut(thePlayer) 
        if ( getElementHealth(pruefungsrepVehicle) == 800 ) then 
                outputChatBox ( "Nice Job!", player, 125, 0, 0 ) 
        destroyElement(pruefungsrepVehicle) 
        setElementPosition ( player, 1172.158, 1350.906, 10.922 ) 
                setElementDimension ( player, 0 ) 
        end 
end 

Ok, when the car (pruefungsrepVehicle) set on 800 then

outputChatBox ( "Nice Job!", player, 125, 0, 0 )

But it will come not ....

Where is the event or whatever the way you calling the function reparierungszieltut?

he can use timer to check that.

Link to comment
how?
function reparierungszieltut() 
    if ( getElementHealth ( getPedOccupiedVehicle ( source ) ) == 800 ) then 
        -- your code goes here 
    end 
end 
setTimer ( reparierungszieltut, 1000, 0 ) 

this check player's healt in every 1 second.

Edited by Guest
Link to comment
Can i change the "source" to "pruefungsrepVehicle" ?

you can;

function reparierungszieltut(pruefungsrepVehicle) 
    if ( getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) ) == 800 ) then 
        -- your code goes here 
    end 
end 
setTimer ( reparierungszieltut, 1000, 0 ) 

Link to comment
function reparierungszieltut(pruefungsrepVehicle) 
    if ( getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) ) == 800 ) then 
        -- your code goes here 
    end 
end 
setTimer ( reparierungszieltut, 1000, 0 ) 

This works serverside?

yes, its for server-side.

Link to comment
tt = setTimer(function() 
    if isElement(pruefungsrepVehicle) and getElementHealth(pruefungsrepVehicle) <= 800 then 
        local player = getVehicleController(pruefungsrepVehicle) 
        if player then 
            if isTimer(tt) then killTimer(tt) end 
            destroyElement(pruefungsrepVehicle) 
            outputChatBox("Nice Job!", player, 125, 0, 0) 
            setElementPosition(player, 1172.158, 1350.906, 10.922) 
            setElementDimension(player, 0) 
        end 
    end 
end, 3000, 0) 

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