createObject
CREATE_OBJECT0x509D5878EB39E842The 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.
createObject(
modelHash: Hash,
x: number,
y: number,
z: number,
isNetwork: boolean,
bScriptHostObj: boolean,
dynamic: boolean
): ObjectcreateObject(
modelHash: Hash,
x: number,
y: number,
z: number,
isNetwork: boolean,
bScriptHostObj: boolean,
dynamic: boolean
): ObjectUsage
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
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
modelHash | Hash | number | integer |
x | float | number | number |
y | float | number | number |
z | float | number | number |
isNetwork | BOOL | boolean | boolean |
bScriptHostObj | BOOL | boolean | boolean |
dynamic | BOOL | boolean | boolean |
Returns
Object JavaScript number, Lua integerGame 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