PL/getTypeIndexFromClothes: Difference between revisions
Jump to navigation
Jump to search
ThePiotrek (talk | contribs) (Created page with "{{PL/Shared function}} __NOTOC__ Ta funkcja służy do uzyskania typu i indeksu ciuchu z tekstury i modelu/ (Skanuje listę ubrań). ==Składnia== <syntaxhighlight lang="lua"> int int getTy...") |
(No difference)
|
Revision as of 19:42, 19 July 2016
Ta funkcja służy do uzyskania typu i indeksu ciuchu z tekstury i modelu/ (Skanuje listę ubrań).
Składnia
int int getTypeIndexFromClothes ( string clothesTexture, string clothesModel )
Wymagane argumenty
- clothesTexture: Ciąg znaków oznaczający teksturę ubrania którego indeks i typ chcesz pobrać. Zerknij na katalog odzieży.
- clothesModel: Ciąg znaków oznaczający model ubrania którego indeks i typ chcesz pobrać. Zerknij na katalog odzieży.
Wartości zwrotne
Funkcja zwraca dwie liczby całkowie, odpowiednio typ i indeks ubrania, lub false w przypadku podania nieprawidłowych parametrów.
Przykład
Ten przykład pobiera ciuchy gracza wybranego typu i zmienia je na poprzednie w liście po wpisaniu /previousClothes
function scriptPreviousClothes ( thePlayer, key, clothesType )
local currentTexture, currentModel = getPedClothes ( thePlayer, clothesType ) -- sprawdźmy aktualne ciuchy
local clothesIndex = 1
if ( currentTexture ) then -- if he had clothes of that type
local tempA, tempB = getTypeIndexFromClothes ( currentTexture, currentModel ) -- pobierzmy typ i indeks, dzięki czemu będziemy mogli zmienić ubrania na poprzednie w liście
if ( tempA and tempB ) then -- jeśli je znaleźliśmy
clothesType, clothesIndex = tempA, tempB
end
end
clothesIndex = clothesIndex - 1
local texture, model = getClothesByTypeIndex ( clothesType, clothesIndex ) -- pobierzmy nową teksturę i model
if ( texture == false ) then -- jeśl osiągnęliśmy koniec listy
removePedClothes ( thePlayer, clothesType )
else addPedClothes ( thePlayer, texture, model, clothesType )
end
end
addCommandHandler ( "previousClothes", scriptPreviousClothes )