Пользователь
- Статус
- Оффлайн
- Регистрация
- 24 Авг 2019
- Сообщения
- 239
- Реакции
- 37
Подскажите как добавить новую модельку ножа в skichanger. Вот код ItemDefinirions:
А вот код самого skinchanger(хз надо или нет):
И еще если кто-то знает как перевести новые скины:
C++:
#include "ItemDefinitions.h"
const std::map<size_t, weapon_info> k_weapon_info =
{
{WEAPON_KNIFE,{"models/weapons/v_knife_default_ct.mdl", "knife_default_ct"}},
{WEAPON_KNIFE_T,{"models/weapons/v_knife_default_t.mdl", "knife_t"}},
{WEAPON_KNIFE_BAYONET, {"models/weapons/v_knife_bayonet.mdl", "bayonet"}},
{WEAPON_KNIFE_FLIP, {"models/weapons/v_knife_flip.mdl", "knife_flip"}},
{WEAPON_KNIFE_GUT, {"models/weapons/v_knife_gut.mdl", "knife_gut"}},
{WEAPON_KNIFE_KARAMBIT, {"models/weapons/v_knife_karam.mdl", "knife_karambit"}},
{WEAPON_KNIFE_M9_BAYONET, {"models/weapons/v_knife_m9_bay.mdl", "knife_m9_bayonet"}},
{WEAPON_KNIFE_TACTICAL, {"models/weapons/v_knife_tactical.mdl", "knife_tactical"}},
{WEAPON_KNIFE_FALCHION, {"models/weapons/v_knife_falchion_advanced.mdl", "knife_falchion"}},
{WEAPON_KNIFE_SURVIVAL_BOWIE, {"models/weapons/v_knife_survival_bowie.mdl", "knife_survival_bowie"}},
{WEAPON_KNIFE_BUTTERFLY, {"models/weapons/v_knife_butterfly.mdl", "knife_butterfly"}},
{WEAPON_KNIFE_PUSH, {"models/weapons/v_knife_push.mdl", "knife_push"}},
{WEAPON_KNIFE_URSUS,{"models/weapons/v_knife_ursus.mdl", "knife_ursus"}},
{WEAPON_KNIFE_GYPSY_JACKKNIFE,{"models/weapons/v_knife_gypsy_jackknife.mdl", "knife_gypsy_jackknife"}},
{WEAPON_KNIFE_STILETTO,{"models/weapons/v_knife_stiletto.mdl", "knife_stiletto"}},
{WEAPON_KNIFE_WIDOWMAKER,{"models/weapons/v_knife_widowmaker.mdl", "knife_widowmaker"}},
{GLOVE_STUDDED_BLOODHOUND,{"models/weapons/v_models/arms/glove_bloodhound/v_glove_bloodhound.mdl"}},
{GLOVE_T_SIDE,{"models/weapons/v_models/arms/glove_fingerless/v_glove_fingerless.mdl"}},
{GLOVE_CT_SIDE,{"models/weapons/v_models/arms/glove_hardknuckle/v_glove_hardknuckle.mdl"}},
{GLOVE_SPORTY,{"models/weapons/v_models/arms/glove_sporty/v_glove_sporty.mdl"}},
{GLOVE_SLICK,{"models/weapons/v_models/arms/glove_slick/v_glove_slick.mdl"}},
{GLOVE_LEATHER_WRAP,{"models/weapons/v_models/arms/glove_handwrap_leathery/v_glove_handwrap_leathery.mdl"}},
{GLOVE_MOTORCYCLE,{"models/weapons/v_models/arms/glove_motorcycle/v_glove_motorcycle.mdl"}},
{GLOVE_SPECIALIST,{"models/weapons/v_models/arms/glove_specialist/v_glove_specialist.mdl"}},
{GLOVE_HYDRA,{"models/weapons/v_models/arms/glove_bloodhound/v_glove_bloodhound_hydra.mdl"}}
};
const std::vector<weapon_name> k_knife_names =
{
{0, "Default"},
{WEAPON_KNIFE_BAYONET, "Bayonet"},
{WEAPON_KNIFE_FLIP, "Flip Knife"},
{WEAPON_KNIFE_GUT, "Gut Knife"},
{WEAPON_KNIFE_KARAMBIT, "Karambit"},
{WEAPON_KNIFE_M9_BAYONET, "M9 Bayonet"},
{WEAPON_KNIFE_TACTICAL, "Huntsman Knife"},
{WEAPON_KNIFE_FALCHION, "Falchion Knife"},
{WEAPON_KNIFE_SURVIVAL_BOWIE, "Bowie Knife"},
{WEAPON_KNIFE_BUTTERFLY, "Butterfly Knife"},
{WEAPON_KNIFE_PUSH, "Shadow Daggers"},
{WEAPON_KNIFE_URSUS, "Ursus Knife"},
{WEAPON_KNIFE_GYPSY_JACKKNIFE, "Navaja Knife"},
{WEAPON_KNIFE_STILETTO, "Stiletto Knife"},
{WEAPON_KNIFE_WIDOWMAKER, "Talon Knife"}
};
const std::vector<weapon_name> k_glove_names =
{
{ 0, "Default" },
{ GLOVE_STUDDED_BLOODHOUND, "Bloodhound" },
{ GLOVE_T_SIDE, "Default (Terrorists)" },
{ GLOVE_CT_SIDE, "Default (Counter-Terrorists)" },
{ GLOVE_SPORTY, "Sporty" },
{ GLOVE_SLICK, "Slick" },
{ GLOVE_LEATHER_WRAP, "Handwrap" },
{ GLOVE_MOTORCYCLE, "Motorcycle" },
{ GLOVE_SPECIALIST, "Specialist" },
{ GLOVE_HYDRA, "Hydra" }
};
const std::vector<weapon_name> k_weapon_names =
{
{WEAPON_KNIFE, "Knife"},
{GLOVE_T_SIDE, "Glove"},
{7, "AK-47"},
{8, "AUG"},
{9, "AWP"},
{63, "CZ75 Auto"},
{1, "Desert Eagle"},
{2, "Dual Berettas"},
{10, "FAMAS"},
{3, "Five-SeveN"},
{11, "G3SG1"},
{13, "Galil AR"},
{4, "Glock-18"},
{14, "M249"},
{60, "M4A1-S"},
{16, "M4A4"},
{17, "MAC-10"},
{27, "MAG-7"},
{23, "MP5-SD"},
{33, "MP7"},
{34, "MP9"},
{28, "Negev"},
{35, "Nova"},
{32, "P2000"},
{36, "P250"},
{19, "P90"},
{26, "PP-Bizon"},
{64, "R8 Revolver"},
{29, "Sawed-Off"},
{38, "SCAR-20"},
{40, "SSG 08"},
{39, "SG 553"},
{30, "Tec-9"},
{24, "UMP-45"},
{61, "USP-S"},
{25, "XM1014"},
};
C++:
#include "Skinchanger.h"
#include <filesystem>
#include "..\Settings.h"
#include "..\Logger.h"
static auto erase_override_if_exists_by_index(const int definition_index) -> void
{
if (k_weapon_info.count(definition_index))
{
auto& icon_override_map = Settings::Skins::m_icon_overrides;
const auto& original_item = k_weapon_info.at(definition_index);
if (original_item.icon && icon_override_map.count(original_item.icon))
icon_override_map.erase(icon_override_map.at(original_item.icon)); // Remove the leftover override
}
}
static auto apply_config_on_attributable_item(C_BaseAttributableItem* item, const item_setting* config,
const unsigned xuid_low) -> void
{
if (!config->enabled) {
return;
}
item->m_Item().m_iItemIDHigh() = -1;
item->m_Item().m_iAccountID() = xuid_low;
if (config->custom_name[0])
strcpy_s(item->m_Item().m_iCustomName(), config->custom_name);
if (config->paint_kit_index)
item->m_nFallbackPaintKit() = config->paint_kit_index;
if (config->seed)
item->m_nFallbackSeed() = config->seed;
if (config->stat_trak) {
item->m_nFallbackStatTrak() = config->stat_trak;
item->m_Item().m_iEntityQuality() = 9;
}
else {
item->m_Item().m_iEntityQuality() = is_knife(config->definition_index) ? 3 : 0;
}
item->m_flFallbackWear() = config->wear;
auto& definition_index = item->m_Item().m_iItemDefinitionIndex();
auto& icon_override_map = Settings::Skins::m_icon_overrides;
if (config->definition_override_index && config->definition_override_index != definition_index && k_weapon_info.count(config->definition_override_index))
{
const auto old_definition_index = definition_index;
definition_index = config->definition_override_index;
const auto& replacement_item = k_weapon_info.at(config->definition_override_index);
item->m_nModelIndex() = g_MdlInfo->GetModelIndex(replacement_item.model);
item->SetModelIndex(g_MdlInfo->GetModelIndex(replacement_item.model));
item->GetClientNetworkable()->PreDataUpdate(0);
if (old_definition_index && k_weapon_info.count(old_definition_index))
{
const auto& original_item = k_weapon_info.at(old_definition_index);
if (original_item.icon && replacement_item.icon) {
icon_override_map[original_item.icon] = replacement_item.icon;
}
}
}
else
{
erase_override_if_exists_by_index(definition_index);
}
}
static auto get_wearable_create_fn() -> CreateClientClassFn
{
auto clazz = g_CHLClient->GetAllClasses();
// Please, if you gonna paste it into a cheat use classids here. I use names because they
// won't change in the foreseeable future and i dont need high speed, but chances are
// you already have classids, so use them instead, they are faster.
while (strcmp(clazz->m_pNetworkName, "CEconWearable"))
clazz = clazz->m_pNext;
return clazz->m_pCreateFn;
}
void Skinchanger::OnFrameStageNotify(ClientFrameStage_t stage)
{
if (stage != FRAME_NET_UPDATE_POSTDATAUPDATE_START)
return;
const auto local_index = g_EngineClient->GetLocalPlayer();
const auto local = static_cast<C_BasePlayer*>(g_EntityList->GetClientEntity(local_index));
if (!local)
return;
player_info_t player_info;
if (!g_EngineClient->GetPlayerInfo(local_index, &player_info))
return;
{
const auto wearables = local->m_hMyWearables();
const auto glove_config = &Settings::Skins::m_items[GLOVE_T_SIDE];
static auto glove_handle = CBaseHandle(0);
auto glove = reinterpret_cast<C_BaseAttributableItem*>(g_EntityList->GetClientEntityFromHandle(wearables[0]));
if (!glove)
{
const auto our_glove = reinterpret_cast<C_BaseAttributableItem*>(g_EntityList->GetClientEntityFromHandle(glove_handle));
if (our_glove) // Our glove still exists
{
wearables[0] = glove_handle;
glove = our_glove;
}
}
if (!local->IsAlive())
{
if (glove)
{
glove->GetClientNetworkable()->SetDestroyedOnRecreateEntities();
glove->GetClientNetworkable()->Release();
}
return;
}
if (glove_config && glove_config->definition_override_index)
{
if (!glove)
{
static auto create_wearable_fn = get_wearable_create_fn();
const auto entry = g_EntityList->GetHighestEntityIndex() + 1;
const auto serial = rand() % 0x1000;
//glove = static_cast<C_BaseAttributableItem*>(create_wearable_fn(entry, serial));
create_wearable_fn(entry, serial);
glove = reinterpret_cast<C_BaseAttributableItem*>(g_EntityList->GetClientEntity(entry));
assert(glove);
{
static auto set_abs_origin_addr = Utils::PatternScan(GetModuleHandle(L"client_panorama.dll"), "55 8B EC 83 E4 F8 51 53 56 57 8B F1");
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);
}
const auto wearable_handle = reinterpret_cast<CBaseHandle*>(&wearables[0]);
*wearable_handle = entry | serial << 16;
glove_handle = wearables[0];
}
// Thanks, Beakers
glove->SetGloveModelIndex(-1);
apply_config_on_attributable_item(glove, glove_config, player_info.xuid_low);
}
}
{
auto weapons = local->m_hMyWeapons();
for (int i = 0; weapons[i].IsValid(); i++)
{
C_BaseAttributableItem *weapon = (C_BaseAttributableItem*)g_EntityList->GetClientEntityFromHandle(weapons[i]);
if (!weapon)
continue;
auto& definition_index = weapon->m_Item().m_iItemDefinitionIndex();
const auto active_conf = &Settings::Skins::m_items[is_knife(definition_index) ? WEAPON_KNIFE : definition_index];
apply_config_on_attributable_item(weapon, active_conf, player_info.xuid_low);
}
}
const auto view_model_handle = local->m_hViewModel();
if (!view_model_handle.IsValid())
return;
const auto view_model = static_cast<C_BaseViewModel*>(g_EntityList->GetClientEntityFromHandle(view_model_handle));
if (!view_model)
return;
const auto view_model_weapon_handle = view_model->m_hWeapon();
if (!view_model_weapon_handle.IsValid())
return;
const auto view_model_weapon = static_cast<C_BaseCombatWeapon*>(g_EntityList->GetClientEntityFromHandle(view_model_weapon_handle));
if (!view_model_weapon)
return;
if (k_weapon_info.count(view_model_weapon->m_Item().m_iItemDefinitionIndex()))
{
const auto override_model = k_weapon_info.at(view_model_weapon->m_Item().m_iItemDefinitionIndex()).model;
auto override_model_index = g_MdlInfo->GetModelIndex(override_model);
view_model->m_nModelIndex() = override_model_index;
auto world_model_handle = view_model_weapon->m_hWeaponWorldModel();
if (!world_model_handle.IsValid())
return;
const auto world_model = static_cast<C_BaseWeaponWorldModel*>(g_EntityList->GetClientEntityFromHandle(world_model_handle));
if (!world_model)
return;
world_model->m_nModelIndex() = override_model_index + 1;
}
}