View Single Post
Re: Getting edict from name
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Getting edict from name - 14-04-2004

There is no facility available in the SDK that will do what you want that I know of. However, you can simply find the edict_t of a particular client given his name, if you cycle through all of them and compare their netname with the supplied one.

Code:
int iClientIndex;
edict_t *pClient;
 
pClient = NULL; // initialize
 
// cycle through all clients...
for (iClientIndex = 1; iClientIndex < gpGlobals->maxClients; iClientIndex++)
{
   pClient = INDEXENT (iClientIndex);
 
   if (FNullEnt (pClient))
	  continue; // discard invalid client slots
 
   if (strcmp ("two_masks", STRING (pClient->v.netname)) == 0)
	  break; // it's this client !
}
 
// have we finally found a client ?
if (!FNullEnt (pClient))
{
   DoSomeStuffWithClient (pClient);
   DoSomeOtherStuffWithClient (pClient);
   SlapClientAroundABit (pClient);
   MakeClientJumpUpAndDown (pClient);
   ClientWriteALoveLetterToYourMomma (pClient);
   // etc...
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 14-04-2004 at 10:14..
  
Reply With Quote