Probably entity is null. Use something like this;
PHP Code:
edict_t *ent = NULL;
for (int entIndex = 0; entIndex < gpGlobals->maxEntities; entIndex++)
{
ent = INDEXENT (entIndex);
if (FNullEnt (ent))
continue;
g_engfuncs.pfnServerPrint (STRING (ent->v.classname));
g_engfuncs.pfnServerPrint ("\n");
}
Should work without a problem.