onPedDamage | Multi Theft Auto: Wiki Skip to content

onPedDamage

Client-side
Server-side
Shared

This event is triggered when a ped is damaged. For player damage, use onPlayerDamage instead.

This event is not triggered prior to r21247.

Parameters

float loss
  • loss: an int representing the percentage of health the ped lost.

Source

element: The source of this event is the ped that got damaged.

Canceling

Canceling this event has no effect. Cancel the client-side event onClientPedDamage instead.

Code Examples

server

This example outputs a message to the console when a specific ped is damaged.

local ped1 = createPed(112, 0, 0, 0) -- create our ped
function pedDamaged(loss)
outputConsole("ped1 damaged! loss: " .. tostring(loss))
end
addEventHandler("onPedDamage", ped1, pedDamaged) -- triggered only when ped1 gets damaged

See Also