If you want data to store consistent, use steamids. Userid, Index and (caused by that) CBE* and edict_t* changes on every mapchange because every client will be fully disconnected and reconnected.
I would create a struct with the following pointers/vars:
Code:
struct Player_s
{
CBaseEntity *m_pEntity;
edict_t *m_pEdict;
IPlayerInfo *m_pInfo;
int m_iIndex; // if needed
int m_iUserID; // if needed
char *m_pszSteamID; // if I remember, there was a class called CSteamID, may you can use that instead
}
CUtlVector<Player_s*> vecPlayers;
Player_s *getPlayerInfo(char *pszSteamID)
{
for (int i = 0; i < vecPlayers.Count(); i++) // or Size(), one of them is deprecated
{
Player_s *pPlayer = vecPlayers[i];
if (!strcmp(pPlayer->m_pszSteamID, pszSteamID))
{
return pPlayer;
}
}
return (Player_s*)NULL;
}
The advantage of this method is, that you can search for everything you want, you've only to create a search function for example CBE or Index.
Chris