ENTINDEX() and INDEXENT() Question.
I just started learning module coding.
I want to know the usage and meaning of ENTINDEX() and INDEXENT(), because I couldn't understand from the notes of HLSDK. Please help me with example if possible. |
Re: ENTINDEX() and INDEXENT() Question.
This question has already been answered here. If you have a more specific question, you should create a thread to ask the more specific question.
|
Re: ENTINDEX() and INDEXENT() Question.
Think of edict_t as a seat in a theater. The Goldsource engine (our theater) has a limited number of seats for each watcher.
Every watcher in this case is an entity that can be divided into groups: players, point entities, weapon entities, etc. For now, players are in our interest. Every seat has its own unique number ranging from zero to the max amount of seats the theater can have. The player group can only have their own id number from one to thirty two which is the max amount of players a server can have. This is that id parameter you see everywhere in amxx plugins when a player is being referenced to. The amxx plugin references the seat number, not the player directly. In AMXX modules, you are able to do much more than that (for now). You get to reference the seat number and the seat itself, accessing its properties directly. edict_t (edicts) are not players, they are slots for entities that contain many values every entity including the player have in common, like position, classname, targetname, netname (nickname) and many more. The true player class is called CBasePlayer, but we are working with edicts here, aka the seats that still contain valuable data about its sitter. So, finally, let's put it simple. ENTINDEX(edict_t*) returns the specified seat's number. Note that it can't be empty, it needs to have a sitter in order for you to do something with them, duh. (Pointers are crucial and I suggest you do a little bit of research on C++ pointers, they are very beautiful things). INDEXENT(int) returns a seat by a specified seat number. Different functions that work with the same seat object types receive different references to the seat. Either the seat itself or its number. |
Re: ENTINDEX() and INDEXENT() Question.
So, in my term if I make it simple to understand it would be ENTINDEX() = Returns data of an entity and INDEXENT() = Returns entity of the data.
Right, redivcram ? |
Re: ENTINDEX() and INDEXENT() Question.
No. ENTINDEX returns the index number of the entity and INDEXENT returns the entity that has the index number specified as the only argument when calling the function.
Sample uaage: Code:
edict_t* pMyEnt = ENTINDEX(4); // pMyEnt now points to the entity with the index number of 4 if it exists, otherwise it will point nowhere (will be nullptr) |
Re: ENTINDEX() and INDEXENT() Question.
Quote:
I have a question, what if I use INDEXENT() for entity other than player ? Then, will it return the index of that entity ? |
Re: ENTINDEX() and INDEXENT() Question.
Players ARE entities and every entity has an index.
|
Re: ENTINDEX() and INDEXENT() Question.
Quote:
Yes, but no reason to do so. Depends on what your function accepts, index or entity. |
All times are GMT -4. The time now is 06:53. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.