createBuilding | Multi Theft Auto: Wiki Skip to content

createBuilding

Client-side
Server-side
Shared

Creates a building element at a given position & interior with a certain rotation.

Note

Unlike createObject, this function does not have an isLowLOD argument. When using setLowLODElement, the system will automatically define the building as a LOD.

Note
  • Some objects/buildings in interior 13 show in all interiors.
  • Buildings can only be created inside regular GTA:SA Map Boundaries (X between -3000 and 3000; Y between -3000 and 3000). Use createObject to spawn objects outside these normal limits. This limitation is probably going to stop existing in the near future.
  • Buildings cannot appear in certain a Dimension, and not show in others. Function setElementDimension returns false on any building. A building is created in a specific Interior world (such as 0, the main world), like the default GTA:SA landscape objects. All buildings appear in EVERY DIMENSION.
  • There is a distinction in GTA: San Andreas between static and dynamic models (these use a separate streaming system). Examples of buildings include building models, roads, and terrain. Objects created as buildings can contain glass and shadows, unlike those created as objects (which are missing these features).
  • Buildings can be created with dynamic object model IDs, but they won't have any physical interaction. For example, object ID 1502 (Gen_doorINT04) is a door that can only be opened if created with createObject.
Tip
  • Using buildings for mapping is more optimized than using objects. Gains in FPS can be noticed in areas where a lot of objects were replaced with buildings of this new system.
  • Created buildings can have LOD models. The procedure is as follows: spawn the LOD building using createBuilding, then use setLowLODElement to associate it with the non-LOD building element you created beforehand. LOD model distance changed with engineSetModelLODDistance works for buildings.

OOP Syntax Help! I don't understand this!

Syntax

building createBuilding ( int modelId, float x, float y, float z, [ float rx = 0, float ry = 0, float rz = 0, int interior = 0 ] )
Required Arguments
  • modelId: A whole integer specifying the GTA:SA object model ID. See Object IDs for a list of model IDs.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • rx (default: 0): A floating point number representing the rotation about the X axis in degrees.
  • ry (default: 0): A floating point number representing the rotation about the Y axis in degrees.
  • rz (default: 0): A floating point number representing the rotation about the Z axis in degrees.
  • interior (default: 0): The interior you want to set the building to. Valid values are 0 to 255.

Returns

  • building: building element

Returns the building element if the creation was successful, throws an error otherwise.

Code Examples

shared

This example creates a building when the resource starts.

-- create a *building* at a specified position with a specified rotation
createBuilding(4550, 1985, -2544, 94, 0,0,0) -- Maze Bank Tower in LS airport

Changelog

  • 1.6.0 r23232Added to the server side, thus the function is now shared.
  • See Also

    Building Functions
    • createBuilding