ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setElementHealth

Function

setElementHealth

Server and clientElementsIdentical to MTA:SA

Sets an element's health. 0 kills a player or ped and fires onPlayerWasted / onPedWasted.

Syntax

bool setElementHealth(element theElement, float newHealth)

Arguments

theElementelement
The element.
newHealthfloat
New health.

Returns

true on success.

Example

addCommandHandler("ulecz", function(player)
    setElementHealth(player, 100)
    local veh = getPedOccupiedVehicle(player)
    if veh then setElementHealth(veh, 1000) end
end)

See also