PedClient

isPedInMeleeCombat

IS_PED_IN_MELEE_COMBAT0x4E209B2C1EAD5159

The GTA V native IS_PED_IN_MELEE_COMBAT of the PED namespace, as LS:MP client scripts call it: the global function isPedInMeleeCombat, in JavaScript and in Lua.

SignatureJavaScript
isPedInMeleeCombat(ped: Ped): boolean
SignatureLua
isPedInMeleeCombat(ped: Ped): boolean

Usage

JavaScript
const result = isPedInMeleeCombat(ped);
Lua
local result = isPedInMeleeCombat(ped)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger

Returns

BOOL JavaScript boolean, Lua boolean

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Notes: The function only returns true while the ped is:
A.) Swinging a random melee attack (including pistol-whipping)

B.) Reacting to being hit by a melee attack (including pistol-whipping)

C.) Is locked-on to an enemy (arms up, strafing/skipping in the default fighting-stance, ready to dodge+counter).

You don't have to be holding the melee-targetting button to be in this stance; you stay in it by default for a few seconds after swinging at someone. If you do a sprinting punch, it returns true for the duration of the punch animation and then returns false again, even if you've punched and made-angry many peds

Reference

Namespace
Ped PED
In the game
BOOL IS_PED_IN_MELEE_COMBAT(Ped ped)
Hash
0x4E209B2C1EAD5159

Open in the interactive natives reference