ObjectClient

createObject

CREATE_OBJECT0x509D5878EB39E842

The GTA V native CREATE_OBJECT of the OBJECT namespace, as LS:MP client scripts call it: the global function createObject, in JavaScript and in Lua.

SignatureJavaScript
createObject(
  modelHash: Hash,
  x: number,
  y: number,
  z: number,
  isNetwork: boolean,
  bScriptHostObj: boolean,
  dynamic: boolean
): Object
SignatureLua
createObject(
  modelHash: Hash,
  x: number,
  y: number,
  z: number,
  isNetwork: boolean,
  bScriptHostObj: boolean,
  dynamic: boolean
): Object

Usage

JavaScript
const object = createObject(modelHash, x, y, z, isNetwork, bScriptHostObj, dynamic);
Lua
local object = createObject(modelHash, x, y, z, isNetwork, bScriptHostObj, dynamic)

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 object = createObject(modelHash, pos, isNetwork, bScriptHostObj, dynamic);
Lua · with vectors
local object = createObject(modelHash, pos, isNetwork, bScriptHostObj, dynamic)

Parameters

ParameterTypeJavaScriptLua
modelHashHashnumberinteger
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber
isNetworkBOOLbooleanboolean
bScriptHostObjBOOLbooleanboolean
dynamicBOOLbooleanboolean

Returns

Object JavaScript number, Lua integer

Game handle of an object (prop). Not an LS:MP netId. Convert one with lsmp.getEntityFromNetId.

Notes

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

List of object models that can be created without any additional effort like making sure ytyp is loaded etc: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/ObjectList.ini

Reference

Namespace
Object OBJECT
In the game
Object CREATE_OBJECT(Hash modelHash, float x, float y, float z, BOOL isNetwork, BOOL bScriptHostObj, BOOL dynamic)
Hash
0x509D5878EB39E842

Open in the interactive natives reference