I was playing around with the entities today, and made this command
Code:
CON_COMMAND( print_edicts, "print the edicts with classnames" )
{
for(int i = 0; i < engine->GetEntityCount(); i++)
{
edict_t *pEntity = engine->PEntityOfEntIndex(i);
if(pEntity)
{
CBaseEntity *cbe = pEntity->GetUnknown()->GetBaseEntity();
Msg("%i\t: %s \n", i, pEntity->GetClassName() );
}
}
}
This will simply print the entire list of entities on the server. It will crash if you don't do the if(pEntity) test.
This can be expanded to filter out what you want. Example, getting the teams
Code:
if( FStrEq(pEntity->GetClassName(), "cs_team_manager") )
{
CTeam *team = (CTeam*)pEntity->GetUnknown()->GetBaseEntity();
Msg("Team name: \t%s \n", team->GetName() );
}
You'll need to include "cbase.h" and "team.h".
team->AddScore(2) adds 2 points to that team.
Just wanted to share in case someone could benefit from this code.