i useit inside a namespace SUtilsLib
edict_t *getEntityFromUserID(int userid)
{
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
edict_t* pEntity = engine->PEntityOfEntIndex(i);
if (!IsEntitySafe(pEntity)) continue;
if (engine->GetPlayerUserId(pEntity) == userid)
return pEntity;
}
return NULL;
}
works for me
- sn4k3
> Date: Sun, 27 Apr 2008 07:40:09 -0600> From: [EMAIL PROTECTED]> To:
> [email protected]> Subject: Re: [hlcoders] Plugin Crashing when
> getting player edict index> > A quick search for GetPlayerForUserID shows
> that it is in the client code> and part of the IVEngineClient class. You
> can't use client-side code on the> server.> > I use something like this:> >
> // return player edict for a userid> edict_t *DBUtils::EdictOfUserId( int
> UserId )> {> int i;> edict_t *pEnt;> for (i=0; i<MAX_CLIENTS; i++)> {> pEnt =
> m_Engine->PEntityOfEntIndex(i);> if (pEnt && !pEnt->IsFree())> {> if
> (FStrEq(pEnt->GetClassName(), "player"))> {> if
> (m_Engine->GetPlayerUserId(pEnt)==UserId)> {> return pEnt;> }> }> }> }> >
> return NULL;> }> > > On Sun, Apr 27, 2008 at 1:47 AM, Mark Chandler <[EMAIL
> PROTECTED]> wrote:> > > Hey all,> >> > Im getting a server crash when im
> trying to use> > engine->GetPlayerForUserID(userId) for a tf2 server plugin.
> The error it> > crashes with is "NUM_FOR_EDICT: bad pointer". I think this
> might be a> > valve> > bug but I really need to convert userId (from events)
> into the edict index> > (to use with some other engine functions). Any help
> will be appreciated.> >> > Mark> >> >
> _______________________________________________> > To unsubscribe, edit your
> list preferences, or view the list archives,> > please visit:> >
> http://list.valvesoftware.com/mailman/listinfo/hlcoders> >> >>
> _______________________________________________> To unsubscribe, edit your
> list preferences, or view the list archives, please visit:>
> http://list.valvesoftware.com/mailman/listinfo/hlcoders>
_________________________________________________________________
Instale a Barra de Ferramentas com Desktop Search e ganhe EMOTICONS para o
Messenger! É GRÁTIS!
http://www.msn.com.br/emoticonpack
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders