GetElementHealth
From Multi Theft Auto: Wiki
This function returns the current health for the specified element. This can be a player, a ped, a vehicle, or an object.
Syntax
float getElementHealth ( element theElement )
OOP Syntax Help! I don't understand this!
- Method: element:getHealth(...)
- Variable: .health
- Counterpart: setElementHealth
Required Arguments
Returns
Returns a float indicating the element's health, or false if invalid arguments were passed.
Example
Click to collapse [-]
Clientside exampleThis example outputs the health of the player who enters the command 'showhealth', and their vehicle's health.
function showLocalHealth() -- get the player's health and output it local playerHealth = getElementHealth ( localPlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( localPlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth ) end end addCommandHandler ( "showhealth", showLocalHealth )
See Also
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementData
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementCollisionsEnabled
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementColShape
- getElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getElementsByType
- getElementsWithinColShape
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementVisibleTo
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement