FiGo

help plz

Recommended Posts

CarModel = getElementModel ( 516 )
If ( CarModel = 516 ) then
CarHP = getElementHealth( 516 )
if ( CarHP < 90 ) then
setElementHealth ( 516, CarHP + 5 )

 

why this function for car health increase when it get damaged why it doesn't work

Share this post


Link to post

I changed it and it doesn't work

 

function fix()
   CarHP = getElementHealth(source)
    if ( getElementModel(source) == 451 ) then
    if ( CarHP < 90 ) then
        setElementHealth ( source, 100 )
    end
end
end
addEventHandler("onClientVehicleDamage", root, fix)

 

help plz

 

Share this post


Link to post

The maximum health of the vehicle is 1000, not 100, so:

 

-- CLIENT SIDE

function fix()
    local CarHP = getElementHealth(source) -- use as local variable, because you want to use this variable inside this function only
    
    if (getElementModel(source) == 451) then
        if (CarHP < 900) then
            setElementHealth(source, 1000)
        end
    end
end
addEventHandler("onClientVehicleDamage", root, fix)

 

  • Thanks 1

Share this post


Link to post

i added it but it donot work I need to make when the car got damaged it increases by +5 I mean if it is 90 it be 95 and like that until it becomes 100

Edited by FiGo

Share this post


Link to post
18 minutes ago, FiGo said:

i added it but it donot work I need to make when the car got damaged it increases by +5 I mean if it is 90 it be 95 and like that until it becomes 100

 

increase old health with 50

setElementHealth(source, CarHP + 50)

 

Share this post


Link to post

still did not work

 

+ when I hit the car the car get fixes but while I am standing it doesn't increase alone 

Share this post


Link to post
Just now, FiGo said:

still did not work

 

This "not work" is not a big help dude.

- Do you use this code on client side?

- Do you test it with Turismo? (id: 451)

Share this post


Link to post

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.