CREATE_OBJECT_NO_OFFSET
Creates an object (prop) with the specified model centered at the specified position.
Signature
Entity CREATE_OBJECT_NO_OFFSET(Hash modelHash, float x, float y, float z, BOOL isNetwork, BOOL netMissionEntity, BOOL doorFlag);Parameters
| Name | Type | Description |
|---|---|---|
modelHash | Hash | The model to spawn. |
x | float | Spawn coordinate X component. |
y | float | Spawn coordinate Y component. |
z | float | Spawn coordinate Z component. |
isNetwork | BOOL | Whether to create a network object for the object. If false, the object exists only locally. |
netMissionEntity | BOOL | Whether to register the object as pinned to the script host in the R* network model. |
doorFlag | BOOL | False to create a door archetype (archetype flag bit 26 set) as a door. Required to be set to true to create door models in network mode. |
Returns Entity — A script handle (fwScriptGuid index) for the object, or `0` if the object failed to be created.
Description
Creates an object (prop) with the specified model centered at the specified position. This object will initially be owned by the creating script as a mission entity, and the model should be loaded already (e.g. using REQUEST_MODEL).
This is the server-side RPC native equivalent of the client native CREATE_OBJECT_NO_OFFSET.
Usage
local retval = CreateObjectNoOffset(modelHash, x, y, z, isNetwork, netMissionEntity, doorFlag)
-- always works, by hash
local retval = Citizen.InvokeNative(0x58040420, modelHash, x, y, z, isNetwork, netMissionEntity, doorFlag, Citizen.ResultAsInteger())JavaScript and C#
const retval = CreateObjectNoOffset(modelHash, x, y, z, isNetwork, netMissionEntity, doorFlag);
// by hash
const retval = Citizen.invokeNative('0x58040420', modelHash, x + 0.0000001, y + 0.0000001, z + 0.0000001, isNetwork, netMissionEntity, doorFlag, Citizen.returnResultAnyway(), Citizen.resultAsInteger());int retval = Function.Call<int>((Hash)0x58040420, modelHash, x, y, z, isNetwork, netMissionEntity, doorFlag);- Hash parameters: the named function also accepts a string and hashes it for you;
Citizen.InvokeNativeneeds the number — passjoaat("name")or a backtick literal like`name`. - Float parameters: Lua integers (
10, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write10.0orvalue + 0.0. The generated JS wrappers add0.0000001to non-zero floats for the same reason.
Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.