GetElementHealth: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float getElementHealth ( element theElement ) | float getElementHealth ( element theElement ) | ||
Line 14: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns a float indicating the element's health, or ''false'' if invalid arguments were passed. | Returns a float indicating the element's health, or ''false'' if invalid arguments were passed. | ||
==Example== | ==Example== | ||
Line 26: | Line 24: | ||
-- get the player's vehicle: if he is in one, output its health as well | -- get the player's vehicle: if he is in one, output its health as well | ||
local playerVehicle = | local playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) | ||
if playerVehicle then | if playerVehicle then | ||
local vehicleHealth = getElementHealth ( playerVehicle ) | local vehicleHealth = getElementHealth ( playerVehicle ) |
Revision as of 12:49, 19 May 2010
This function returns the current health for the specified element. This can be a player, a ped, or a vehicle.
Syntax
float getElementHealth ( element theElement )
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 ( getLocalPlayer() ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) outputChatBox ( "Your vehicle's health: " .. vehicleHealth ) end end addCommandHandler ( "showhealth", showLocalHealth )
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement