plugins/include/entity.inc
author David Anderson <dvander@alliedmods.net>
Tue Jan 22 17:04:59 2008 +0000 (2008-01-22)
changeset 1854 91f2e0437e12
parent 1847 5336a438763f
child 1884 9ca6aacb1400
permissions -rw-r--r--
added amb1378 - FileExists() for valve fs
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32  
    33 #if defined _entity_included
    34  #endinput
    35 #endif
    36 #define _entity_included
    37 
    38 /**
    39  * Property types for entities.
    40  */
    41 enum PropType
    42 {
    43 	Prop_Send = 0,	/**< This property is networked. */
    44 	Prop_Data = 1,	/**< This property is for save game data fields. */
    45 };
    46 
    47 /**
    48  * @section For more information on these, see the HL2SDK (public/edict.h)
    49  */
    50 #define FL_EDICT_CHANGED		(1<<0)	/**< Game DLL sets this when the entity state changes
    51 										 Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */
    52 #define FL_EDICT_FREE			(1<<1)	/**< this edict if free for reuse */
    53 #define FL_EDICT_FULL			(1<<2)	/**< this is a full server entity */
    54 #define FL_EDICT_FULLCHECK		(0<<0)  /**< call ShouldTransmit() each time, this is a fake flag */
    55 #define FL_EDICT_ALWAYS			(1<<3)	/**< always transmit this entity */
    56 #define FL_EDICT_DONTSEND		(1<<4)	/**< don't transmit this entity */
    57 #define FL_EDICT_PVSCHECK		(1<<5)	/**< always transmit entity, but cull against PVS */
    58 #define FL_EDICT_PENDING_DORMANT_CHECK	(1<<6)
    59 #define FL_EDICT_DIRTY_PVS_INFORMATION	(1<<7)
    60 #define FL_FULL_EDICT_CHANGED		(1<<8)
    61 
    62 enum PropFieldType
    63 {
    64 	PropField_Unsupported,		/**< The type is unsupported. */
    65 	PropField_Integer,			/**< Valid for SendProp and Data fields */
    66 	PropField_Float,			/**< Valid for SendProp and Data fields */
    67 	PropField_Entity,			/**< Valid for Data fields only (SendProp shows as int) */
    68 	PropField_Vector,			/**< Valid for SendProp and Data fields */
    69 	PropField_String,			/**< Valid for SendProp and Data fields */
    70 };
    71 
    72 /**
    73  * @endsection
    74  */
    75 
    76 /**
    77  * Returns the maximum number of entities.
    78  *
    79  * @return				Maximum number of entities.
    80  */
    81 native GetMaxEntities();
    82 
    83 /**
    84  * Returns the number of entities in the server.
    85  *
    86  * @return				Number of entities in the server.
    87  */
    88 native GetEntityCount();
    89 
    90 /**
    91  * Returns whether or not an entity is valid.  Returns false
    92  * if there is no matching CBaseEntity for this edict index.
    93  *
    94  * @param edict			Index of the entity/edict.
    95  * @return				True if valid, false otherwise.
    96  */
    97 native bool:IsValidEntity(edict);
    98 
    99 /**
   100  * Returns whether or not an edict index is valid.
   101  *
   102  * @param edict			Index of the edict.
   103  * @return				True if valid, false otherwise.
   104  */
   105 native bool:IsValidEdict(edict);
   106 
   107 /**
   108  * Returns whether or not an entity is a valid networkable edict.
   109  *
   110  * @param edict			Index of the edict.
   111  * @return				True if networkable, false if invalid or not networkable.
   112  */
   113 native bool:IsEntNetworkable(edict);
   114 
   115 /**
   116  * Creates a new edict (the basis of a networkable entity)
   117  *
   118  * @return				Index of the edict, 0 on failure.
   119  */
   120 native CreateEdict();
   121 
   122 /** 
   123  * Removes an edict from the world.
   124  *
   125  * @param edict			Index of the edict.
   126  * @noreturn
   127  * @error				Invalid edict index.
   128  */
   129 native RemoveEdict(edict);
   130 
   131 /**
   132  * Returns the flags on an edict.  These are not the same as entity flags.
   133  *
   134  * @param edict			Index of the entity.
   135  * @return				Edict flags.
   136  * @error				Invalid edict index.
   137  */
   138 native GetEdictFlags(edict);
   139 
   140 /**
   141  * Sets the flags on an edict.  These are not the same as entity flags.
   142  *
   143  * @param edict			Index of the entity.
   144  * @param flags			Flags to set.
   145  * @noreturn
   146  * @error				Invalid edict index.
   147  */
   148 native SetEdictFlags(edict, flags);
   149 
   150 /**
   151  * Retrieves an edict classname.
   152  *
   153  * @param edict			Index of the entity.
   154  * @param clsname		Buffer to store the classname.
   155  * @param maxlength		Maximum length of the buffer.
   156  * @return				True on success, false if there is no classname set.
   157  */
   158 native bool:GetEdictClassname(edict, String:clsname[], maxlength);
   159 
   160 /**
   161  * Retrieves an entity's networkable serverclass name.
   162  * This is not the same as the classname and is used for networkable state changes.
   163  *
   164  * @param edict			Index of the entity.
   165  * @param clsname		Buffer to store the serverclass name.
   166  * @param maxlength		Maximum lnegth of the buffer.
   167  * @return				True on success, false if the edict is not networkable.
   168  * @error				Invalid edict index.
   169  */
   170 native bool:GetEntityNetClass(edict, String:clsname[], maxlength);
   171 
   172 /**
   173  * @section Entity offset functions
   174  *
   175  * Offsets should be specified in byte distance from the CBaseEntity 
   176  * structure, not short (double byte) or integer (four byte) multiples.  
   177  * It is somewhat common practice to use offsets aligned to their final 
   178  * type, and thus make sure you are not falling to this error in SourceMod.
   179  * For example, if your "integer-aligned" offset was 119, your byte-aligned
   180  * offset is 119*4, or 476.
   181  
   182  * Specifying incorrect offsets or the incorrect data type for an offset
   183  * can have fatal consequences.  If you are hardcoding offsets, and the 
   184  * layout of CBaseEntity does not match, you can easily crash the server.
   185  *
   186  * The reasonable bounds for offsets is greater than or equal to 0 and 
   187  * below 32768.  Offsets out of these bounds will throw an error.  However,
   188  * this does not represent any real range, it is simply a sanity check for
   189  * illegal values.  Any range outside of the CBaseEntity structure's private
   190  * size will cause undefined behaviour or even crash.
   191  */
   192  
   193 /**
   194  * Marks an entity as state changed.  This can be useful if you set an offset 
   195  * and wish for it to be immediately changed over the network.  By default this 
   196  * is not done for offset setting functions.  
   197  *
   198  * @param edict			Index to the edict.
   199  * @param offset		Offset to mark as changed.  If 0, 
   200  *						the entire edict is marked as changed.
   201  * @noreturn
   202  * @error				Invalid entity or offset out of bounds.
   203  */
   204 native ChangeEdictState(edict, offset = 0);
   205 
   206 /**
   207  * Peeks into an entity's object data and retrieves the integer value at 
   208  * the given offset.
   209  * 
   210  * @param entity		Edict index.
   211  * @param offset		Offset to use.
   212  * @param size			Number of bytes to read (valid values are 1, 2, or 4).
   213  * @return				Value at the given memory location.
   214  * @error				Invalid entity or offset out of reasonable bounds.
   215  */
   216 native GetEntData(entity, offset, size=4);
   217 
   218 /**
   219  * Peeks into an entity's object data and sets the integer value at 
   220  * the given offset.
   221  *
   222  * @param entity		Edict index.
   223  * @param offset		Offset to use.
   224  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   225  * @param changeState	If true, change will be sent over the network.
   226  * @return				Value at the given memory location.
   227  * @error				Invalid entity or offset out of reasonable bounds.
   228  * @noreturn
   229  */
   230 native SetEntData(entity, offset, any:value, size=4, bool:changeState=false);
   231 
   232 /**
   233  * Peeks into an entity's object data and retrieves the float value at 
   234  * the given offset.
   235  * 
   236  * @param entity		Edict index.
   237  * @param offset		Offset to use.
   238  * @return				Value at the given memory location.
   239  * @error				Invalid entity or offset out of reasonable bounds.
   240  */
   241 native Float:GetEntDataFloat(entity, offset);
   242 
   243 /**
   244  * Peeks into an entity's object data and sets the integer value at 
   245  * the given offset.
   246  *
   247  * @param entity		Edict index.
   248  * @param offset		Offset to use.
   249  * @param changeState	If true, change will be sent over the network.
   250  * @return				Value at the given memory location.
   251  * @error				Invalid entity or offset out of reasonable bounds.
   252  * @noreturn
   253  */
   254 native SetEntDataFloat(entity, offset, Float:value, bool:changeState=false);
   255 
   256 /**
   257  * This function is deprecated.  Use GetEntDataEnt2 instead, for 
   258  * reasons explained in the notes.
   259  *
   260  * Note: This function returns 0 on failure, which may be misleading, 
   261  * as the number 0 is also used for the world entity index.
   262  *
   263  * Note: This function makes no attempt to validate the returned 
   264  * entity, and in fact, it could be garbage or completely unexpected.
   265  * 
   266  * @param entity		Edict index.
   267  * @param offset		Offset to use.
   268  * @return				Entity index at the given location, or 0 if none.
   269  * @error				Invalid entity or offset out of reasonable bounds.
   270  */
   271 native GetEntDataEnt(entity, offset);
   272 
   273 /**
   274  * This function is deprecated.   Use GetEntDataEnt2 instead, for 
   275  * reasons explained in the notes.
   276  *
   277  * Note: This function uses 0 as an indicator to unset data, but 
   278  * 0 is also the world entity index.  Thus, the a property cannot 
   279  * be set to the world entity using this native.
   280  * 
   281  * @param entity		Edict index.
   282  * @param offset		Offset to use.
   283  * @param other			Entity index to set, or 0 to clear.
   284  * @param changeState	If true, change will be sent over the network.
   285  * @noreturn
   286  * @error				Invalid entity or offset out of reasonable bounds.
   287  */
   288 native SetEntDataEnt(entity, offset, other, bool:changeState=false);
   289 
   290 /**
   291  * Peeks into an entity's object data and retrieves the entity index 
   292  * at the given offset.
   293  *
   294  * Note: This will only work on offsets that are stored as "entity 
   295  * handles" (which usually looks like m_h* in properties).  These 
   296  * are not SourceMod Handles, but internal Source structures.
   297  * 
   298  * @param entity		Edict index.
   299  * @param offset		Offset to use.
   300  * @return				Entity index at the given location.  If there is no entity, 
   301  *						or the stored entity is invalid, then -1 is returned.
   302  * @error				Invalid input entity, or offset out of reasonable bounds.
   303  */
   304 native GetEntDataEnt2(entity, offset);
   305 
   306 /**
   307  * Peeks into an entity's object data and sets the entity index at the 
   308  * given offset.
   309  *
   310  * Note: This will only work on offsets that are stored as "entity 
   311  * handles" (which usually looks like m_h* in properties).  These 
   312  * are not SourceMod Handles, but internal Source structures.
   313  * 
   314  * @param entity		Edict index.
   315  * @param offset		Offset to use.
   316  * @param other			Entity index to set, or -1 to clear.
   317  * @param changeState	If true, change will be sent over the network.
   318  * @noreturn
   319  * @error				Invalid input entity, or offset out of reasonable bounds.
   320  */
   321 native SetEntDataEnt2(entity, offset, other, bool:changeState=false);
   322 
   323 /**
   324  * Peeks into an entity's object data and retrieves the vector at the 
   325  * given offset.
   326  * @note Both a Vector and a QAngle are three floats.  This is a 
   327  * convenience function and will work with both types.
   328  * 
   329  * @param entity		Edict index.
   330  * @param offset		Offset to use.
   331  * @param vec			Vector buffer to store data in.
   332  * @noreturn
   333  * @error				Invalid entity or offset out of reasonable bounds.
   334  */
   335 native GetEntDataVector(entity, offset, Float:vec[3]);
   336 
   337 /**
   338  * Peeks into an entity's object data and sets the vector at the given 
   339  * offset.
   340  * @note Both a Vector and a QAngle are three floats.  This is a 
   341  * convenience function and will work with both types.
   342  * 
   343  * @param entity		Edict index.
   344  * @param offset		Offset to use.
   345  * @param vec			Vector to set.
   346  * @param changeState	If true, change will be sent over the network.
   347  * @noreturn
   348  * @error				Invalid entity or offset out of reasonable bounds.
   349  */
   350 native SetEntDataVector(entity, offset, const Float:vec[3], bool:changeState=false);
   351 
   352 /**
   353  * Peeks into an entity's object data and retrieves the string at 
   354  * the given offset.
   355  * 
   356  * @param entity		Edict index.
   357  * @param offset		Offset to use.
   358  * @param buffer		Destination string buffer.
   359  * @param maxlen		Maximum length of output string buffer.
   360  * @return			Number of non-null bytes written.
   361  * @error				Invalid entity or offset out of reasonable bounds.
   362  */
   363 native GetEntDataString(entity, offset, String:buffer[], maxlen);
   364 
   365 /**
   366  * Peeks into an entity's object data and sets the string at 
   367  * the given offset.
   368  * 
   369  * @param entity		Edict index.
   370  * @param offset		Offset to use.
   371  * @param buffer		String to set.
   372  * @param maxlen		Maximum length of bytes to write.
   373  * @param changeState	If true, change will be sent over the network.
   374  * @return			Number of non-null bytes written.
   375  * @error				Invalid entity or offset out of reasonable bounds.
   376  */
   377 native SetEntDataString(entity, offset, const String:buffer[], maxlen, bool:changeState=false);
   378 
   379 /**
   380  * @endsection
   381  */
   382 
   383 /**
   384  * Given a ServerClass name, finds a networkable send property offset.
   385  * This information is cached for future calls.
   386  *
   387  * Note, this function may return offsets that do not work!
   388  * If a property is nested beneath a parent object, the resulting offset 
   389  * will be invalid for direct use with data functions.  Therefore, you 
   390  * should use FindSendPropInfo() instead.  An example of such a property is 
   391  * CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress.
   392  *
   393  * @param cls			Classname.
   394  * @param prop			Property name.
   395  * @return				An offset, or -1 on failure.
   396  */
   397 native FindSendPropOffs(const String:cls[], const String:prop[]);
   398 
   399 /**
   400  * Given a ServerClass name, finds a networkable send property offset.
   401  * This information is cached for future calls.
   402  * 
   403  * Note: This function will correctly compute nested offsets, unlike 
   404  * FindSendPropOffs().  YOU SHOULD NOT use this function to self-compute 
   405  * nested offsets.  For example, it is okay to add indexes for arrays, 
   406  * but not to add DT_LocalPlayer to m_nDisguiseClass.
   407  *
   408  * @param cls			Classname.
   409  * @param prop			Property name.
   410  * @param type			Optional parameter to store the type.
   411  * @param num_bits		Optional parameter to store the number of bits the field 
   412  *						uses, if applicable (otherwise 0 is stored).  The number 
   413  *						of bits varies for integers and floats, and is always 0 
   414  * 						for strings.
   415  * @param local_offset	Optional parameter to store the local offset, as 
   416  *						FindSendPropOffs() would return.
   417  * @return				On success, returns an absolutely computed offset.
   418  *						If no offset is available, 0 is returned.
   419  *						If the property is not found, -1 is returned.
   420  */
   421 native FindSendPropInfo(const String:cls[], 
   422 						const String:prop[], 
   423 						&PropFieldType:type=PropFieldType:0,
   424 						&num_bits=0,
   425 						&local_offset=0);
   426 
   427 /**
   428  * Given an entity, finds a datamap property offset.
   429  * This information is cached for future calls.
   430  *
   431  * @param entity		Entity index.
   432  * @param prop			Property name.
   433  * @param type			Optional parameter to store the type.
   434  * @param num_bits		Optional parameter to store the number of bits the field 
   435  *						uses.  The bit count will either be 1 (for boolean) or 
   436  *						divisible by 8 (including 0 if unknown).
   437  * @return				An offset, or -1 on failure.
   438  */
   439 native FindDataMapOffs(entity, 
   440 					   const String:prop[],
   441 					   &PropFieldType:type=PropFieldType:0,
   442 					   &num_bits=0);
   443 
   444 /**
   445  * Wrapper function for finding a send property for a particular entity.
   446  *
   447  * @param ent			Entity index.
   448  * @param prop			Property name.
   449  * @param actual		Defaults to false for backwards compatibility.
   450  *						If true, the newer FindSendPropInfo() function 
   451  *						is used instead.
   452  * @return				An offset, or -1 on failure.
   453  */
   454 stock GetEntSendPropOffs(ent, const String:prop[], bool:actual=false)
   455 {
   456 	decl String:cls[64];
   457 	
   458 	if (!GetEntityNetClass(ent, cls, sizeof(cls)))
   459 	{
   460 		return -1;
   461 	}
   462 	
   463 	if (actual)
   464 	{
   465 		return FindSendPropInfo(cls, prop);
   466 	}
   467 	else
   468 	{
   469 		return FindSendPropOffs(cls, prop);
   470 	}
   471 }
   472 
   473 /**
   474  * Retrieves an integer value from an entity's property.
   475  *
   476  * This function is considered safer and more robust over GetEntData, 
   477  * because it performs strict offset checking and typing rules.  There is a 
   478  * very minor performance hit from this.
   479  * 
   480  * @param entity		Entity/edict index.
   481  * @param type			Property type.
   482  * @param prop			Property name.
   483  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   484  *						This value is auto-detected, and the size parameter is 
   485  *						only used as a fallback in case detection fails.
   486  * @return				Value at the given property offset.
   487  * @error				Invalid entity or property not found.
   488  */
   489 native GetEntProp(entity, PropType:type, const String:prop[], size=4);
   490 
   491 /**
   492  * Sets an integer value in an entity's property.
   493  *
   494  * This function is considered safer and more robust over SetEntData, 
   495  * because it performs strict offset checking and typing rules.  There is a 
   496  * very minor performance hit from this.
   497  * 
   498  * @param entity		Entity/edict index.
   499  * @param type			Property type.
   500  * @param prop			Property name.
   501  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
   502  *						This value is auto-detected, and the size parameter is 
   503  *						only used as a fallback in case detection fails.
   504  * @error				Invalid entity or offset out of reasonable bounds.
   505  * @noreturn
   506  */
   507 native SetEntProp(entity, PropType:type, const String:prop[], any:value, size=4);
   508 
   509 /**
   510  * Retrieves a float value from an entity's property.
   511  *
   512  * This function is considered safer and more robust over GetEntDataFloat, 
   513  * because it performs strict offset checking and typing rules.  There is a 
   514  * very minor performance hit from this.
   515  * 
   516  * @param entity		Entity/edict index.
   517  * @param type			Property type.
   518  * @param prop			Property name.
   519  * @return				Value at the given property offset.
   520  * @error				Invalid entity or offset out of reasonable bounds.
   521  */
   522 native Float:GetEntPropFloat(entity, PropType:type, const String:prop[]);
   523 
   524 /**
   525  * Sets a float value in an entity's property.
   526  *
   527  * This function is considered safer and more robust over SetEntDataFloat, 
   528  * because it performs strict offset checking and typing rules.  There is a 
   529  * very minor performance hit from this.
   530  * 
   531  * @param entity		Entity/edict index.
   532  * @param type			Property type.
   533  * @param prop			Property name.
   534  * @param value			Value to set.
   535  * @noreturn
   536  * @error				Invalid entity or offset out of reasonable bounds.
   537  */
   538 native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);
   539 
   540 /**
   541  * Retrieves an entity index from an entity's property.
   542  *
   543  * This function is considered safer and more robust over GetEntDataEnt*, 
   544  * because it performs strict offset checking and typing rules.  There is a 
   545  * very minor performance hit from this.
   546  * 
   547  * @param entity		Entity/edict index.
   548  * @param type			Property type.
   549  * @param prop			Property name.
   550  * @return				Entity index at the given property.
   551  *						If there is no entity, or the entity is not valid, 
   552  *						then -1 is returned.
   553  * @error				Invalid entity or offset out of reasonable bounds.
   554  */
   555 native GetEntPropEnt(entity, PropType:type, const String:prop[]);
   556 
   557 /**
   558  * Sets an entity index in an entity's property.
   559  *
   560  * This function is considered safer and more robust over SetEntDataEnt*, 
   561  * because it performs strict offset checking and typing rules.  There is a 
   562  * very minor performance hit from this.
   563  * 
   564  * @param entity		Entity/edict index.
   565  * @param type			Property type.
   566  * @param prop			Property name.
   567  * @param other			Entity index to set, or -1 to unset.
   568  * @noreturn
   569  * @error				Invalid entity or offset out of reasonable bounds.
   570  */
   571 native SetEntPropEnt(entity, PropType:type, const String:prop[], other);
   572 
   573 /**
   574  * Retrieves a vector of floats from an entity, given a named network property.
   575  *
   576  * This function is considered safer and more robust over GetEntDataVector, 
   577  * because it performs strict offset checking and typing rules.  There is a 
   578  * very minor performance hit from this.
   579  * 
   580  * @param entity		Entity/edict index.
   581  * @param type			Property type.
   582  * @param prop			Property name.
   583  * @param vec			Vector buffer to store data in.
   584  * @noreturn
   585  * @error				Invalid entity, property not found, or property not 
   586  *						actually a vector data type.
   587  */
   588 native GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3]);
   589 
   590 /**
   591  * Sets a vector of floats in an entity, given a named network property.
   592  *
   593  * This function is considered safer and more robust over SetEntDataVector, 
   594  * because it performs strict offset checking and typing rules.  There is a 
   595  * very minor performance hit from this.
   596  * 
   597  * @param entity		Entity/edict index.
   598  * @param type			Property type.
   599  * @param prop			Property name.
   600  * @param vec			Vector to set.
   601  * @noreturn
   602  * @error				Invalid entity, property not found, or property not 
   603  *						actually a vector data type.
   604  */
   605 native SetEntPropVector(entity, PropType:type, const String:prop[], const Float:vec[3]);
   606 
   607 /**
   608  * Gets a network property as a string.
   609  * 
   610  * @param entity		Edict index.
   611  * @param type			Property type.
   612  * @param prop			Property to use.
   613  * @param buffer		Destination string buffer.
   614  * @param maxlen		Maximum length of output string buffer.		
   615  * @return				Number of non-null bytes written.
   616  * @error				Invalid entity, offset out of reasonable bounds, or property is not a valid string.
   617  */
   618 native GetEntPropString(entity, PropType:type, const String:prop[], String:buffer[], maxlen);
   619 
   620 /**
   621  * Sets a network property as a string.
   622  * 
   623  * @param entity		Edict index.
   624  * @param type			Property type.
   625  * @param prop			Property to use.
   626  * @param buffer		String to set.		
   627  * @return				Number of non-null bytes written.
   628  * @error				Invalid entity, offset out of reasonable bounds, or property is not a valid string.
   629  */
   630 native SetEntPropString(entity, PropType:type, const String:prop[], const String:buffer[]);
   631 
   632 /**
   633  * Copies an array of cells from an entity at a given offset.
   634  *
   635  * @param entity		Entity index.
   636  * @param offset		Offset to use.
   637  * @param array			Array to read into.
   638  * @param arraySize		Number of values to read.
   639  * @param dataSize		Size of each value in bytes (1, 2, or 4).
   640  * @noreturn
   641  * @error				Invalid entity or offset out of reasonable bounds.
   642  */
   643 stock GetEntDataArray(entity, offset, array[], arraySize, dataSize=4)
   644 {
   645 	for (new i=0; i<arraySize; i++)
   646 	{
   647 		array[i] = GetEntData(entity, offset + i*dataSize, dataSize)
   648 	}
   649 }
   650 
   651 /**
   652  * Copies an array of cells to an entity at a given offset.
   653  *
   654  * @param entity		Entity index.
   655  * @param offset		Offset to use.
   656  * @param array			Array of values to copy.
   657  * @param arraySize		Number of values to copy.
   658  * @param dataSize		Size of each value in bytes (1, 2, or 4).
   659  * @param changeState	True to set the network state as changed; false otherwise.
   660  * @noreturn
   661  * @error				Invalid entity or offset out of reasonable bounds.
   662  */
   663 stock SetEntDataArray(entity, offset, const array[], arraySize, dataSize=4, bool:changeState=false)
   664 {
   665 	for (new i=0; i<arraySize; i++)
   666 	{
   667 		SetEntData(entity, offset + i*dataSize, array[i], dataSize, changeState);
   668 	}
   669 }