Jump to content

Check Vehicle Health


gerlachmax123

Recommended Posts

Posted

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.

Posted

client;

function getVehHealt() 
getElementHealth ( getPedOccupiedVehicle ( getLocalPlayer() ) 
end 

server;

function getVehHealt() 
getElementHealth ( getPedOccupiedVehicle ( source ) 
end 

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

Posted
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?

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

Posted (edited)
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
Posted
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 ) 

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

This works serverside?

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

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

Posted
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) 

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