SendNetworkDamage

Send a synthetic network damage event from a source entity to a target entity at a world position.

Syntax

Susano.SendNetworkDamage(source, target, posX, posY, posZ, damage [, weaponHash [, flags [, actionResultHash [, actionResultId [, actionUnk [, hitComponent]]]]]]) -> void

Parameters

source (int): Entity handle of the damage source (ped/vehicle/script ID).

target (int): Entity handle of the damage target (ped/vehicle/script ID).

posX, posY, posZ (number): World position of the hit.

damage (number): Damage amount, as a float.

weaponHash (int, optional): Weapon hash to attribute the damage to. Defaults to 0, which is replaced internally with GetHashKey("weapon_run_over_by_car").

flags (int, optional): Damage-event flag bitfield. Defaults to 522.

actionResultHash (int, optional): Action-result hash. Defaults to 0.

actionResultId (int, optional): Action-result ID (16-bit). Defaults to 0.

actionUnk (int, optional): Reserved action field. Defaults to 0.

hitComponent (int, optional): Body-part / hit-component index. Defaults to 0.

Return(s)

None

Behavior

Raises SendNetworkDamage: invalid source or target entity handle if either handle cannot be resolved to a live entity.

The internal direction vector is fixed at {0, 0, 0} and the four boolean flags at the tail of the underlying native are all sent as false.

Example(s)

-- Deal 50 damage to the closest ped with the default "run over by car" weapon hash
local me      = PlayerPedId()
local target  = GetClosestPed(GetEntityCoords(me))
local x, y, z = table.unpack(GetEntityCoords(target))

Susano.SendNetworkDamage(me, target, x, y, z, 50.0)
-- Attribute the damage to a specific weapon, with a custom flags value
local wpn = GetHashKey("weapon_pistol")
Susano.SendNetworkDamage(source, target, x, y, z, 100.0, wpn, 522)