GetTypeIndexFromClothes: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
(13 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function is used to get the clothes type and index from the texture and model. | This function is used to get the clothes type and index from the texture and model. | ||
Line 11: | Line 10: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''clothesTexture''': A string determining the clothes texture that you wish to retrieve the type and index from. See [[clothes | *'''clothesTexture''': A string determining the clothes texture that you wish to retrieve the type and index from. See the [[CJ Clothes|clothes catalog]]. | ||
*'''clothesModel''': A string determining the corresponding clothes model that you wish to retrieve the type and index from. See [[clothes | *'''clothesModel''': A string determining the corresponding clothes model that you wish to retrieve the type and index from. See the [[CJ Clothes|clothes catalog]]. | ||
==Returns== | ==Returns== | ||
This function returns two integers, type and index respectively, 'false' if invalid arguments were passed to the function. | This function returns two integers, type and index respectively, ''false'' if invalid arguments were passed to the function. | ||
==Example== | ==Example== | ||
This example gets the current clothes of a certain type on a player, then swaps with the previous in the clothes list. | This example gets the current clothes of a certain type on a player, then swaps with the previous in the clothes list. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function scriptPreviousClothes ( thePlayer, key, clothesType ) | |||
function | local currentTexture, currentModel = getPedClothes ( thePlayer, clothesType ) -- get the current clothes on this slot | ||
currentTexture, currentModel = | local clothesIndex = 1 | ||
clothesIndex = 1 | |||
if ( currentTexture ) then -- if he had clothes of that type | if ( currentTexture ) then -- if he had clothes of that type | ||
local tempA, tempB = getTypeIndexFromClothes ( currentTexture, currentModel ) -- get the type and index for these clothes, so we can decrease and get the previous in the list | |||
if ( tempA and tempB ) then -- if we found them | |||
clothesType, clothesIndex = tempA, tempB | |||
end | |||
end | end | ||
clothesIndex = clothesIndex - 1 | clothesIndex = clothesIndex - 1 | ||
texture, model = getClothesByTypeIndex ( | local texture, model = getClothesByTypeIndex ( clothesType, clothesIndex ) -- get the new texture and model | ||
if ( texture == false ) then -- if we've reached the end of the list | |||
removePedClothes ( thePlayer, clothesType ) | |||
else addPedClothes ( thePlayer, texture, model, clothesType ) | |||
end | |||
end | end | ||
addCommandHandler ( "previousClothes", scriptPreviousClothes ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Clothes and body functions}} | {{Clothes and body functions}} | ||
[[hu:getTypeIndexFromClothes]] |
Latest revision as of 10:49, 22 September 2018
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. See the clothes catalog.
- clothesModel: A string determining the corresponding clothes model that you wish to retrieve the type and index from. See the clothes catalog.
Returns
This function returns two integers, type and index respectively, false if invalid arguments were passed to the function.
Example
This example gets the current clothes of a certain type on a player, then swaps with the previous in the clothes list.
function scriptPreviousClothes ( thePlayer, key, clothesType ) local currentTexture, currentModel = getPedClothes ( thePlayer, clothesType ) -- get the current clothes on this slot local clothesIndex = 1 if ( currentTexture ) then -- if he had clothes of that type local tempA, tempB = getTypeIndexFromClothes ( currentTexture, currentModel ) -- get the type and index for these clothes, so we can decrease and get the previous in the list if ( tempA and tempB ) then -- if we found them clothesType, clothesIndex = tempA, tempB end end clothesIndex = clothesIndex - 1 local texture, model = getClothesByTypeIndex ( clothesType, clothesIndex ) -- get the new texture and model if ( texture == false ) then -- if we've reached the end of the list removePedClothes ( thePlayer, clothesType ) else addPedClothes ( thePlayer, texture, model, clothesType ) end end addCommandHandler ( "previousClothes", scriptPreviousClothes )