Client.cpp above Code:
drawPlayerEsp
add following
Code:
typedef struct
{
char szName[256];
char szSprite[256];
HSPRITE hspr;
wrect_t rc;
int iRes;
} spriteinfo_t;
typedef struct
{
int iSpritesLoaded;
spriteinfo_t spriteinfo[MAX_SPRITES];
} spritedata_t;
spritedata_t spritedata;
void LoadSprites(client_sprite_t *pList, int iCount)
{
int i;
client_sprite_t *p;
char buf[512];
spritedata.iSpritesLoaded = 0;
if(!pList)
{
return;
}
p = pList;
i = iCount;
while(i-- && p->szName[0] != 0x00 && spritedata.iSpritesLoaded < MAX_SPRITES)
{
strncpy(spritedata.spriteinfo[spritedata.iSpritesLoaded].szName, p->szName,MAX_SPRITES);
strncpy(spritedata.spriteinfo[spritedata.iSpritesLoaded].szSprite, p->szSprite,MAX_SPRITES);
sprintf(buf, "sprites/%s.spr", p->szSprite);
spritedata.spriteinfo[spritedata.iSpritesLoaded].hspr = pEngfuncs->pfnSPR_Load(buf);
memcpy(&(spritedata.spriteinfo[spritedata.iSpritesLoaded].rc), &(p->rc), sizeof(p->rc));
spritedata.spriteinfo[spritedata.iSpritesLoaded].iRes = p->iRes;
p++;
spritedata.iSpritesLoaded++;
}
}
client_sprite_t* __stdcall hookpfnSPR_GetList(char *psz, int *piCount)
{
client_sprite_t *ret;
ret = pEngfuncs->pfnSPR_GetList(psz, piCount);
client_sprite_t *pList;
if(!strcmp(psz, "sprites/weapon_knife.txt"))
{
int iCount;
pList = pEngfuncs->pfnSPR_GetList("sprites/hud.txt", &iCount);
if(pList)
{
LoadSprites(pList, iCount);
}
}
return ret;
}
int GetSpriteIndex(char *szName)
{
int i;
if(szName[0] == 0x00)
return -1;
for(i = 0; i < spritedata.iSpritesLoaded; i++)
{
if(spritedata.spriteinfo.iRes == 640)
{
if(!strcmp(spritedata.spriteinfo.szName, szName))
{
return i;
}
}
}
}
now somewhere in Code:
drawPlayerEsp
add following:
Code:
char buf[255];
int index;
if (strstr(gGetWeaponName(ent->curstate.weaponmodel),"nade"))
{ sprintf(buf,"d_grenade"); }
else if (strstr(gGetWeaponName(ent->curstate.weaponmodel),"c4"))
{ sprintf(buf,"c4"); }
else if (strstr(gGetWeaponName(ent->curstate.weaponmodel),"mp5"))
{ sprintf(buf,"d_mp5navy"); }
else if (strstr(gGetWeaponName(ent->curstate.weaponmodel),"shield"))
{ sprintf(buf,"d_skull"); }
else{ sprintf(buf, "d_%s",gGetWeaponName(ent->curstate.weaponmodel)); }
index = GetSpriteIndex(buf);
if (cvar.spriteesp)
{
if (index != -1)
{
pEngfuncs->pfnSPR_Set(spritedata.spriteinfo[index].hspr, color->r,color->g,color->b); // Get sprite ready
pEngfuncs->pfnSPR_DrawAdditive(0, vecScreen[0]-10, vecScreen[1]-55, &(spritedata.spriteinfo[index].rc)); // Draw sprite
}
}
Register cvars spriteesp as int!