GetClothesByTypeIndex: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addCommandHandler ( "nextClothes", "nextClothes" ) | addCommandHandler ( "nextClothes", "nextClothes" ) | ||
function nextClothes ( | function nextClothes ( thePlayer, key, clothesType ) | ||
currentTexture, currentModel = getPlayerClothes ( | currentTexture, currentModel = getPlayerClothes ( thePlayer, clothesType ) -- get the current clothes of this type | ||
clothesIndex = -1 | clothesIndex = -1 | ||
if ( currentTexture ) then -- if this clothes slot wasn't empty | if ( currentTexture ) then -- if this clothes slot wasn't empty | ||
Line 33: | Line 33: | ||
texture, model = getClothesByTypeIndex ( type, 0 ) -- get the first in the list | texture, model = getClothesByTypeIndex ( type, 0 ) -- get the first in the list | ||
end | end | ||
setPlayerClothes ( | setPlayerClothes ( thePlayer, texture, model, type ) | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 13:46, 25 July 2006
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 ( thePlayer, key, clothesType ) currentTexture, currentModel = getPlayerClothes ( thePlayer, 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 ( thePlayer, texture, model, type ) end
See Also
- addPedClothes
- getBodyPartName
- getClothesByTypeIndex
- getClothesTypeName
- getPedClothes
- getTypeIndexFromClothes
- removePedClothes