Difference between revisions of "EngineGetModelTextures"

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
===Required Arguments===
 
===Required Arguments===
 
*'''model''': either the model ID or model name.
 
*'''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===

Revision as of 16:36, 12 June 2020

BETA: FROM VERSION 1.5.7 r20416 ONWARDS
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

See Also

BETA: FROM VERSION 1.5.8 r20704 ONWARDS
BETA: FROM VERSION 1.5.8 r20704 ONWARDS
BETA: FROM VERSION 1.5.8 r20704 ONWARDS