engineLoadCOL
Client-side
Server-side
Shared
This function loads a RenderWare Collision (COL 1/2/3) file into GTA. The collisions can then be used to provide collisions for in-game objects.
Note
- For vehicles, please omit this function by embedding your COL file into your DFF file. This way, you can be sure that the COL file is correctly (and automatically) loaded when calling engineLoadDFF.
- Follow loading order ( COL -> TXD -> DFF ) as other orders can cause collisions, textures or the DFF not to load.
- Collision libraries (.col files containing multiple collision models) are not supported. See COL for details. Or you can try
This custom function to get the collision data from the col library
local matchedCOLVer = {COLL = "COLL", COL2 = "COL2", COL3 = "COL3"}function engineGetCOLsFromLibrary(file)assert(type(file) == "string", "Bad argument @'engineGetCOLsFromLibrary' expected a string at argument 1, got " ..type(file))if fileExists(file) then -- COL Librarylocal f = fileOpen(file)local str = fileRead(f, fileGetSize(f))fileClose(f)return engineGetCOLsFromLibrary(str)elselocal cols = {}while true dolocal colVer = file:sub(1, 4)if matchedCOLVer[colVer] thenlocal a, b, c, d = file:byte(5, 8)local colSize = a + b * 0x100 + c * 0x10000 + d * 0x1000000local col = file:sub(1, colSize + 8)local colName = col:sub(9, 29)local zeroPoint = colName:find("\0")cols[colName:sub(1, zeroPoint - 1)] = colfile = file:sub(colSize + 9)elsebreakendendreturn colsendend
OOP Syntax Help! I don't understand this!
- Constructor: EngineCOL (...)
Syntax
col|false engineLoadCOL ( string filePath/rawData )Required Arguments
- filePath/rawData: The filepath to the COL file you want to load or whole data buffer of the COL file.
Returns
- col|false: collision element
Returns a COL if the file was loaded, false otherwise.
Code Examples
client
local col = engineLoadCOL("trashcan.col")engineReplaceCOL(col, 1337)Changelog
Added option to use raw data instead of a file path.
See Also
Engine Functions
- engineAddClothingModelNew
- engineAddClothingTXDNew
- engineAddImageNew
- engineApplyShaderToWorldTexture
- engineFreeModel
- engineFreeTXDNew
- engineGetModelFlagsNew
- engineGetModelIDFromName
- engineGetModelLODDistance
- engineGetModelNameFromID
- engineGetModelPhysicalPropertiesGroup
- engineGetModelTextureNames
- engineGetModelTextures
- engineGetModelTXDIDNew
- engineGetModelVisibleTime
- engineGetObjectGroupPhysicalProperty
- engineGetPoolCapacityNew
- engineGetPoolDefaultCapacityNew
- engineGetPoolUsedCapacityNew
- engineGetSurfaceProperties
- engineGetVisibleTextureNames
- engineImageGetFileNew
- engineImageGetFilesNew
- engineImageGetFilesCountNew
- engineImageLinkDFFNew
- engineImageLinkTXDNew
- engineImportTXD
- engineLoadCOL
- engineLoadDFF
- engineLoadIFP
- engineLoadIMGNew
- engineLoadTXD
- enginePreloadWorldAreaNew
- engineRemoveImageNew
- engineRemoveShaderFromWorldTexture
- engineReplaceAnimation
- engineReplaceCOL
- engineReplaceModel
- engineRequestModel
- engineRequestTXDNew
- engineResetModelFlagsNew
- engineResetModelLODDistance
- engineResetModelTXDIDNew
- engineResetSurfaceProperties
- engineRestoreAnimation
- engineRestoreCOL
- engineRestoreDFFImageNew
- engineRestoreModel
- engineRestoreModelPhysicalPropertiesGroup
- engineRestoreObjectGroupPhysicalProperties
- engineRestoreTXDImageNew
- engineRestreamNew
- engineRestreamModelNew
- engineRestreamWorldUpdated
- engineSetAsynchronousLoading
- engineSetModelFlagNew
- engineSetModelFlagsNew
- engineSetModelLODDistanceUpdated
- engineSetModelPhysicalPropertiesGroupUpdated
- engineSetModelTXDIDNew
- engineSetModelVisibleTime
- engineSetObjectGroupPhysicalProperty
- engineSetPoolCapacityNew
- engineSetSurfaceProperties
- engineStreamingFreeUpMemory
- engineStreamingGetBufferSizeNew
- engineStreamingGetMemorySizeNew
- engineStreamingGetModelLoadStateNew
- engineStreamingGetUsedMemory
- engineStreamingReleaseModelNew
- engineStreamingRequestModelNew
- engineStreamingRestoreBufferSizeNew
- engineStreamingRestoreMemorySizeNew
- engineStreamingSetBufferSizeNew
- engineStreamingSetMemorySizeNew
- engineStreamingSetModelCacheLimitsNew