Lloyd Logan Posted January 27, 2013 Share Posted January 27, 2013 Hey, is this piece of code correct? local health = getElementHealth( thePlayer ) if (health=<50) then I am not sure about the second line? WHat the layout of that should be? Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Perfect! How would i get the health of a vehicle! Thanks Link to comment
TAPL Posted January 27, 2013 Share Posted January 27, 2013 Perfect! How would i get the health of a vehicle!Thanks getElementHealth: This function returns the current health for the specified element. This can be a player, a ped, or a vehicle. Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Perfect! How would i get the health of a vehicle!Thanks getElementHealth: This function returns the current health for the specified element. This can be a player, a ped, or a vehicle. I done this but it always says Your car is fine? even if my car is on fire. function healthin( thePlayer ) local vehiclee = getPedOccupiedVehicle( thePlayer ) if vehiclee then local health = getElementHealth( vehiclee ) if (health<=50) then outputChatBox("Time For a repair!", thePlayer) else outputChatBox("Your car is fine!", thePlayer) end else outputChatBox("You're not in a vehicle!", thePlayer) end end addCommandHandler("carh", healthin) Link to comment
TAPL Posted January 27, 2013 Share Posted January 27, 2013 The vehicle health is from 1000 not 100. Link to comment
DNL291 Posted January 27, 2013 Share Posted January 27, 2013 function healthin( thePlayer ) local vehiclee = getPedOccupiedVehicle( thePlayer ) if vehiclee then local health = getElementHealth( vehiclee ) if (health<=500) then outputChatBox("Time For a repair!", thePlayer) else outputChatBox("Your car is fine!", thePlayer) end else outputChatBox("You're not in a vehicle!", thePlayer) end end addCommandHandler("carh", healthin) Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Thanks, is health out of 1000? Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 Max vehicle health is 1000%. Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Max vehicle health is 1000%. Is there anyway to change the health value to 100 instead of 1000, so it would be /setcarhp 100? Link to comment
TAPL Posted January 27, 2013 Share Posted January 27, 2013 Max vehicle health is 1000%. Is there anyway to change the health value to 100 instead of 1000, so it would be /setcarhp 100? With math you can do it: 10*100 will do the job. Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Max vehicle health is 1000%. Is there anyway to change the health value to 100 instead of 1000, so it would be /setcarhp 100? With math you can do it: 10*100 will do the job. So, calculate in my script, that if a player enters /setcarhp 100, just multiply the 100 by 10?, and if so, how would I do this? Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 Yes, that's right. setElementHealth ( theVehicle, amount * 10 ) Link to comment
TAPL Posted January 27, 2013 Share Posted January 27, 2013 Don't forget to use tonumber when you use addCommandHandler, because the argument will be in string. Link to comment
Lloyd Logan Posted January 27, 2013 Author Share Posted January 27, 2013 Thanks guys!! 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