3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _entity_included
19 #define _entity_included
23 * For more information on these, see the HL2SDK (public/edict.h)
25 #define FL_EDICT_CHANGED (1<<0) /**< Game DLL sets this when the entity state changes
26 Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */
27 #define FL_EDICT_FREE (1<<1) /**< this edict if free for reuse */
28 #define FL_EDICT_FULL (1<<2) /**< this is a full server entity */
29 #define FL_EDICT_FULLCHECK (0<<0) /**< call ShouldTransmit() each time, this is a fake flag */
30 #define FL_EDICT_ALWAYS (1<<3) /**< always transmit this entity */
31 #define FL_EDICT_DONTSEND (1<<4) /**< don't transmit this entity */
32 #define FL_EDICT_PVSCHECK (1<<5) /**< always transmit entity, but cull against PVS */
33 #define FL_EDICT_PENDING_DORMANT_CHECK (1<<6)
34 #define FL_EDICT_DIRTY_PVS_INFORMATION (1<<7)
35 #define FL_FULL_EDICT_CHANGED (1<<8)
38 * Returns the maximum number of entities.
40 * @return Maximum number of entities.
42 native GetMaxEntities();
45 * Returns the number of entities in the server.
47 * @return Number of entities in the server.
49 native GetEntityCount();
52 * Returns whether or not an entity is valid. Returns false
53 * if there is no matching CBaseEntity for this edict index.
55 * @param edict Index of the entity/edict.
56 * @return True if valid, false otherwise.
58 native bool:IsValidEntity(edict);
61 * Returns whether or not an edict index is valid.
63 * @param edict Index of the edict.
64 * @return True if valid, false otherwise.
66 native bool:IsValidEdict(edict);
69 * Returns whether or not an entity is a valid networkable edict.
71 * @param edict Index of the edict.
72 * @return True if networkable, false if invalid or not networkable.
74 native bool:IsEntNetworkable(edict);
77 * Creates a new edict (the basis of a networkable entity)
79 * @return Index of the edict, 0 on failure.
84 * Removes an edict from the world.
86 * @param edict Index of the edict.
88 * @error Invalid edict index.
90 native RemoveEdict(edict);
93 * Returns the flags on an edict. These are not the same as entity flags.
95 * @param edict Index of the entity.
96 * @return Edict flags.
97 * @error Invalid edict index.
99 native GetEdictFlags(edict);
102 * Sets the flags on an edict. These are not the same as entity flags.
104 * @param edict Index of the entity.
105 * @param flags Flags to set.
107 * @error Invalid edict index.
109 native SetEdictFlags(edict, flags);
112 * Retrieves an edict classname.
114 * @param edict Index of the entity.
115 * @param clsname Buffer to store the classname.
116 * @param maxlength Maximum length of the buffer.
117 * @return True on success, false if there is no classname set.
119 native bool:GetEdictClassname(edict, String:clsname[], maxlength);
122 * Retrieves an entity's networkable serverclass name.
123 * This is not the same as the classname and is used for networkable state changes.
125 * @param edict Index of the entity.
126 * @param clsname Buffer to store the serverclass name.
127 * @param maxlength Maximum lnegth of the buffer.
128 * @return True on success, false if the edict is not networkable.
129 * @error Invalid edict index.
131 native bool:GetEntityNetClass(edict, String:clsname[], maxlength);
134 * @section Entity offset functions
136 * Offsets should be specified in byte distance from the CBaseEntity
137 * structure, not short (double byte) or integer (four byte) multiples.
138 * It is somewhat common practice to use offsets aligned to their final
139 * type, and thus make sure you are not falling to this error in SourceMod.
140 * For example, if your "integer-aligned" offset was 119, your byte-aligned
141 * offset is 119*4, or 476.
143 * Specifying incorrect offsets or the incorrect data type for an offset
144 * can have fatal consequences. If you are hardcoding offsets, and the
145 * layout of CBaseEntity does not match, you can easily crash the server.
147 * The reasonable bounds for offsets is greater than or equal to 0 and
148 * below 32768. Offsets out of these bounds will throw an error. However,
149 * this does not represent any real range, it is simply a sanity check for
150 * illegal values. Any range outside of the CBaseEntity structure's private
151 * size will cause undefined behaviour or even crash.
155 * Marks an entity as state changed. This can be useful if you set an offset
156 * and wish for it to be immediately changed over the network. By default this
157 * is not done for offset setting functions.
159 * @param edict Index to the edict.
160 * @param offset Offset to mark as changed. If 0,
161 * the entire edict is marked as changed.
163 * @error Invalid entity or offset out of bounds.
165 native ChangeEdictState(edict, offset = 0);
168 * Peeks into an entity's object data and retrieves the integer value at
171 * @param entity Edict index.
172 * @param offset Offset to use.
173 * @param size Number of bytes to read (valid values are 1, 2, or 4).
174 * @return Value at the given memory location.
175 * @error Invalid entity or offset out of reasonable bounds.
177 native GetEntData(entity, offset, size=4);
180 * Peeks into an entity's object data and sets the integer value at
183 * @param entity Edict index.
184 * @param offset Offset to use.
185 * @param size Number of bytes to write (valid values are 1, 2, or 4).
186 * @return Value at the given memory location.
187 * @error Invalid entity or offset out of reasonable bounds.
190 native SetEntData(entity, offset, value, size=4);
193 * Peeks into an entity's object data and retrieves the float value at
196 * @param entity Edict index.
197 * @param offset Offset to use.
198 * @return Value at the given memory location.
199 * @error Invalid entity or offset out of reasonable bounds.
201 native Float:GetEntDataFloat(entity, offset);
204 * Peeks into an entity's object data and sets the integer value at
207 * @param entity Edict index.
208 * @param offset Offset to use.
209 * @return Value at the given memory location.
210 * @error Invalid entity or offset out of reasonable bounds.
213 native SetEntDataFloat(entity, offset, Float:value);
216 * Peeks into an entity's object data and retrieves the entity handle
217 * info at the given offset.
219 * @param entity Edict index.
220 * @param offset Offset to use.
221 * @return Entity index at the given location, or 0 if none.
222 * @error Invalid entity or offset out of reasonable bounds.
224 native GetEntDataEnt(entity, offset);
227 * Peeks into an entity's object data and sest the entity handle info
228 * at the given offset.
230 * @param entity Edict index.
231 * @param offset Offset to use.
232 * @param other Entity index to set, or 0 to clear.
234 * @error Invalid entity or offset out of reasonable bounds.
236 native SetEntDataEnt(entity, offset, other);
239 * Peeks into an entity's object data and retrieves the vector at the
241 * @note Both a Vector and a QAngle are three floats. This is a
242 * convenience function and will work with both types.
244 * @param entity Edict index.
245 * @param offset Offset to use.
246 * @param vec Vector buffer to store data in.
248 * @error Invalid entity or offset out of reasonable bounds.
250 native GetEntDataVector(entity, offset, Float:vec[3]);
253 * Peeks into an entity's object data and sets the vector at the given
255 * @note Both a Vector and a QAngle are three floats. This is a
256 * convenience function and will work with both types.
258 * @param entity Edict index.
259 * @param offset Offset to use.
260 * @param vec Vector to set.
262 * @error Invalid entity or offset out of reasonable bounds.
264 native SetEntDataVector(entity, offset, const Float:vec[3]);