GetTypeIndexFromClothes: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "previousClothes", "previousClothes" )
addCommandHandler ( "previousClothes", "previousClothes" )
function nextClothes ( player, key, clothesType )
function nextClothes ( thePlayer, key, clothesType )
   currentTexture, currentModel = getPlayerClothes ( source, clothesType ) -- get the current clothes on this slot
   currentTexture, currentModel = getPlayerClothes ( thePlayer, clothesType ) -- get the current clothes on this slot
   clothesIndex = 1
   clothesIndex = 1
   if ( currentTexture ) then -- if he had clothes of that type
   if ( currentTexture ) then -- if he had clothes of that type
Line 27: Line 27:
   clothesIndex = clothesIndex - 1
   clothesIndex = clothesIndex - 1
   texture, model = getClothesByTypeIndex ( type, index ) -- get the new texture and model
   texture, model = getClothesByTypeIndex ( type, index ) -- get the new texture and model
   setPlayerClothes ( source, texture, model, type )
   setPlayerClothes ( thePlayer, texture, model, type )
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 13:47, 25 July 2006

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

Syntax

int int getTypeIndexFromClothes ( string clothesTexture, string clothesModel )

Required Arguments

  • clothesTexture: A string determining the clothes texture that you wish to retrieve the type and index from.
  • clothesModel: A string determining the corresponding clothes model that you wish to retrieve the type and index from.

Returns

This function returns 2 integers, a type and index if found, 'false' otherwise.

Example

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

addCommandHandler ( "previousClothes", "previousClothes" )
function nextClothes ( thePlayer, key, clothesType )
  currentTexture, currentModel = getPlayerClothes ( thePlayer, clothesType ) -- get the current clothes on this slot
  clothesIndex = 1
  if ( currentTexture ) then -- if he had clothes of that type
    clothesType, clothesIndex = getTypeIndexFromClothes ( currentTexture, currentModel ) -- get the type and index of these clothes, so we can decrease and get the previous
  end
  clothesIndex = clothesIndex - 1
  texture, model = getClothesByTypeIndex ( type, index ) -- get the new texture and model
  setPlayerClothes ( thePlayer, texture, model, type )
end

See Also