PDA

View Full Version : Getting edict from name


two_masks
14-04-2004, 03:17
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, 11:01
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.


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...
}