#include <sdk/IVModelRender.h>
// Function to draw player model in ESP preview
void draw_player_model(const C_BaseEntity *player, const Vector &origin, const QAngle &angles) {
// Get model render interface
IVModelRender *pModelRender = g_pModelRender;
// Set up model render data
model_render_info_t render_info;
render_info.origin = origin;
render_info.angles = angles;
render_info.pModel = player->GetModel();
render_info.pRenderable = player;
render_info.flags = STUDIO_RENDER;
// Set up lighting data
lighting_query_t lighting;
lighting.pos = origin;
lighting.normal = Vector(0.0f, 0.0f, 1.0f);
lighting.ambient_light_color = Color(255, 255, 255, 255);
lighting.direct_light_color = Color(255, 255, 255, 255);
lighting.pMaterial = nullptr;
lighting.flags = LIGHTING_LIGHT_AMBIENT | LIGHTING_LIGHT_DIRECT;
// Set up lighting state
lighting_state_t lighting_state;
lighting_state.pLighting = &lighting;
lighting_state.pLightingState = &lighting_state;
// Draw player model
pModelRender->DrawModelEx(render_info, lighting_state);
}
int main() {
// Initialize player model and preview window
// ...
// Loop through all player entities
for (int i = 1; i <= g_pGlobalVars->maxClients; i++) {
// Get player entity
C_BaseEntity *player = g_pEntityList->GetClientEntity(i);
if (!player || player->GetDormant() || player->GetHealth() <= 0) continue; // skip inactive or dead players
// Draw player model in preview window
draw_player_model(player, player->GetAbsOrigin(), player->GetAbsAngles());
}
// Handle user input and update preview window
// ...
}