Raised This Month: $51 Target: $400
 12% 

Getting edict_T* from index?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Misery
Senior Member
Join Date: Dec 2010
Old 07-22-2012 , 04:42   Getting edict_T* from index?
Reply With Quote #1

Hi,

In the AMXX source it seems we can get the edict_t* with a macro called GET_PLAYER_POINTER_I... However it's used with a global variable declared into AMXX...

I'm not sure whether or not I can do the same on a module...?
Can someone explain me, in a mdoule, how I can manage to get the edict from player index?

Also it seems the class CPlayer* is unique to AMXX? I'm I right?
EDIT: Yes, seems it's amxx specific stuff...

Thanks

Misery

Last edited by Misery; 07-22-2012 at 04:48.
Misery is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 07-22-2012 , 04:53   Re: Getting edict_T* from index?
Reply With Quote #2

actually amxx provide the entry to its functions sort of.

MF_GetPlayerEdict(int id)

more details please check amxxmodule.h
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Misery
Senior Member
Join Date: Dec 2010
Old 07-22-2012 , 05:18   Re: Getting edict_T* from index?
Reply With Quote #3

Thanks a lot jim. STill, what about metamod's function here
Code:
PEntityOfEntIndex

from engine/eiface.h:
edict_t *PEntityOfEntIndex(int iEntIndex);
INDEXENT()

comments:
Returns the edict for the player in the given server slot (ie 1 to maxplayers).
Which one would you think is... actually faster? Any preference?

Thanks!
Misery is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 07-22-2012 , 06:00   Re: Getting edict_T* from index?
Reply With Quote #4

I think that's not something you should care about. The difference can be ignored totally. If you really care about it, generate native code for this instead of these two above: get the first edict pointer, then do the math to get the edict you want.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-22-2012 , 06:11   Re: Getting edict_T* from index?
Reply With Quote #5

index to edict and edict to index :

Code:
inline int	  ENTINDEX(edict_t *pEdict)			{ return (*g_engfuncs.pfnIndexOfEdict)(pEdict); }
inline edict_t* INDEXENT( int iEdictNum )		{ return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); }
You could cache world index first time Spawn is called and then you could make your own function, look hamsandwich code fro more details.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-22-2012 at 06:12.
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode