-
Автор темы
- #1
Hello my base is on csgosimple so today for some reason my skins showing up only when the weapon dropped and not when i
got it in my hands!
read this and tell me please what is going wrong ?
Sreenshot Skinchanger (weapon on my hands) :
Screenshot Skinchanger (weapon dropped)
method hook : OnFrameStageNotify
skins.cpp code :
skins.h
OnFrameStageNotify :
void __stdcall hooked(int update_type)
{
Skins::OnFrameStageNotify(true);
postdata_hook.get_original<Post_o>(7)(static_cast<IClientNetworkable*>(g_LocalPlayer), update_type);
}
SupressLists:
hooks,cpp:
menu.cpp:
got it in my hands!
read this and tell me please what is going wrong ?
Sreenshot Skinchanger (weapon on my hands) :
Screenshot Skinchanger (weapon dropped)
method hook : OnFrameStageNotify
skins.cpp code :
C++:
#include "skins.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 = g_Options.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() = g_Options.statrack_items[config->definition_index].statrack_new.counter;
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 = g_Options.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 player_death_event::FireGameEvent(IGameEvent* p_event)
{
/* if we are connected */
if (!g_EngineClient->IsConnected() || !g_EngineClient->IsInGame() || !g_LocalPlayer)
return;
/* return if not event */
if (!p_event)
return;
if (strstr(p_event->GetName(), "player_death")) {
if (g_EngineClient->GetPlayerForUserID(p_event->GetInt("attacker")) == g_EngineClient->GetLocalPlayer()) {
auto& weapon = g_LocalPlayer->m_hActiveWeapon();
if (weapon) {
auto& skin_data = g_Options.skins.m_items[weapon->m_Item().m_iItemDefinitionIndex()];
auto& stat_track = g_Options.statrack_items[weapon->m_Item().m_iItemDefinitionIndex()];
if (skin_data.enabled && skin_data.stat_trak) {
stat_track.statrack_new.counter++;
weapon->m_nFallbackStatTrak() = stat_track.statrack_new.counter;
weapon->GetClientNetworkable()->PostDataUpdate(0);
weapon->GetClientNetworkable()->OnDataChanged(0);
}
}
const auto icon_override = g_Options.skins.get_icon_override(p_event->GetString("weapon"));
if (icon_override) {
p_event->SetString("weapon", icon_override);
}
}
}
}
void Skins::OnFrameStageNotify(bool frame_end)
{
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;
if (frame_end)
{
const auto wearables = local->m_hMyWearables();
const auto glove_config = &g_Options.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.dll"), "55 8B EC 83 E4 F8 51 53 56 57 8B F1 E8");
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);
}
}
else
{
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 = &g_Options.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;
}
}
C++:
#pragma once
#include "../valve_sdk/csgostructs.hpp"
#include "../options.hpp"
#include "../valve_sdk/sdk.hpp"
class player_death_event : public IGameEventListener2
{
public:
~player_death_event() { g_GameEvents->RemoveListener(this); }
virtual void FireGameEvent(IGameEvent* p_event);
};
namespace Skins {
void Listener();
void OnFrameStageNotify(bool frame_end);
};
void __stdcall hooked(int update_type)
{
Skins::OnFrameStageNotify(true);
postdata_hook.get_original<Post_o>(7)(static_cast<IClientNetworkable*>(g_LocalPlayer), update_type);
}
SupressLists:
hooks,cpp:
C++:
void __fastcall hkReadPacketEntities(void* pClientState, void* pEDX, void* pEntInfo) {
static auto original = clientstate_hook.get_original<ReadPacketEntities>(64);
original(pClientState, pEntInfo);
Skins::OnFrameStageNotify(false);
//if(g_EngineClient->IsInGame() && g_LocalPlayer)
// animation_system.server_layers = *g_LocalPlayer->GetAnimOverlays();
}
C++:
void RenderSkinsTab() {
auto& entries = g_Options.skins.m_items;
static auto definition_vector_index = 0;
auto& selected_entry = entries[k_weapon_names[definition_vector_index].definition_index];
auto& satatt = g_Options.statrack_items[k_weapon_names[definition_vector_index].definition_index];
selected_entry.definition_index = k_weapon_names[definition_vector_index].definition_index;
selected_entry.definition_vector_index = definition_vector_index;
ImGui::Columns(2, nullptr, false);
{
ImGui::PushItemWidth(-1);
const auto wnd = ImGui::GetCurrentWindowRead();
float height = (wnd->Pos.y + wnd->Size.y) - wnd->DC.CursorPos.y - 18.0f - ImGui::GetStyle().WindowPadding.y - ImGui::GetStyle().FramePadding.y * 2.0f;
auto& styles = ImGui::GetStyle();
styles.FrameRounding = 0;
ImGui::ListBoxHeader("##config", ImVec2(0.f, height));
{
for (size_t w = 0; w < k_weapon_names.size(); w++) {
if (ImGui::Selectable(k_weapon_names[w].name, definition_vector_index == w)) {
definition_vector_index = w;
}
}
}
ImGui::ListBoxFooter();
styles.FrameRounding = 10;
if (ImGui::Button("Update")) {
static auto clear_hud_weapon_icon_fn =
reinterpret_cast<std::int32_t(__thiscall*)(void*, std::int32_t)>(
Utils::PatternScan(GetModuleHandleA("client.dll"), "55 8B EC 51 53 56 8B 75 08 8B D9 57 6B FE 2C 89 5D FC"));
auto element = FindHudElement<std::uintptr_t*>("CCSGO_HudWeaponSelection");
if (!element)
return;
auto hud_weapons = reinterpret_cast<hud_weapons_t*>(std::uintptr_t(element) - 0xa0);
if (hud_weapons == nullptr)
return;
if (!*hud_weapons->get_weapon_count())
return;
for (std::int32_t i = 0; i < *hud_weapons->get_weapon_count(); i++)
i = clear_hud_weapon_icon_fn(hud_weapons, i);
typedef void(*ForceUpdate) (void);
static ForceUpdate FullUpdate = (ForceUpdate)Utils::PatternScan(GetModuleHandleA("engine.dll"), "A1 ? ? ? ? B9 ? ? ? ? 56 FF 50 14 8B 34 85");
FullUpdate();
//g_ClientState->ForceFullUpdate();
}
ImGui::SameLine();
ImGui::PopItemWidth();
}
ImGui::NextColumn();
{
ImGui::Checkbox("Enabled", &selected_entry.enabled);
ImGui::InputText("Name Tag", selected_entry.custom_name, 32);
ImGui::Checkbox("StatTrak##2", &selected_entry.stat_trak);
ImGui::InputInt("Seed", &selected_entry.seed);
ImGui::InputInt("StatTrak", &satatt.statrack_new.counter);
ImGui::SliderFloat("Wear", &selected_entry.wear, FLT_MIN, 1.f, "%.10f", 5);
if (selected_entry.definition_index != GLOVE_T_SIDE)
{
ImGui::Combo("Paint Kit", &selected_entry.paint_kit_vector_index, [](void* data, int idx, const char** out_text) {
*out_text = k_skins[idx].name.c_str();
return true;
}, nullptr, k_skins.size(), 20);
selected_entry.paint_kit_index = k_skins[selected_entry.paint_kit_vector_index].id;
}
else {
ImGui::Combo("Paint Kit##2222", &selected_entry.paint_kit_vector_index, [](void* data, int idx, const char** out_text) {
*out_text = k_gloves[idx].name.c_str();
return true;
}, nullptr, k_gloves.size(), 20);
selected_entry.paint_kit_index = k_gloves[selected_entry.paint_kit_vector_index].id;
}
if (selected_entry.definition_index == WEAPON_KNIFE) {
ImGui::Combo("Knife", &selected_entry.definition_override_vector_index, [](void* data, int idx, const char** out_text) {
*out_text = k_knife_names.at(idx).name;
return true;
}, nullptr, k_knife_names.size(), 10);
selected_entry.definition_override_index = k_knife_names.at(selected_entry.definition_override_vector_index).definition_index;
}
else if (selected_entry.definition_index == GLOVE_T_SIDE) {
ImGui::Combo("Glove", &selected_entry.definition_override_vector_index, [](void* data, int idx, const char** out_text) {
*out_text = k_glove_names.at(idx).name;
return true;
}, nullptr, k_glove_names.size(), 10);
selected_entry.definition_override_index = k_glove_names.at(selected_entry.definition_override_vector_index).definition_index;
}
else {
static auto unused_value = 0;
selected_entry.definition_override_vector_index = 0;
}
const char* Slot[] =
{
"1",
"2",
"3",
"4"
};
ImGui::Checkbox("Stickers", &selected_entry.enabled_stickers);
ImGui::SliderInt("Slot", &selected_entry.stickers_place, 0, 4);
ImGui::InputInt("Index", &selected_entry.stickers[selected_entry.stickers_place].stickers_id);
}
ImGui::Columns(1, nullptr, false);
}