CreateBuilding: Difference between revisions
Jump to navigation
Jump to search
Fernando187 (talk | contribs) m (new note) |
Fernando187 (talk | contribs) m (add note about map limits (-3000 3000)) |
||
Line 3: | Line 3: | ||
{{New feature/item|3.0161|1.6.0|22410|Creates a [[building]] [[element]] at a given position and rotation.}} | {{New feature/item|3.0161|1.6.0|22410|Creates a [[building]] [[element]] at a given position and rotation.}} | ||
{{Note|Access the [[Building]] page to read more about how this feature works. '''Buildings support LOD models.'''}} | {{Note|Access the [[Building]] page to read more about how this feature works. '''Buildings support LOD models.'''}} | ||
{{Note|This function expects valid non-dynamic object model IDs. Check the examples below to understand how to validate the model ID before calling the function.}} | {{Note|This function can only create [[building|Buildings]] inside the regular GTA:SA map limits (X between -3000 and 3000; Y between -3000 and 3000). Use [[createObject]] to spawn objects outside the normal map boundaries.}} | ||
{{Note|This function expects valid non-dynamic object model IDs. Check the examples below to understand how to validate the model ID before calling the function. Use [[createObject]] to spawn dynamic objects.}} | |||
==Syntax== | ==Syntax== |
Revision as of 09:29, 14 October 2024
Syntax
building createBuilding ( int modelId, float x, float y, float z [, float rx, float ry, float rz, int interior = 0 ] )
OOP Syntax Help! I don't understand this!
- Method: Building(...)
Required Arguments
- modelId: A whole integer specifying the GTA:SA object model ID.
- 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. For more information on optional arguments, see optional arguments.
- rx: A floating point number representing the rotation about the X axis in degrees.
- ry: A floating point number representing the rotation about the Y axis in degrees.
- rz: A floating point number representing the rotation about the Z axis in degrees.
- interior: The interior you want to set the building to. Valid values are 0 to 255.
Returns
- Returns the building element if the creation was successful, throws an error otherwise.
Example
Click to collapse [-]
Validate building model IDThis example shows you how to easily verify if any object model ID is non-dynamic, so it can be used with the createBuilding function:
-- Dynamic object models will always have a physical properties group different than -1. local isNonDynamic = ( engineGetModelPhysicalPropertiesGroup(modelID) == -1 ) if isNonDynamic then -- createBuilding else -- createObject end
Click to collapse [-]
Simple exampleThis example creates a building when the resource starts:
function loadMap() -- 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 end addEventHandler("onClientResourceStart", resourceRoot, loadMap)
See Also