FEEL FREE TO USE!
This is NOT made by me, I only supported the person.
Also SOME of the code is taken for free from another website that gives source codes for free, Keep that in mind. ;))))
if (pCmd->buttons & IN_ATTACK)
{
float radius = 512.0f;
C_BasePlayer *lp = UTIL_PlayerByIndex(1);
C_BaseEntity *ents[256];
int ent_count = UTIL_EntitiesInSphere(ents, 256, lp->GetAbsOrigin(), radius, 0);
int i = 0;
for (i = 0; i < ent_count; i++)
{
if (ents[i] == NULL) continue;
if (!ents[i]->IsAlive()) continue;
if (!ents[i]->IsNPC()) continue;
if (!ents[i]->IsVisible()) continue;
if (ents[i]->IsDormant()) continue;
if (ents[i]->GetMoveType() == MOVETYPE_NONE) continue;
if (ents[i]->GetMoveType() == MOVETYPE_OBSERVER) continue;
Vector aimpos; aimpos.Init();
aimpos = ents[i]->GetAbsOrigin();
QAngle attchangles;
int attch = ents[i]->LookupAttachment("ValveBiped.Bip01_Head1");
if (attch > 0) ents[i]->GetAttachment(attch, aimpos, attchangles);
QAngle aimang; aimang.Init();
aimpos = aimpos - EyePosition();
AngleVectors(aimang, &aimpos);
pCmd->viewangles = aimang;
}
If a person who posted PARTS of this code originally please contact me via steam...
And I will take the post down if you wish me to.