MiscClient

isPositionOccupied

IS_POSITION_OCCUPIED0xADCDE75E1C60F32D

The GTA V native IS_POSITION_OCCUPIED of the MISC namespace, as LS:MP client scripts call it: the global function isPositionOccupied, in JavaScript and in Lua.

SignatureJavaScript
isPositionOccupied(
  x: number,
  y: number,
  z: number,
  range: number,
  p4: boolean,
  checkVehicles: boolean,
  checkPeds: boolean,
  p7: boolean,
  p8: boolean,
  ignoreEntity: Entity,
  p10: boolean
): boolean
SignatureLua
isPositionOccupied(
  x: number,
  y: number,
  z: number,
  range: number,
  p4: boolean,
  checkVehicles: boolean,
  checkPeds: boolean,
  p7: boolean,
  p8: boolean,
  ignoreEntity: Entity,
  p10: boolean
): boolean

Usage

JavaScript
const result = isPositionOccupied(
  x, y, z, range, p4, checkVehicles, checkPeds, p7, p8, ignoreEntity, p10
);
Lua
local result = isPositionOccupied(
    x, y, z, range, p4, checkVehicles, checkPeds, p7, p8, ignoreEntity, p10
)

Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.

JavaScript · with vectors
const result = isPositionOccupied(
  pos, range, p4, checkVehicles, checkPeds, p7, p8, ignoreEntity, p10
);
Lua · with vectors
local result = isPositionOccupied(
    pos, range, p4, checkVehicles, checkPeds, p7, p8, ignoreEntity, p10
)

Parameters

ParameterTypeJavaScriptLua
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber
rangefloatnumbernumber
p4BOOLbooleanboolean
checkVehiclesBOOLbooleanboolean
checkPedsBOOLbooleanboolean
p7BOOLbooleanboolean
p8BOOLbooleanboolean
ignoreEntityEntitynumberinteger
p10BOOLbooleanboolean

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.

range: The range, seems to not be very accurate during testing.
p4: Unknown, when set to true it seems to always return true no matter what I try.
checkVehicle: Check for any vehicles in that area.
checkPeds: Check for any peds in that area.
ignoreEntity: This entity will be ignored if it's in the area. Set to 0 if you don't want to exclude any entities.
The BOOL parameters that are documented have not been confirmed. They are just documented from what I've found during testing. They may not work as expected in all cases.

Returns true if there is anything in that location matching the provided parameters.

Reference

Namespace
Misc MISC
In the game
BOOL IS_POSITION_OCCUPIED(float x, float y, float z, float range, BOOL p4, BOOL checkVehicles, BOOL checkPeds, BOOL p7, BOOL p8, Entity ignoreEntity, BOOL p10)
Hash
0xADCDE75E1C60F32D

Open in the interactive natives reference