EngineGetModelTextures: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 67736 by Pirulax (talk))
Tag: Undo
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.5.7|20416|This function allows you to get the textures of any model.}}
{{New feature/item|3.0158|1.5.7|20416|This function allows you to get the textures of any model.}}


==Syntax==  
==Syntax==  
Line 35: Line 35:
</section>
</section>


==Requirements==
{{Requirements|n/a|1.5.7-9.20416|}}
==See Also==
==See Also==
{{Engine_functions}}
{{Engine_functions}}

Latest revision as of 19:48, 12 November 2020

This function allows you to get the textures of any model.

Syntax

table engineGetModelTextures( string/int modelName/modelID [, string/table textureNames ] )

Required Arguments

  • model: either the model ID or model name.

Optional Arguments

  • textureNames: Only return textures with specified name(s). You can provide a single string or a table of strings. Wildcard matching e.g. "ro?ds*" can be used.

Returns

Returns a table of texture elements [textureName, texture], false otherwise.

Example

Click to collapse [-]
Client

Get the textures for model ID 3722 and draw them with dxDrawImage.

function init()
	textures = engineGetModelTextures(3722)
	addEventHandler("onClientRender", root, render)
end
addEventHandler("onClientResourceStart", resourceRoot, init)

function render()
	local offset = 0
	for name,texture in pairs(textures) do
		local size = dxGetPixelsSize(dxGetTexturePixels(texture))
		dxDrawImage(0+offset, 0, size, size, texture)
		offset = offset + size
	end
end

Requirements

Minimum server version n/a
Minimum client version 1.5.7-9.20416

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.5.7-9.20416" />

See Also