plugins/include/entity.inc
changeset 1952 b7aa2b626807
child 2098 763afb5d7ddf
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/entity.inc	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,677 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 + 
    1.36 +#if defined _entity_included
    1.37 + #endinput
    1.38 +#endif
    1.39 +#define _entity_included
    1.40 +
    1.41 +/**
    1.42 + * Property types for entities.
    1.43 + */
    1.44 +enum PropType
    1.45 +{
    1.46 +	Prop_Send = 0,	/**< This property is networked. */
    1.47 +	Prop_Data = 1,	/**< This property is for save game data fields. */
    1.48 +};
    1.49 +
    1.50 +/**
    1.51 + * @section For more information on these, see the HL2SDK (public/edict.h)
    1.52 + */
    1.53 +#define FL_EDICT_CHANGED		(1<<0)	/**< Game DLL sets this when the entity state changes
    1.54 +										 Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */
    1.55 +#define FL_EDICT_FREE			(1<<1)	/**< this edict if free for reuse */
    1.56 +#define FL_EDICT_FULL			(1<<2)	/**< this is a full server entity */
    1.57 +#define FL_EDICT_FULLCHECK		(0<<0)  /**< call ShouldTransmit() each time, this is a fake flag */
    1.58 +#define FL_EDICT_ALWAYS			(1<<3)	/**< always transmit this entity */
    1.59 +#define FL_EDICT_DONTSEND		(1<<4)	/**< don't transmit this entity */
    1.60 +#define FL_EDICT_PVSCHECK		(1<<5)	/**< always transmit entity, but cull against PVS */
    1.61 +#define FL_EDICT_PENDING_DORMANT_CHECK	(1<<6)
    1.62 +#define FL_EDICT_DIRTY_PVS_INFORMATION	(1<<7)
    1.63 +#define FL_FULL_EDICT_CHANGED		(1<<8)
    1.64 +
    1.65 +enum PropFieldType
    1.66 +{
    1.67 +	PropField_Unsupported,		/**< The type is unsupported. */
    1.68 +	PropField_Integer,			/**< Valid for SendProp and Data fields */
    1.69 +	PropField_Float,			/**< Valid for SendProp and Data fields */
    1.70 +	PropField_Entity,			/**< Valid for Data fields only (SendProp shows as int) */
    1.71 +	PropField_Vector,			/**< Valid for SendProp and Data fields */
    1.72 +	PropField_String,			/**< Valid for SendProp and Data fields */
    1.73 +	PropField_String_T,			/**< Valid for Data fields.  Read only.  
    1.74 +									 Note that the size of a string_t is dynamic, and 
    1.75 +									 thus FindDataMapOffs() will return the constant size 
    1.76 +									 of the string_t container (which is 32 bits right now).
    1.77 +								 */
    1.78 +};
    1.79 +
    1.80 +/**
    1.81 + * @endsection
    1.82 + */
    1.83 +
    1.84 +/**
    1.85 + * Returns the maximum number of entities.
    1.86 + *
    1.87 + * @return				Maximum number of entities.
    1.88 + */
    1.89 +native GetMaxEntities();
    1.90 +
    1.91 +/**
    1.92 + * Returns the number of entities in the server.
    1.93 + *
    1.94 + * @return				Number of entities in the server.
    1.95 + */
    1.96 +native GetEntityCount();
    1.97 +
    1.98 +/**
    1.99 + * Returns whether or not an entity is valid.  Returns false
   1.100 + * if there is no matching CBaseEntity for this edict index.
   1.101 + *
   1.102 + * @param edict			Index of the entity/edict.
   1.103 + * @return				True if valid, false otherwise.
   1.104 + */
   1.105 +native bool:IsValidEntity(edict);
   1.106 +
   1.107 +/**
   1.108 + * Returns whether or not an edict index is valid.
   1.109 + *
   1.110 + * @param edict			Index of the edict.
   1.111 + * @return				True if valid, false otherwise.
   1.112 + */
   1.113 +native bool:IsValidEdict(edict);
   1.114 +
   1.115 +/**
   1.116 + * Returns whether or not an entity is a valid networkable edict.
   1.117 + *
   1.118 + * @param edict			Index of the edict.
   1.119 + * @return				True if networkable, false if invalid or not networkable.
   1.120 + */
   1.121 +native bool:IsEntNetworkable(edict);
   1.122 +
   1.123 +/**
   1.124 + * Creates a new edict (the basis of a networkable entity)
   1.125 + *
   1.126 + * @return				Index of the edict, 0 on failure.
   1.127 + */
   1.128 +native CreateEdict();
   1.129 +
   1.130 +/** 
   1.131 + * Removes an edict from the world.
   1.132 + *
   1.133 + * @param edict			Index of the edict.
   1.134 + * @noreturn
   1.135 + * @error				Invalid edict index.
   1.136 + */
   1.137 +native RemoveEdict(edict);
   1.138 +
   1.139 +/**
   1.140 + * Returns the flags on an edict.  These are not the same as entity flags.
   1.141 + *
   1.142 + * @param edict			Index of the entity.
   1.143 + * @return				Edict flags.
   1.144 + * @error				Invalid edict index.
   1.145 + */
   1.146 +native GetEdictFlags(edict);
   1.147 +
   1.148 +/**
   1.149 + * Sets the flags on an edict.  These are not the same as entity flags.
   1.150 + *
   1.151 + * @param edict			Index of the entity.
   1.152 + * @param flags			Flags to set.
   1.153 + * @noreturn
   1.154 + * @error				Invalid edict index.
   1.155 + */
   1.156 +native SetEdictFlags(edict, flags);
   1.157 +
   1.158 +/**
   1.159 + * Retrieves an edict classname.
   1.160 + *
   1.161 + * @param edict			Index of the entity.
   1.162 + * @param clsname		Buffer to store the classname.
   1.163 + * @param maxlength		Maximum length of the buffer.
   1.164 + * @return				True on success, false if there is no classname set.
   1.165 + */
   1.166 +native bool:GetEdictClassname(edict, String:clsname[], maxlength);
   1.167 +
   1.168 +/**
   1.169 + * Retrieves an entity's networkable serverclass name.
   1.170 + * This is not the same as the classname and is used for networkable state changes.
   1.171 + *
   1.172 + * @param edict			Index of the entity.
   1.173 + * @param clsname		Buffer to store the serverclass name.
   1.174 + * @param maxlength		Maximum lnegth of the buffer.
   1.175 + * @return				True on success, false if the edict is not networkable.
   1.176 + * @error				Invalid edict index.
   1.177 + */
   1.178 +native bool:GetEntityNetClass(edict, String:clsname[], maxlength);
   1.179 +
   1.180 +/**
   1.181 + * @section Entity offset functions
   1.182 + *
   1.183 + * Offsets should be specified in byte distance from the CBaseEntity 
   1.184 + * structure, not short (double byte) or integer (four byte) multiples.  
   1.185 + * It is somewhat common practice to use offsets aligned to their final 
   1.186 + * type, and thus make sure you are not falling to this error in SourceMod.
   1.187 + * For example, if your "integer-aligned" offset was 119, your byte-aligned
   1.188 + * offset is 119*4, or 476.
   1.189 + 
   1.190 + * Specifying incorrect offsets or the incorrect data type for an offset
   1.191 + * can have fatal consequences.  If you are hardcoding offsets, and the 
   1.192 + * layout of CBaseEntity does not match, you can easily crash the server.
   1.193 + *
   1.194 + * The reasonable bounds for offsets is greater than or equal to 0 and 
   1.195 + * below 32768.  Offsets out of these bounds will throw an error.  However,
   1.196 + * this does not represent any real range, it is simply a sanity check for
   1.197 + * illegal values.  Any range outside of the CBaseEntity structure's private
   1.198 + * size will cause undefined behaviour or even crash.
   1.199 + */
   1.200 + 
   1.201 +/**
   1.202 + * Marks an entity as state changed.  This can be useful if you set an offset 
   1.203 + * and wish for it to be immediately changed over the network.  By default this 
   1.204 + * is not done for offset setting functions.  
   1.205 + *
   1.206 + * @param edict			Index to the edict.
   1.207 + * @param offset		Offset to mark as changed.  If 0, 
   1.208 + *						the entire edict is marked as changed.
   1.209 + * @noreturn
   1.210 + * @error				Invalid entity or offset out of bounds.
   1.211 + */
   1.212 +native ChangeEdictState(edict, offset = 0);
   1.213 +
   1.214 +/**
   1.215 + * Peeks into an entity's object data and retrieves the integer value at 
   1.216 + * the given offset.
   1.217 + * 
   1.218 + * @param entity		Edict index.
   1.219 + * @param offset		Offset to use.
   1.220 + * @param size			Number of bytes to read (valid values are 1, 2, or 4).
   1.221 + * @return				Value at the given memory location.
   1.222 + * @error				Invalid entity or offset out of reasonable bounds.
   1.223 + */
   1.224 +native GetEntData(entity, offset, size=4);
   1.225 +
   1.226 +/**
   1.227 + * Peeks into an entity's object data and sets the integer value at 
   1.228 + * the given offset.
   1.229 + *
   1.230 + * @param entity		Edict index.
   1.231 + * @param offset		Offset to use.
   1.232 + * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   1.233 + * @param changeState	If true, change will be sent over the network.
   1.234 + * @return				Value at the given memory location.
   1.235 + * @error				Invalid entity or offset out of reasonable bounds.
   1.236 + * @noreturn
   1.237 + */
   1.238 +native SetEntData(entity, offset, any:value, size=4, bool:changeState=false);
   1.239 +
   1.240 +/**
   1.241 + * Peeks into an entity's object data and retrieves the float value at 
   1.242 + * the given offset.
   1.243 + * 
   1.244 + * @param entity		Edict index.
   1.245 + * @param offset		Offset to use.
   1.246 + * @return				Value at the given memory location.
   1.247 + * @error				Invalid entity or offset out of reasonable bounds.
   1.248 + */
   1.249 +native Float:GetEntDataFloat(entity, offset);
   1.250 +
   1.251 +/**
   1.252 + * Peeks into an entity's object data and sets the integer value at 
   1.253 + * the given offset.
   1.254 + *
   1.255 + * @param entity		Edict index.
   1.256 + * @param offset		Offset to use.
   1.257 + * @param changeState	If true, change will be sent over the network.
   1.258 + * @return				Value at the given memory location.
   1.259 + * @error				Invalid entity or offset out of reasonable bounds.
   1.260 + * @noreturn
   1.261 + */
   1.262 +native SetEntDataFloat(entity, offset, Float:value, bool:changeState=false);
   1.263 +
   1.264 +/**
   1.265 + * This function is deprecated.  Use GetEntDataEnt2 instead, for 
   1.266 + * reasons explained in the notes.
   1.267 + *
   1.268 + * Note: This function returns 0 on failure, which may be misleading, 
   1.269 + * as the number 0 is also used for the world entity index.
   1.270 + *
   1.271 + * Note: This function makes no attempt to validate the returned 
   1.272 + * entity, and in fact, it could be garbage or completely unexpected.
   1.273 + * 
   1.274 + * @param entity		Edict index.
   1.275 + * @param offset		Offset to use.
   1.276 + * @return				Entity index at the given location, or 0 if none.
   1.277 + * @error				Invalid entity or offset out of reasonable bounds.
   1.278 + */
   1.279 +native GetEntDataEnt(entity, offset);
   1.280 +
   1.281 +/**
   1.282 + * This function is deprecated.   Use GetEntDataEnt2 instead, for 
   1.283 + * reasons explained in the notes.
   1.284 + *
   1.285 + * Note: This function uses 0 as an indicator to unset data, but 
   1.286 + * 0 is also the world entity index.  Thus, the a property cannot 
   1.287 + * be set to the world entity using this native.
   1.288 + * 
   1.289 + * @param entity		Edict index.
   1.290 + * @param offset		Offset to use.
   1.291 + * @param other			Entity index to set, or 0 to clear.
   1.292 + * @param changeState	If true, change will be sent over the network.
   1.293 + * @noreturn
   1.294 + * @error				Invalid entity or offset out of reasonable bounds.
   1.295 + */
   1.296 +native SetEntDataEnt(entity, offset, other, bool:changeState=false);
   1.297 +
   1.298 +/**
   1.299 + * Peeks into an entity's object data and retrieves the entity index 
   1.300 + * at the given offset.
   1.301 + *
   1.302 + * Note: This will only work on offsets that are stored as "entity 
   1.303 + * handles" (which usually looks like m_h* in properties).  These 
   1.304 + * are not SourceMod Handles, but internal Source structures.
   1.305 + * 
   1.306 + * @param entity		Edict index.
   1.307 + * @param offset		Offset to use.
   1.308 + * @return				Entity index at the given location.  If there is no entity, 
   1.309 + *						or the stored entity is invalid, then -1 is returned.
   1.310 + * @error				Invalid input entity, or offset out of reasonable bounds.
   1.311 + */
   1.312 +native GetEntDataEnt2(entity, offset);
   1.313 +
   1.314 +/**
   1.315 + * Peeks into an entity's object data and sets the entity index at the 
   1.316 + * given offset.
   1.317 + *
   1.318 + * Note: This will only work on offsets that are stored as "entity 
   1.319 + * handles" (which usually looks like m_h* in properties).  These 
   1.320 + * are not SourceMod Handles, but internal Source structures.
   1.321 + * 
   1.322 + * @param entity		Edict index.
   1.323 + * @param offset		Offset to use.
   1.324 + * @param other			Entity index to set, or -1 to clear.
   1.325 + * @param changeState	If true, change will be sent over the network.
   1.326 + * @noreturn
   1.327 + * @error				Invalid input entity, or offset out of reasonable bounds.
   1.328 + */
   1.329 +native SetEntDataEnt2(entity, offset, other, bool:changeState=false);
   1.330 +
   1.331 +/**
   1.332 + * Peeks into an entity's object data and retrieves the vector at the 
   1.333 + * given offset.
   1.334 + * @note Both a Vector and a QAngle are three floats.  This is a 
   1.335 + * convenience function and will work with both types.
   1.336 + * 
   1.337 + * @param entity		Edict index.
   1.338 + * @param offset		Offset to use.
   1.339 + * @param vec			Vector buffer to store data in.
   1.340 + * @noreturn
   1.341 + * @error				Invalid entity or offset out of reasonable bounds.
   1.342 + */
   1.343 +native GetEntDataVector(entity, offset, Float:vec[3]);
   1.344 +
   1.345 +/**
   1.346 + * Peeks into an entity's object data and sets the vector at the given 
   1.347 + * offset.
   1.348 + * @note Both a Vector and a QAngle are three floats.  This is a 
   1.349 + * convenience function and will work with both types.
   1.350 + * 
   1.351 + * @param entity		Edict index.
   1.352 + * @param offset		Offset to use.
   1.353 + * @param vec			Vector to set.
   1.354 + * @param changeState	If true, change will be sent over the network.
   1.355 + * @noreturn
   1.356 + * @error				Invalid entity or offset out of reasonable bounds.
   1.357 + */
   1.358 +native SetEntDataVector(entity, offset, const Float:vec[3], bool:changeState=false);
   1.359 +
   1.360 +/**
   1.361 + * Peeks into an entity's object data and retrieves the string at 
   1.362 + * the given offset.
   1.363 + * 
   1.364 + * @param entity		Edict index.
   1.365 + * @param offset		Offset to use.
   1.366 + * @param buffer		Destination string buffer.
   1.367 + * @param maxlen		Maximum length of output string buffer.
   1.368 + * @return			Number of non-null bytes written.
   1.369 + * @error				Invalid entity or offset out of reasonable bounds.
   1.370 + */
   1.371 +native GetEntDataString(entity, offset, String:buffer[], maxlen);
   1.372 +
   1.373 +/**
   1.374 + * Peeks into an entity's object data and sets the string at 
   1.375 + * the given offset.
   1.376 + * 
   1.377 + * @param entity		Edict index.
   1.378 + * @param offset		Offset to use.
   1.379 + * @param buffer		String to set.
   1.380 + * @param maxlen		Maximum length of bytes to write.
   1.381 + * @param changeState	If true, change will be sent over the network.
   1.382 + * @return			Number of non-null bytes written.
   1.383 + * @error				Invalid entity or offset out of reasonable bounds.
   1.384 + */
   1.385 +native SetEntDataString(entity, offset, const String:buffer[], maxlen, bool:changeState=false);
   1.386 +
   1.387 +/**
   1.388 + * @endsection
   1.389 + */
   1.390 +
   1.391 +/**
   1.392 + * Given a ServerClass name, finds a networkable send property offset.
   1.393 + * This information is cached for future calls.
   1.394 + *
   1.395 + * Note, this function may return offsets that do not work!
   1.396 + * If a property is nested beneath a parent object, the resulting offset 
   1.397 + * will be invalid for direct use with data functions.  Therefore, you 
   1.398 + * should use FindSendPropInfo() instead.  An example of such a property is 
   1.399 + * CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress.
   1.400 + *
   1.401 + * @param cls			Classname.
   1.402 + * @param prop			Property name.
   1.403 + * @return				An offset, or -1 on failure.
   1.404 + */
   1.405 +native FindSendPropOffs(const String:cls[], const String:prop[]);
   1.406 +
   1.407 +/**
   1.408 + * Given a ServerClass name, finds a networkable send property offset.
   1.409 + * This information is cached for future calls.
   1.410 + * 
   1.411 + * Note: This function will correctly compute nested offsets, unlike 
   1.412 + * FindSendPropOffs().  YOU SHOULD NOT use this function to self-compute 
   1.413 + * nested offsets.  For example, it is okay to add indexes for arrays, 
   1.414 + * but not to add DT_LocalPlayer to m_nDisguiseClass.
   1.415 + *
   1.416 + * @param cls			Classname.
   1.417 + * @param prop			Property name.
   1.418 + * @param type			Optional parameter to store the type.
   1.419 + * @param num_bits		Optional parameter to store the number of bits the field 
   1.420 + *						uses, if applicable (otherwise 0 is stored).  The number 
   1.421 + *						of bits varies for integers and floats, and is always 0 
   1.422 + * 						for strings.
   1.423 + * @param local_offset	Optional parameter to store the local offset, as 
   1.424 + *						FindSendPropOffs() would return.
   1.425 + * @return				On success, returns an absolutely computed offset.
   1.426 + *						If no offset is available, 0 is returned.
   1.427 + *						If the property is not found, -1 is returned.
   1.428 + */
   1.429 +native FindSendPropInfo(const String:cls[], 
   1.430 +						const String:prop[], 
   1.431 +						&PropFieldType:type=PropFieldType:0,
   1.432 +						&num_bits=0,
   1.433 +						&local_offset=0);
   1.434 +
   1.435 +/**
   1.436 + * Given an entity, finds a datamap property offset.
   1.437 + * This information is cached for future calls.
   1.438 + *
   1.439 + * @param entity		Entity index.
   1.440 + * @param prop			Property name.
   1.441 + * @param type			Optional parameter to store the type.
   1.442 + * @param num_bits		Optional parameter to store the number of bits the field 
   1.443 + *						uses.  The bit count will either be 1 (for boolean) or 
   1.444 + *						divisible by 8 (including 0 if unknown).
   1.445 + * @return				An offset, or -1 on failure.
   1.446 + */
   1.447 +native FindDataMapOffs(entity, 
   1.448 +					   const String:prop[],
   1.449 +					   &PropFieldType:type=PropFieldType:0,
   1.450 +					   &num_bits=0);
   1.451 +
   1.452 +/**
   1.453 + * Wrapper function for finding a send property for a particular entity.
   1.454 + *
   1.455 + * @param ent			Entity index.
   1.456 + * @param prop			Property name.
   1.457 + * @param actual		Defaults to false for backwards compatibility.
   1.458 + *						If true, the newer FindSendPropInfo() function 
   1.459 + *						is used instead.
   1.460 + * @return				An offset, or -1 on failure.
   1.461 + */
   1.462 +stock GetEntSendPropOffs(ent, const String:prop[], bool:actual=false)
   1.463 +{
   1.464 +	decl String:cls[64];
   1.465 +	
   1.466 +	if (!GetEntityNetClass(ent, cls, sizeof(cls)))
   1.467 +	{
   1.468 +		return -1;
   1.469 +	}
   1.470 +	
   1.471 +	if (actual)
   1.472 +	{
   1.473 +		return FindSendPropInfo(cls, prop);
   1.474 +	}
   1.475 +	else
   1.476 +	{
   1.477 +		return FindSendPropOffs(cls, prop);
   1.478 +	}
   1.479 +}
   1.480 +
   1.481 +/**
   1.482 + * Retrieves an integer value from an entity's property.
   1.483 + *
   1.484 + * This function is considered safer and more robust over GetEntData, 
   1.485 + * because it performs strict offset checking and typing rules.  There is a 
   1.486 + * very minor performance hit from this.
   1.487 + * 
   1.488 + * @param entity		Entity/edict index.
   1.489 + * @param type			Property type.
   1.490 + * @param prop			Property name.
   1.491 + * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   1.492 + *						This value is auto-detected, and the size parameter is 
   1.493 + *						only used as a fallback in case detection fails.
   1.494 + * @return				Value at the given property offset.
   1.495 + * @error				Invalid entity or property not found.
   1.496 + */
   1.497 +native GetEntProp(entity, PropType:type, const String:prop[], size=4);
   1.498 +
   1.499 +/**
   1.500 + * Sets an integer value in an entity's property.
   1.501 + *
   1.502 + * This function is considered safer and more robust over SetEntData, 
   1.503 + * because it performs strict offset checking and typing rules.  There is a 
   1.504 + * very minor performance hit from this.
   1.505 + * 
   1.506 + * @param entity		Entity/edict index.
   1.507 + * @param type			Property type.
   1.508 + * @param prop			Property name.
   1.509 + * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   1.510 + *						This value is auto-detected, and the size parameter is 
   1.511 + *						only used as a fallback in case detection fails.
   1.512 + * @error				Invalid entity or offset out of reasonable bounds.
   1.513 + * @noreturn
   1.514 + */
   1.515 +native SetEntProp(entity, PropType:type, const String:prop[], any:value, size=4);
   1.516 +
   1.517 +/**
   1.518 + * Retrieves a float value from an entity's property.
   1.519 + *
   1.520 + * This function is considered safer and more robust over GetEntDataFloat, 
   1.521 + * because it performs strict offset checking and typing rules.  There is a 
   1.522 + * very minor performance hit from this.
   1.523 + * 
   1.524 + * @param entity		Entity/edict index.
   1.525 + * @param type			Property type.
   1.526 + * @param prop			Property name.
   1.527 + * @return				Value at the given property offset.
   1.528 + * @error				Invalid entity or offset out of reasonable bounds.
   1.529 + */
   1.530 +native Float:GetEntPropFloat(entity, PropType:type, const String:prop[]);
   1.531 +
   1.532 +/**
   1.533 + * Sets a float value in an entity's property.
   1.534 + *
   1.535 + * This function is considered safer and more robust over SetEntDataFloat, 
   1.536 + * because it performs strict offset checking and typing rules.  There is a 
   1.537 + * very minor performance hit from this.
   1.538 + * 
   1.539 + * @param entity		Entity/edict index.
   1.540 + * @param type			Property type.
   1.541 + * @param prop			Property name.
   1.542 + * @param value			Value to set.
   1.543 + * @noreturn
   1.544 + * @error				Invalid entity or offset out of reasonable bounds.
   1.545 + */
   1.546 +native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);
   1.547 +
   1.548 +/**
   1.549 + * Retrieves an entity index from an entity's property.
   1.550 + *
   1.551 + * This function is considered safer and more robust over GetEntDataEnt*, 
   1.552 + * because it performs strict offset checking and typing rules.  There is a 
   1.553 + * very minor performance hit from this.
   1.554 + * 
   1.555 + * @param entity		Entity/edict index.
   1.556 + * @param type			Property type.
   1.557 + * @param prop			Property name.
   1.558 + * @return				Entity index at the given property.
   1.559 + *						If there is no entity, or the entity is not valid, 
   1.560 + *						then -1 is returned.
   1.561 + * @error				Invalid entity or offset out of reasonable bounds.
   1.562 + */
   1.563 +native GetEntPropEnt(entity, PropType:type, const String:prop[]);
   1.564 +
   1.565 +/**
   1.566 + * Sets an entity index in an entity's property.
   1.567 + *
   1.568 + * This function is considered safer and more robust over SetEntDataEnt*, 
   1.569 + * because it performs strict offset checking and typing rules.  There is a 
   1.570 + * very minor performance hit from this.
   1.571 + * 
   1.572 + * @param entity		Entity/edict index.
   1.573 + * @param type			Property type.
   1.574 + * @param prop			Property name.
   1.575 + * @param other			Entity index to set, or -1 to unset.
   1.576 + * @noreturn
   1.577 + * @error				Invalid entity or offset out of reasonable bounds.
   1.578 + */
   1.579 +native SetEntPropEnt(entity, PropType:type, const String:prop[], other);
   1.580 +
   1.581 +/**
   1.582 + * Retrieves a vector of floats from an entity, given a named network property.
   1.583 + *
   1.584 + * This function is considered safer and more robust over GetEntDataVector, 
   1.585 + * because it performs strict offset checking and typing rules.  There is a 
   1.586 + * very minor performance hit from this.
   1.587 + * 
   1.588 + * @param entity		Entity/edict index.
   1.589 + * @param type			Property type.
   1.590 + * @param prop			Property name.
   1.591 + * @param vec			Vector buffer to store data in.
   1.592 + * @noreturn
   1.593 + * @error				Invalid entity, property not found, or property not 
   1.594 + *						actually a vector data type.
   1.595 + */
   1.596 +native GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3]);
   1.597 +
   1.598 +/**
   1.599 + * Sets a vector of floats in an entity, given a named network property.
   1.600 + *
   1.601 + * This function is considered safer and more robust over SetEntDataVector, 
   1.602 + * because it performs strict offset checking and typing rules.  There is a 
   1.603 + * very minor performance hit from this.
   1.604 + * 
   1.605 + * @param entity		Entity/edict index.
   1.606 + * @param type			Property type.
   1.607 + * @param prop			Property name.
   1.608 + * @param vec			Vector to set.
   1.609 + * @noreturn
   1.610 + * @error				Invalid entity, property not found, or property not 
   1.611 + *						actually a vector data type.
   1.612 + */
   1.613 +native SetEntPropVector(entity, PropType:type, const String:prop[], const Float:vec[3]);
   1.614 +
   1.615 +/**
   1.616 + * Gets a network property as a string.
   1.617 + * 
   1.618 + * @param entity		Edict index.
   1.619 + * @param type			Property type.
   1.620 + * @param prop			Property to use.
   1.621 + * @param buffer		Destination string buffer.
   1.622 + * @param maxlen		Maximum length of output string buffer.		
   1.623 + * @return				Number of non-null bytes written.
   1.624 + * @error				Invalid entity, offset out of reasonable bounds, or property is not a valid string.
   1.625 + */
   1.626 +native GetEntPropString(entity, PropType:type, const String:prop[], String:buffer[], maxlen);
   1.627 +
   1.628 +/**
   1.629 + * Sets a network property as a string.
   1.630 + *
   1.631 + * This cannot set property fields of type PropField_String_T (such as "m_target").
   1.632 + * To set such fields, you should use DispatchKeyValue() from SDKTools.
   1.633 + * 
   1.634 + * @param entity		Edict index.
   1.635 + * @param type			Property type.
   1.636 + * @param prop			Property to use.
   1.637 + * @param buffer		String to set.		
   1.638 + * @return				Number of non-null bytes written.
   1.639 + * @error				Invalid entity, offset out of reasonable bounds, or property is not a valid string.
   1.640 + */
   1.641 +native SetEntPropString(entity, PropType:type, const String:prop[], const String:buffer[]);
   1.642 +
   1.643 +/**
   1.644 + * Copies an array of cells from an entity at a given offset.
   1.645 + *
   1.646 + * @param entity		Entity index.
   1.647 + * @param offset		Offset to use.
   1.648 + * @param array			Array to read into.
   1.649 + * @param arraySize		Number of values to read.
   1.650 + * @param dataSize		Size of each value in bytes (1, 2, or 4).
   1.651 + * @noreturn
   1.652 + * @error				Invalid entity or offset out of reasonable bounds.
   1.653 + */
   1.654 +stock GetEntDataArray(entity, offset, array[], arraySize, dataSize=4)
   1.655 +{
   1.656 +	for (new i=0; i<arraySize; i++)
   1.657 +	{
   1.658 +		array[i] = GetEntData(entity, offset + i*dataSize, dataSize)
   1.659 +	}
   1.660 +}
   1.661 +
   1.662 +/**
   1.663 + * Copies an array of cells to an entity at a given offset.
   1.664 + *
   1.665 + * @param entity		Entity index.
   1.666 + * @param offset		Offset to use.
   1.667 + * @param array			Array of values to copy.
   1.668 + * @param arraySize		Number of values to copy.
   1.669 + * @param dataSize		Size of each value in bytes (1, 2, or 4).
   1.670 + * @param changeState	True to set the network state as changed; false otherwise.
   1.671 + * @noreturn
   1.672 + * @error				Invalid entity or offset out of reasonable bounds.
   1.673 + */
   1.674 +stock SetEntDataArray(entity, offset, const array[], arraySize, dataSize=4, bool:changeState=false)
   1.675 +{
   1.676 +	for (new i=0; i<arraySize; i++)
   1.677 +	{
   1.678 +		SetEntData(entity, offset + i*dataSize, array[i], dataSize, changeState);
   1.679 +	}
   1.680 +}