engineRequestModel
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function is used to assign the next available model ID to a certain element type.
Vehicle unique features may be unsupported, see issue 1861 for examples and details
For most cases, you will probably want to add models to your server that are synced with all clients automatically. This is possible with this resource : newmodels
Unlike some other functions, the side-effects of this function aren't reverted on resource stop, so you must manually call engineFreeModel in onClientResourceStop (Just like the example below does)
parentID should be the same model type to prevent crashes.
Syntax
engineRequestModel ( )Code Examples
This example creates a ped and then gives you the opportunity to change its model. If the resource stops, then the IDs allocated will be deallocated. Use/capfor creating the ped and/sapto skin the ped. You will need some skins added to a folder and to the meta.xml for/sapto work:
local peds = {}function createAllocatedPed() local x, y, z = getElementPosition(localPlayer) local id = engineRequestModel("ped") peds[id] = createPed(id, x+0.5, y, z+0.5) outputChatBox("New ped with ID "..id.." created.")endaddCommandHandler("cap", createAllocatedPed, false, false)
function skinAllocatedPeds() local txd, dff; for id,ped in pairs(peds) do if fileExists("skins/" .. id .. ".txd") and fileExists("skins/" .. id .. ".dff") then txd = engineLoadTXD("skins/" .. id .. ".txd") engineImportTXD(txd, id) dff = engineLoadDFF("skins/" .. id .. ".dff") engineReplaceModel(dff, id) outputChatBox("Model ID "..id.." changed correctly.") else outputChatBox("Model ID "..id.." couldn't change. REASON: skins/" .. id .. ".txd or skins/" .. id .. ".dff does not exist.") end endendaddCommandHandler("sap", skinAllocatedPeds, false, false)
function onStop() for id,ped in pairs(peds) do engineFreeModel(id) endendaddEventHandler("onClientResourceStop", resourceRoot, onStop)See Also
Engine Functions
- engineAddClothingModel
- engineAddClothingTXD
- engineAddImage
- engineApplyShaderToWorldTexture
- engineFreeModel
- engineFreeTXD
- engineGetModelFlags
- engineGetModelIDFromName
- engineGetModelLODDistance
- engineGetModelNameFromID
- engineGetModelPhysicalPropertiesGroup
- engineGetModelTextureNames
- engineGetModelTextures
- engineGetModelTXDID
- engineGetModelVisibleTime
- engineGetObjectGroupPhysicalProperty
- engineGetPoolCapacity
- engineGetPoolDefaultCapacity
- engineGetPoolUsedCapacity
- engineGetSurfaceProperties
- engineGetVisibleTextureNames
- engineImageGetFile
- engineImageGetFiles
- engineImageGetFilesCount
- engineImageLinkDFF
- engineImageLinkTXD
- engineImportTXD
- engineLoadCOL
- engineLoadDFF
- engineLoadIFP
- engineLoadIMG
- engineLoadTXD
- enginePreloadWorldArea
- engineRemoveImage
- engineRemoveShaderFromWorldTexture
- engineReplaceAnimation
- engineReplaceCOL
- engineReplaceModel
- engineRequestModel
- engineRequestTXD
- engineResetModelFlags
- engineResetModelLODDistance
- engineResetModelTXDID
- engineResetSurfaceProperties
- engineRestoreAnimation
- engineRestoreCOL
- engineRestoreDFFImage
- engineRestoreModel
- engineRestoreModelPhysicalPropertiesGroup
- engineRestoreObjectGroupPhysicalProperties
- engineRestoreTXDImage
- engineRestreamWorld
- engineSetAsynchronousLoading
- engineSetModelFlag
- engineSetModelFlags
- engineSetModelLODDistance
- engineSetModelPhysicalPropertiesGroup
- engineSetModelTXDID
- engineSetModelVisibleTime
- engineSetObjectGroupPhysicalProperty
- engineSetPoolCapacity
- engineSetSurfaceProperties
- engineStreamingFreeUpMemory
- engineStreamingGetBufferSize
- engineStreamingGetMemorySize
- engineStreamingGetModelLoadState
- engineStreamingGetUsedMemory
- engineStreamingReleaseModel
- engineStreamingRequestModel
- engineStreamingRestoreBufferSize
- engineStreamingRestoreMemorySize
- engineStreamingSetBufferSize
- engineStreamingSetMemorySize
- engineStreamingSetModelCacheLimits