FiGo Posted January 20, 2020 Share Posted January 20, 2020 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 Link to comment
FiGo Posted January 20, 2020 Author Share Posted January 20, 2020 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 Link to comment
Moderators Patrick Posted January 20, 2020 Moderators Share Posted January 20, 2020 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) 1 Link to comment
FiGo Posted January 20, 2020 Author Share Posted January 20, 2020 (edited) 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 January 20, 2020 by FiGo Link to comment
Moderators Patrick Posted January 20, 2020 Moderators Share Posted January 20, 2020 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) Link to comment
FiGo Posted January 20, 2020 Author Share Posted January 20, 2020 still did not work + when I hit the car the car get fixes but while I am standing it doesn't increase alone Link to comment
Moderators Patrick Posted January 20, 2020 Moderators Share Posted January 20, 2020 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) Link to comment
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