Lloyd Logan Posted January 27, 2013 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?
Lloyd Logan Posted January 27, 2013 Author Posted January 27, 2013 Perfect! How would i get the health of a vehicle! Thanks
TAPL Posted January 27, 2013 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.
Lloyd Logan Posted January 27, 2013 Author 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)
DNL291 Posted January 27, 2013 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)
Lloyd Logan Posted January 27, 2013 Author 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?
TAPL Posted January 27, 2013 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.
Lloyd Logan Posted January 27, 2013 Author 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?
Castillo Posted January 27, 2013 Posted January 27, 2013 Yes, that's right. setElementHealth ( theVehicle, amount * 10 )
TAPL Posted January 27, 2013 Posted January 27, 2013 Don't forget to use tonumber when you use addCommandHandler, because the argument will be in string.
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