GetClothesByTypeIndex

From Multi Theft Auto: Wiki
Revision as of 13:38, 25 July 2006 by MrJax (talk | contribs)
Jump to navigation Jump to search

This function is used to get the texture and model of clothes by the clothes type and index. (Scans through the list of clothes for the specific type).

Syntax

string string getClothesByTypeIndex ( int clothesType, int clothesIndex )

Required Arguments

  • clothesType: An integer representing the clothes slot/type to scan through.
  • clothesIndex: An integer representing the index (nth) set of clothes in the list you wish to retrieve.

Returns

This function returns 2 strings, a texture and model if found, 'false' otherwise.

Example

This example gets the current clothes of a certain type on a player, then swaps with the next in the clothes list.

addCommandHandler ( "nextClothes", "nextClothes" )
function nextClothes ( player, key, clothesType )
  currentTexture, currentModel = getPlayerClothes ( source, clothesType ) -- get the current clothes of this type
  clothesIndex = -1
  if ( currentTexture ) then -- if this clothes slot wasn't empty
    tempA, tempB = getTypeIndexFromClothes ( currentTexture, currentModel ) -- get the type and index for these clothes, so we can increase it to get the next set in the list
    if ( tempA and tempB ) then -- if we found them
      clothesType, clothesIndex = tempA, tempB
    end
  end
  clothesIndex = clothesIndex + 1 -- increase to the next set
  texture, model = getClothesByTypeIndex ( type, index ) -- our new texture and model
  if ( texture == currenttexture ) then -- if they are the same (the last in the list)
    texture, model = getClothesByTypeIndex ( type, 0 ) -- get the first in the list
  end
  setPlayerClothes ( source, texture, model, type )
end

See Also