Skip to content

Instantly share code, notes, and snippets.

@root-cause
Created August 5, 2019 14:02
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save root-cause/3b80234367b0c856d60bf5cb4b826f86 to your computer and use it in GitHub Desktop.
Save root-cause/3b80234367b0c856d60bf5cb4b826f86 to your computer and use it in GitHub Desktop.
#pragma pack(push, 1)
typedef struct
{
int lockHash;
int _pad1;
int hash;
int _pad2;
int locate; // <locate value="..." /> in clothing data
int _pad3;
int drawable;
int _pad4;
int texture;
int _pad5;
int f_5;
int _pad6;
int componentType;
int _pad7;
int f_7;
int _pad8;
int f_8;
int _pad9;
char gxt[64];
} PedComponent;
#pragma pack(pop)
GET_SHOP_PED_COMPONENT & GET_SHOP_PED_PROP update:
Hash p0 -> Hash componentHash
Any* p1 -> PedComponent* outComponent
- componentHash is obtained by GET_HASH_NAME_FOR_COMPONENT/GET_HASH_NAME_FOR_PROP
- can use outComponent.gxt to get the GXT entries for clothing items
----------------
GET_FORCED_COMPONENT update:
Any* p2 -> int* forcedComponentNameHash
Any* p3 -> int* forcedComponentEnumValue
Any* p4 -> int* forcedComponentType
Example:
std::pair<int, int> GetProperTorso(Ped ped, int drawable, int texture)
{
Hash model = ENTITY::GET_ENTITY_MODEL(ped);
if (model != MISC::GET_HASH_KEY("mp_m_freemode_01") && model != MISC::GET_HASH_KEY("mp_f_freemode_01"))
{
// this stuff probably works with freemode models only
return std::make_pair(-1, -1);
}
Hash topHash = FILES::GET_HASH_NAME_FOR_COMPONENT(ped, 11, drawable, texture);
int fcTorsoDrawable = -1, fcTorsoTexture = -1;
for (int i = 0; i < FILES::_GET_NUM_FORCED_COMPONENTS(topHash); i++)
{
int fcNameHash, fcEnumValue, fcType;
FILES::GET_FORCED_COMPONENT(topHash, i, &fcNameHash, &fcEnumValue, &fcType);
if (fcType == 3)
{
if (fcNameHash == 0 || fcNameHash == MISC::GET_HASH_KEY("0"))
{
fcTorsoDrawable = fcEnumValue;
fcTorsoTexture = 0;
}
else
{
PedComponent torsoData;
FILES::GET_SHOP_PED_COMPONENT(fcNameHash, &torsoData);
fcTorsoDrawable = torsoData.drawable;
fcTorsoTexture = torsoData.texture;
}
}
}
return std::make_pair(fcTorsoDrawable, fcTorsoTexture);
}
Ped player = PLAYER::PLAYER_PED_ID();
int drawable = PED::GET_PED_DRAWABLE_VARIATION(player, 11), texture = PED::GET_PED_TEXTURE_VARIATION(player, 11);
std::pair<int, int> torsoValues = GetProperTorso(player, drawable, texture);
Notify("Current top: " + std::to_string(drawable) + " - " + std::to_string(texture));
Notify("Proper torso drawable: " + std::to_string(torsoValues.first));
Notify("Proper torso texture: " + std::to_string(torsoValues.second));
if (torsoValues.first != -1 && torsoValues.second != -1) PED::SET_PED_COMPONENT_VARIATION(player, 3, torsoValues.first, torsoValues.second, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment