.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Metamod and metamod plugins (http://forums.bots-united.com/forumdisplay.php?f=15)
-   -   Getting edict from name (http://forums.bots-united.com/showthread.php?t=1365)

two_masks 14-04-2004 02:17

Getting edict from name
 
I'd like to be able to get the edict of a client when they send a radio message, but all I have access to is the name of the sending client. Is there a command in the SDK that will let me do this?
FIND_ENTITY_BY_STRING

sounds like it would do the trick, but I don't know where to find a listing of available fieldnames... can anyone fill me in?

Thanks again- this forum has been a great help!

-JB

Pierre-Marie Baty 14-04-2004 10:01

Re: Getting edict from name
 
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...
}



All times are GMT +2. The time now is 03:14.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.