PedClient

setCanAttackFriendly

SET_CAN_ATTACK_FRIENDLY0xB3B1CB349FF9C75D

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

SignatureJavaScript
setCanAttackFriendly(ped: Ped, toggle: boolean, p2: boolean): void
SignatureLua
setCanAttackFriendly(ped: Ped, toggle: boolean, p2: boolean)

Usage

JavaScript
setCanAttackFriendly(ped, toggle, p2);
Lua
setCanAttackFriendly(ped, toggle, p2)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger
toggleBOOLbooleanboolean
p2BOOLbooleanboolean

Returns

Nothing. In JavaScript the call evaluates to undefined.

Notes

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

Setting ped to true allows the ped to shoot "friendlies".

p2 set to true when toggle is also true seams to make peds permanently unable to aim at, even if you set p2 back to false.

p1 = false & p2 = false for unable to aim at.
p1 = true & p2 = false for able to aim at.

Reference

Namespace
Ped PED
In the game
void SET_CAN_ATTACK_FRIENDLY(Ped ped, BOOL toggle, BOOL p2)
Hash
0xB3B1CB349FF9C75D

Open in the interactive natives reference