LightbulbSimple Sticker Changer

Posts 12 of 2 · Page 1 of 1
Simple Sticker Changer
It ONLY changes stickers for now, maybe on some future update I can make it change skins or you just do that yourself.
Sorry for the code being a litte gay, but yeah:~
SS:


Code:
enum class EStickerAttributeType
{
	Index,
	Wear,
	Scale,
	Rotation
};
 
static uint16_t s_iwoff = 0;
 
static void* o_float_fn;
 
static float __fastcall hooked_float_fn(void* thisptr, void*, int slot, EStickerAttributeType attribute, float fl)
{
	auto item = reinterpret_cast<C_BaseAttributableItem*>(uintptr_t(thisptr) - s_iwoff);
 
	switch(attribute)
	{
	case EStickerAttributeType::Wear:
		return FLT_MIN;
	case EStickerAttributeType::Scale:
		return 1.f;
	case EStickerAttributeType::Rotation:
		return 0.f;
	}
 
	return reinterpret_cast<decltype(hooked_float_fn)*>(o_float_fn)(thisptr, nullptr, slot, attribute, fl);
}
 
static void* o_uint_fn;
 
static unsigned int __fastcall hooked_uint_fn(void* thisptr, void*, int slot, EStickerAttributeType attribute, unsigned fl)
{
	auto item = reinterpret_cast<C_BaseAttributableItem*>(uintptr_t(thisptr) - s_iwoff);
 
	switch(attribute)
	{
	case EStickerAttributeType::Index:
		return 442;
	}
 
	return reinterpret_cast<decltype(hooked_uint_fn)*>(o_uint_fn)(thisptr, nullptr, slot, attribute, fl);
}
 
void ApplyStickerHooks(C_BaseAttributableItem* item)
{
	if(!s_iwoff)
		s_iwoff = NetVarManager::Get().GetOffset(FnvHash("CEconEntity->m_Item")) + 0xC;
 
	void**& iw_vt = *reinterpret_cast<void***>(uintptr_t(item) + s_iwoff);
 
	static void** iw_hook_vt = nullptr;
 
	if(!iw_hook_vt)
	{
		size_t len = 0;
		for(; platform::IsCodePtr(iw_vt[len]); ++len);
		iw_hook_vt = new void*[len];
		memcpy(iw_hook_vt, iw_vt, len * sizeof(void*));
		o_float_fn = iw_hook_vt[4];
		iw_hook_vt[4] = &hooked_float_fn;
		o_uint_fn = iw_hook_vt[5];
		iw_hook_vt[5] = &hooked_uint_fn;
	}
 
	iw_vt = iw_hook_vt;
}
How about giving credit to the guy you stole this from?
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?