gta.createObject

Revision as of 18:58, 15 June 2026 by Mex (talk | contribs)

Function Server and Client GTAIII Logo.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Server 1.0.0, Client 1.0.0
Object gta.createObject(int model, Vec3 position)
The gta.createObject function is used to create a visual object for the local client.

Parameters

1) int model The model ID for the object.
2) Vec3 position The 3D position for the object. Server only.

Return

Object An object representing the visual game object that was created.

Notes

There aren't any notes for this function.

Examples

Example 1 - Lua:

object = gta.createObject(1335, Vec3(1062.316, -662.653, 14.652))
if object ~= nil then
    object.heading = 1.5922862291336
end


Example 2 - JavaScript - Server-Side:

addCommandHandler("object", (command, text, client) =>
{
    if (!client.player)
    {
        messageClient('You are not spawned!', client);
        return;
    }

	let model = text.length > 0 ? parseInt(text) : 583;
    if (isNaN(model))
    {
        messageClient('Invalid model ID: ' + text, client);
        return;
    }
    
	let object = gta.createObject(model, client.player.position.addPolar(15.0, client.player.heading + (Math.PI/2.0)));
    object.heading = client.player.heading;
	message(client.name + ' added an object with model ID ' + model, COLOUR_GREEN)
});


Example 3 - JavaScript - Client-Side:

addCommandHandler("object", (command, text) =>
{
    if (!localClient.player)
    {
        message('You are not spawned!');
        return;
    }

	let model = text.length > 0 ? parseInt(text) : 583;
    if (isNaN(model))
    {
        message('Invalid model ID: ' + text);
        return;
    }

	let object = gta.createObject(model, localPlayer.position.addPolar(15.0, localPlayer.heading + (Math.PI/2.0)));
    object.heading = localPlayer.heading;
	message('You added an object with model ID ' + model, COLOUR_GREEN)
});

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

getObjectCount
        getObjects
        gta.createObject
registerNetObject

        object.children
        object.clearExistsFor
        object.dimension
        object.existsFor
        object.getData
        object.getRotation
        object.heading
        object.id
        object.interior
        object.isCreatedFor
        object.isLocal
        object.isOwner
        object.isSyncer
        object.isType
        object.matrix
        object.modelIndex
        object.name
        object.netFlags
        object.parent
        object.position
        object.removeAllData
        object.removeData
        object.resource
        object.rotation
        object.setData
        object.setExistsFor
        object.setRotation
        object.setSyncer
        object.streamInDistance
        object.streamOutDistance
        object.syncer
        object.syncerId
        object.turnVelocity
        object.type
        object.velocity


Client Related

getObjectCount
        getObjects
gta.convertAllObjectsToDummyObjects
        gta.createObject
gta.removeWorldObject
gta.setVisibilityOfClosestObjectOfType
registerNetObject

        object.affectedByGravity
  object.alpha
      object.boundingCentre
        object.boundingMax
        object.boundingMin
        object.boundingRadius
        object.centerOfMass
        object.children
        object.clearExistsFor
        object.collisionBoxCount
        object.collisionBoxes
        object.collisionLineCount
        object.collisionLines
      object.collisionPower
        object.collisionsEnabled
        object.collisionSphereCount
        object.collisionSpheres
        object.collisionVertexCount
      object.collisionVertices
        object.dimension
      object.distanceFromCentreOfMassToBaseOfModel
        object.existsFor
        object.getData
        object.getRotation
        object.heading
object.health
        object.id
        object.interior
object.inWater
        object.isCreatedFor
object.island
        object.isLocal
        object.isOnScreen
        object.isOwner
        object.isSyncer
        object.isType
      object.markAsNoLongerNeeded
        object.mass
        object.matrix
object.model
        object.modelIndex
        object.name
        object.netFlags
object.onScreen
        object.parent
        object.position
        object.removeAllData
        object.removeData
        object.resource
        object.rotation
        object.setData
        object.setExistsFor
        object.setProofs
        object.setRotation
        object.setSyncer
      object.status
        object.streamInDistance
        object.streamOutDistance
        object.syncer
        object.syncerId
        object.turnVelocity
        object.type
        object.velocity
object.visible