🙁 Source SDK 2013 Setup for Skin Changer
Hey there! I've been trying to create an internal CS:GO skin changer, however I am having issues including the source sdk 2013 headers. I have looked around everywhere and everyone just talks about creating your own SDK. I have tried to compile multiple tutorials into one working skin changer as I have no idea how I would go about creating one. What do I need to include to get C_BaseCombatWeapon working?
HEADER:
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
SOURCE:
#include "main.h"
//Netvars:
int weapon = 0x0030;
int iItemDefinitionIndex = 0x2F88;
int hOwnerEntity = 0x0148;
int m_iItemIDHigh = 0x2FA0;
int m_nFallbackPaintKit = 0x3170;
int m_flFallbackWear = 0x3178;
int m_nFallbackStatTrak = 0x317C;
int m_nFallbackSeed = 0x3174;
void fskin(C_BaseCombatWeapon* weapon, int skinid) {
int* idHigh = makeptr<int>(weapon, m_iItemIDHigh);
if (idHigh == nullptr)
return;
*idHigh = 1;
int* ptkit = makeptr<int>(weapon, m_nFallbackPaintKit);
*paintkit = skinid;
float* wear = makeptr<float>(weapon, m_flFallbackWear);
*wear = 0.0000000001f;
}
int getweaponid(C_BaseCombatWeapon* weapon){
return makeptr<int>(weapon, iItemDefinitionIndex);
}
void __fastcall FrameStageNotifyThink(void* ecx, void* edx, ClientFrameStage_t stage) {
if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
for (int i=0; i<cl::entlist->GetHighestEntityIndex(); i++) {
C_BaseCombatWeapon* weapon = (C_BaseCombatWeapon*)cl::entlist->GetClientEntity(i);
if (!weapon)
continue;
if (!cl::entlist->GetClientEntityFromHandle(*(int*)((DWORD)weapon , hOwnerEntity)))
continue;
if (cl::entlist->GetClientEntityFromHandle(*(int*)((DWORD)weapon , hOwnerEntity)) != localent)
continue;
std::string entname = weapon->GetClientClass()->GetName();
if (entname.empty())
continue;
bool isweapon = (entname[1] == 'W' && entname[2] == 'e' && entname[3] == 'a') || entname[3] == '4' || entname[2] == 'E';
if (isWeapon || entname.find("CKnife") != std::string::npos) {
if (weapon->getweaponid() == WEAPON_GLOCK)
util::fskin(weapon, 38);
if (weapon->getweaponid() == WEAPON_AK47)
util::fskin(weapon, 180);
}
}
}
origFSN(ecx, stage);
}
int origFSN() {
origFSN = (FrameStageNotify)VMTManager.Hook(Interfaces->ClientMode, 36, FrameStageNotifyThink);
typedef void(__thiscall *FrameStageNotify)(void*, ClientFrameStage);
FrameStageNotify origFSN = NULL;
}
HEADER:
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
SOURCE:
#include "main.h"
//Netvars:
int weapon = 0x0030;
int iItemDefinitionIndex = 0x2F88;
int hOwnerEntity = 0x0148;
int m_iItemIDHigh = 0x2FA0;
int m_nFallbackPaintKit = 0x3170;
int m_flFallbackWear = 0x3178;
int m_nFallbackStatTrak = 0x317C;
int m_nFallbackSeed = 0x3174;
void fskin(C_BaseCombatWeapon* weapon, int skinid) {
int* idHigh = makeptr<int>(weapon, m_iItemIDHigh);
if (idHigh == nullptr)
return;
*idHigh = 1;
int* ptkit = makeptr<int>(weapon, m_nFallbackPaintKit);
*paintkit = skinid;
float* wear = makeptr<float>(weapon, m_flFallbackWear);
*wear = 0.0000000001f;
}
int getweaponid(C_BaseCombatWeapon* weapon){
return makeptr<int>(weapon, iItemDefinitionIndex);
}
void __fastcall FrameStageNotifyThink(void* ecx, void* edx, ClientFrameStage_t stage) {
if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
for (int i=0; i<cl::entlist->GetHighestEntityIndex(); i++) {
C_BaseCombatWeapon* weapon = (C_BaseCombatWeapon*)cl::entlist->GetClientEntity(i);
if (!weapon)
continue;
if (!cl::entlist->GetClientEntityFromHandle(*(int*)((DWORD)weapon , hOwnerEntity)))
continue;
if (cl::entlist->GetClientEntityFromHandle(*(int*)((DWORD)weapon , hOwnerEntity)) != localent)
continue;
std::string entname = weapon->GetClientClass()->GetName();
if (entname.empty())
continue;
bool isweapon = (entname[1] == 'W' && entname[2] == 'e' && entname[3] == 'a') || entname[3] == '4' || entname[2] == 'E';
if (isWeapon || entname.find("CKnife") != std::string::npos) {
if (weapon->getweaponid() == WEAPON_GLOCK)
util::fskin(weapon, 38);
if (weapon->getweaponid() == WEAPON_AK47)
util::fskin(weapon, 180);
}
}
}
origFSN(ecx, stage);
}
int origFSN() {
origFSN = (FrameStageNotify)VMTManager.Hook(Interfaces->ClientMode, 36, FrameStageNotifyThink);
typedef void(__thiscall *FrameStageNotify)(void*, ClientFrameStage);
FrameStageNotify origFSN = NULL;
}