Пользователь
			
			
				
					
				
			
		- Статус
 - Оффлайн
 
- Регистрация
 - 28 Апр 2018
 
- Сообщения
 - 629
 
- Реакции
 - 134
 
Здарова, тут такой вопрос, как сделать, чтобы перчатки были на 2 командах со скинами, а не на 1 за которую ты заходишь :/
После смерти перчатки пропадают и встают нормально, но при смене команды они теряют скин, но моделька остаётся.
Ниже приложил видео как это происходит.
	
		
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
				
			После смерти перчатки пропадают и встают нормально, но при смене команды они теряют скин, но моделька остаётся.
Ниже приложил видео как это происходит.
			
				C++:
			
		
		
		template <typename T>
T* get_entity_from_handle(UINT h)
{
    if (h == INVALID_EHANDLE_INDEX)
        return nullptr;
    return static_cast<T*>(I::EntityList()->GetClientEntityFromHandle((PVOID)h));
}
static auto get_wearable_create_fn() -> CreateClientClassFn
{
    ClientClass* pClass = I::Client()->GetAllClasses();
    for (pClass = I::Client()->GetAllClasses(); pClass; pClass = pClass->m_pNext)
    {
        if (pClass->m_ClassID == (int)CLIENT_CLASS_ID::CEconWearable)
        {
            return pClass->m_pCreateFn;
        }
    }
    return pClass->m_pCreateFn;
}
static auto make_glove(int entry, int serial) -> CBaseAttributableItem*
{
    static auto create_wearable_fn = get_wearable_create_fn();
    create_wearable_fn(entry, serial);
    const auto glove = static_cast<CBaseAttributableItem*>(I::EntityList()->GetClientEntity(entry));
    assert(glove);
    {
        CSX::Memory::FindPattern(GetClientDll(), ("\x53\x8D\x48\x04\xE8\x00\x00\x00\x00\x8B\x4D\x10"), ("xxxxx????xxx"), 4);
        static auto set_abs_origin_addr = CSX::Memory::FindPattern(GetClientDll(), ("\x55\x8B\xEC\x83\xE4\xF8\x51\x53\x56\x57\x8B\xF1"), ("xxxxxxxxxxxx"), 0);
        const auto set_abs_origin_fn = reinterpret_cast<void(__thiscall*)(void*, const std::array<float, 3>&)>(set_abs_origin_addr);
        static constexpr std::array<float, 3> new_pos = { 10000.f, 10000.f, 10000.f };
        set_abs_origin_fn(glove, new_pos);
    }
    return glove;
}
int CurGlove = IsTT ? SelectedGloveTT : SelectedGloveCT;
    if (CurGlove)
    {
        float CurGloveWear = IsTT ? GloveTTWear : GloveCTWear;
        UINT* wearables = pLocal->GetWearables();
        if (!wearables)
            return;
        static auto glove_handle = UINT(0);
        auto glove = (CBaseAttributableItem*)I::EntityList()->GetClientEntityFromHandle((PVOID)wearables[0]);
        if (!glove)
        {
            const auto our_glove = (CBaseAttributableItem*)I::EntityList()->GetClientEntityFromHandle((PVOID)glove_handle);
            if (our_glove)
            {
                wearables[0] = glove_handle;
                glove = our_glove;
            }
        }
        if (pLocal->IsDead() || pLocal->GetHealth() <= 0)
        {
            if (glove)
            {
                glove->GetClientNetworkable()->SetDestroyedOnRecreateEntities();
                glove->GetClientNetworkable()->Release();
            }
            return;
        }
        if (!glove)
        {
            const auto entry = I::EntityList()->GetHighestEntityIndex() + 1;
            const auto serial = rand() % 0x1000;
            glove = make_glove(entry, serial);
            wearables[0] = entry | serial << 16;
            glove_handle = wearables[0];
        }
        if (glove)
        {
            *glove->GetIndex() = -1;
            *glove->GetItemIDHigh() = -1;
            *glove->GetAccountID() = LocalPlayerInfo.m_nXuidLow;
            *glove->GetEntityQuality() = 4;
            *glove->GetFallbackWear() = CurGloveWear;
            *glove->GetFallbackSeed() = 0;
            *glove->GetFallbackStatTrak() = -1;
            *glove->GetFallbackPaintKit() = GlovesSkin_Array[CurGlove - 1].PaintKit;
            auto& definition_index = *glove->GetItemDefinitionIndex();
            if (GlovesSkin_Array[CurGlove - 1].ItemIndex != definition_index)
            {
                int ModelIndex = I::ModelInfo()->GetModelIndex(GlovesSkin_Array[CurGlove - 1].szModel);
                *glove->GetItemDefinitionIndex() = GlovesSkin_Array[CurGlove - 1].ItemIndex;
                glove->SetModelIndex(ModelIndex);
                glove->GetClientNetworkable()->PreDataUpdate(DATA_UPDATE_CREATED);
            }
        }
    }
	
			
				Последнее редактирование: