1.1 --- a/plugins/include/entity.inc Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,679 +0,0 @@
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 -#pragma deprecated Use GetEntDataEnt2() instead.
1.280 -native GetEntDataEnt(entity, offset);
1.281 -
1.282 -/**
1.283 - * This function is deprecated. Use SetEntDataEnt2 instead, for
1.284 - * reasons explained in the notes.
1.285 - *
1.286 - * Note: This function uses 0 as an indicator to unset data, but
1.287 - * 0 is also the world entity index. Thus, the a property cannot
1.288 - * be set to the world entity using this native.
1.289 - *
1.290 - * @param entity Edict index.
1.291 - * @param offset Offset to use.
1.292 - * @param other Entity index to set, or 0 to clear.
1.293 - * @param changeState If true, change will be sent over the network.
1.294 - * @noreturn
1.295 - * @error Invalid entity or offset out of reasonable bounds.
1.296 - */
1.297 -#pragma deprecated Use SetEntDataEnt2() instead.
1.298 -native SetEntDataEnt(entity, offset, other, bool:changeState=false);
1.299 -
1.300 -/**
1.301 - * Peeks into an entity's object data and retrieves the entity index
1.302 - * at the given offset.
1.303 - *
1.304 - * Note: This will only work on offsets that are stored as "entity
1.305 - * handles" (which usually looks like m_h* in properties). These
1.306 - * are not SourceMod Handles, but internal Source structures.
1.307 - *
1.308 - * @param entity Edict index.
1.309 - * @param offset Offset to use.
1.310 - * @return Entity index at the given location. If there is no entity,
1.311 - * or the stored entity is invalid, then -1 is returned.
1.312 - * @error Invalid input entity, or offset out of reasonable bounds.
1.313 - */
1.314 -native GetEntDataEnt2(entity, offset);
1.315 -
1.316 -/**
1.317 - * Peeks into an entity's object data and sets the entity index at the
1.318 - * given offset.
1.319 - *
1.320 - * Note: This will only work on offsets that are stored as "entity
1.321 - * handles" (which usually looks like m_h* in properties). These
1.322 - * are not SourceMod Handles, but internal Source structures.
1.323 - *
1.324 - * @param entity Edict index.
1.325 - * @param offset Offset to use.
1.326 - * @param other Entity index to set, or -1 to clear.
1.327 - * @param changeState If true, change will be sent over the network.
1.328 - * @noreturn
1.329 - * @error Invalid input entity, or offset out of reasonable bounds.
1.330 - */
1.331 -native SetEntDataEnt2(entity, offset, other, bool:changeState=false);
1.332 -
1.333 -/**
1.334 - * Peeks into an entity's object data and retrieves the vector at the
1.335 - * given offset.
1.336 - * @note Both a Vector and a QAngle are three floats. This is a
1.337 - * convenience function and will work with both types.
1.338 - *
1.339 - * @param entity Edict index.
1.340 - * @param offset Offset to use.
1.341 - * @param vec Vector buffer to store data in.
1.342 - * @noreturn
1.343 - * @error Invalid entity or offset out of reasonable bounds.
1.344 - */
1.345 -native GetEntDataVector(entity, offset, Float:vec[3]);
1.346 -
1.347 -/**
1.348 - * Peeks into an entity's object data and sets the vector at the given
1.349 - * offset.
1.350 - * @note Both a Vector and a QAngle are three floats. This is a
1.351 - * convenience function and will work with both types.
1.352 - *
1.353 - * @param entity Edict index.
1.354 - * @param offset Offset to use.
1.355 - * @param vec Vector to set.
1.356 - * @param changeState If true, change will be sent over the network.
1.357 - * @noreturn
1.358 - * @error Invalid entity or offset out of reasonable bounds.
1.359 - */
1.360 -native SetEntDataVector(entity, offset, const Float:vec[3], bool:changeState=false);
1.361 -
1.362 -/**
1.363 - * Peeks into an entity's object data and retrieves the string at
1.364 - * the given offset.
1.365 - *
1.366 - * @param entity Edict index.
1.367 - * @param offset Offset to use.
1.368 - * @param buffer Destination string buffer.
1.369 - * @param maxlen Maximum length of output string buffer.
1.370 - * @return Number of non-null bytes written.
1.371 - * @error Invalid entity or offset out of reasonable bounds.
1.372 - */
1.373 -native GetEntDataString(entity, offset, String:buffer[], maxlen);
1.374 -
1.375 -/**
1.376 - * Peeks into an entity's object data and sets the string at
1.377 - * the given offset.
1.378 - *
1.379 - * @param entity Edict index.
1.380 - * @param offset Offset to use.
1.381 - * @param buffer String to set.
1.382 - * @param maxlen Maximum length of bytes to write.
1.383 - * @param changeState If true, change will be sent over the network.
1.384 - * @return Number of non-null bytes written.
1.385 - * @error Invalid entity or offset out of reasonable bounds.
1.386 - */
1.387 -native SetEntDataString(entity, offset, const String:buffer[], maxlen, bool:changeState=false);
1.388 -
1.389 -/**
1.390 - * @endsection
1.391 - */
1.392 -
1.393 -/**
1.394 - * Given a ServerClass name, finds a networkable send property offset.
1.395 - * This information is cached for future calls.
1.396 - *
1.397 - * Note, this function may return offsets that do not work!
1.398 - * If a property is nested beneath a parent object, the resulting offset
1.399 - * will be invalid for direct use with data functions. Therefore, you
1.400 - * should use FindSendPropInfo() instead. An example of such a property is
1.401 - * CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress.
1.402 - *
1.403 - * @param cls Classname.
1.404 - * @param prop Property name.
1.405 - * @return An offset, or -1 on failure.
1.406 - */
1.407 -native FindSendPropOffs(const String:cls[], const String:prop[]);
1.408 -
1.409 -/**
1.410 - * Given a ServerClass name, finds a networkable send property offset.
1.411 - * This information is cached for future calls.
1.412 - *
1.413 - * Note: This function will correctly compute nested offsets, unlike
1.414 - * FindSendPropOffs(). YOU SHOULD NOT use this function to self-compute
1.415 - * nested offsets. For example, it is okay to add indexes for arrays,
1.416 - * but not to add DT_LocalPlayer to m_nDisguiseClass.
1.417 - *
1.418 - * @param cls Classname.
1.419 - * @param prop Property name.
1.420 - * @param type Optional parameter to store the type.
1.421 - * @param num_bits Optional parameter to store the number of bits the field
1.422 - * uses, if applicable (otherwise 0 is stored). The number
1.423 - * of bits varies for integers and floats, and is always 0
1.424 - * for strings.
1.425 - * @param local_offset Optional parameter to store the local offset, as
1.426 - * FindSendPropOffs() would return.
1.427 - * @return On success, returns an absolutely computed offset.
1.428 - * If no offset is available, 0 is returned.
1.429 - * If the property is not found, -1 is returned.
1.430 - */
1.431 -native FindSendPropInfo(const String:cls[],
1.432 - const String:prop[],
1.433 - &PropFieldType:type=PropFieldType:0,
1.434 - &num_bits=0,
1.435 - &local_offset=0);
1.436 -
1.437 -/**
1.438 - * Given an entity, finds a datamap property offset.
1.439 - * This information is cached for future calls.
1.440 - *
1.441 - * @param entity Entity index.
1.442 - * @param prop Property name.
1.443 - * @param type Optional parameter to store the type.
1.444 - * @param num_bits Optional parameter to store the number of bits the field
1.445 - * uses. The bit count will either be 1 (for boolean) or
1.446 - * divisible by 8 (including 0 if unknown).
1.447 - * @return An offset, or -1 on failure.
1.448 - */
1.449 -native FindDataMapOffs(entity,
1.450 - const String:prop[],
1.451 - &PropFieldType:type=PropFieldType:0,
1.452 - &num_bits=0);
1.453 -
1.454 -/**
1.455 - * Wrapper function for finding a send property for a particular entity.
1.456 - *
1.457 - * @param ent Entity index.
1.458 - * @param prop Property name.
1.459 - * @param actual Defaults to false for backwards compatibility.
1.460 - * If true, the newer FindSendPropInfo() function
1.461 - * is used instead.
1.462 - * @return An offset, or -1 on failure.
1.463 - */
1.464 -stock GetEntSendPropOffs(ent, const String:prop[], bool:actual=false)
1.465 -{
1.466 - decl String:cls[64];
1.467 -
1.468 - if (!GetEntityNetClass(ent, cls, sizeof(cls)))
1.469 - {
1.470 - return -1;
1.471 - }
1.472 -
1.473 - if (actual)
1.474 - {
1.475 - return FindSendPropInfo(cls, prop);
1.476 - }
1.477 - else
1.478 - {
1.479 - return FindSendPropOffs(cls, prop);
1.480 - }
1.481 -}
1.482 -
1.483 -/**
1.484 - * Retrieves an integer value from an entity's property.
1.485 - *
1.486 - * This function is considered safer and more robust over GetEntData,
1.487 - * because it performs strict offset checking and typing rules. There is a
1.488 - * very minor performance hit from this.
1.489 - *
1.490 - * @param entity Entity/edict index.
1.491 - * @param type Property type.
1.492 - * @param prop Property name.
1.493 - * @param size Number of bytes to write (valid values are 1, 2, or 4).
1.494 - * This value is auto-detected, and the size parameter is
1.495 - * only used as a fallback in case detection fails.
1.496 - * @return Value at the given property offset.
1.497 - * @error Invalid entity or property not found.
1.498 - */
1.499 -native GetEntProp(entity, PropType:type, const String:prop[], size=4);
1.500 -
1.501 -/**
1.502 - * Sets an integer value in an entity's property.
1.503 - *
1.504 - * This function is considered safer and more robust over SetEntData,
1.505 - * because it performs strict offset checking and typing rules. There is a
1.506 - * very minor performance hit from this.
1.507 - *
1.508 - * @param entity Entity/edict index.
1.509 - * @param type Property type.
1.510 - * @param prop Property name.
1.511 - * @param size Number of bytes to write (valid values are 1, 2, or 4).
1.512 - * This value is auto-detected, and the size parameter is
1.513 - * only used as a fallback in case detection fails.
1.514 - * @error Invalid entity or offset out of reasonable bounds.
1.515 - * @noreturn
1.516 - */
1.517 -native SetEntProp(entity, PropType:type, const String:prop[], any:value, size=4);
1.518 -
1.519 -/**
1.520 - * Retrieves a float value from an entity's property.
1.521 - *
1.522 - * This function is considered safer and more robust over GetEntDataFloat,
1.523 - * because it performs strict offset checking and typing rules. There is a
1.524 - * very minor performance hit from this.
1.525 - *
1.526 - * @param entity Entity/edict index.
1.527 - * @param type Property type.
1.528 - * @param prop Property name.
1.529 - * @return Value at the given property offset.
1.530 - * @error Invalid entity or offset out of reasonable bounds.
1.531 - */
1.532 -native Float:GetEntPropFloat(entity, PropType:type, const String:prop[]);
1.533 -
1.534 -/**
1.535 - * Sets a float value in an entity's property.
1.536 - *
1.537 - * This function is considered safer and more robust over SetEntDataFloat,
1.538 - * because it performs strict offset checking and typing rules. There is a
1.539 - * very minor performance hit from this.
1.540 - *
1.541 - * @param entity Entity/edict index.
1.542 - * @param type Property type.
1.543 - * @param prop Property name.
1.544 - * @param value Value to set.
1.545 - * @noreturn
1.546 - * @error Invalid entity or offset out of reasonable bounds.
1.547 - */
1.548 -native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);
1.549 -
1.550 -/**
1.551 - * Retrieves an entity index from an entity's property.
1.552 - *
1.553 - * This function is considered safer and more robust over GetEntDataEnt*,
1.554 - * because it performs strict offset checking and typing rules. There is a
1.555 - * very minor performance hit from this.
1.556 - *
1.557 - * @param entity Entity/edict index.
1.558 - * @param type Property type.
1.559 - * @param prop Property name.
1.560 - * @return Entity index at the given property.
1.561 - * If there is no entity, or the entity is not valid,
1.562 - * then -1 is returned.
1.563 - * @error Invalid entity or offset out of reasonable bounds.
1.564 - */
1.565 -native GetEntPropEnt(entity, PropType:type, const String:prop[]);
1.566 -
1.567 -/**
1.568 - * Sets an entity index in an entity's property.
1.569 - *
1.570 - * This function is considered safer and more robust over SetEntDataEnt*,
1.571 - * because it performs strict offset checking and typing rules. There is a
1.572 - * very minor performance hit from this.
1.573 - *
1.574 - * @param entity Entity/edict index.
1.575 - * @param type Property type.
1.576 - * @param prop Property name.
1.577 - * @param other Entity index to set, or -1 to unset.
1.578 - * @noreturn
1.579 - * @error Invalid entity or offset out of reasonable bounds.
1.580 - */
1.581 -native SetEntPropEnt(entity, PropType:type, const String:prop[], other);
1.582 -
1.583 -/**
1.584 - * Retrieves a vector of floats from an entity, given a named network property.
1.585 - *
1.586 - * This function is considered safer and more robust over GetEntDataVector,
1.587 - * because it performs strict offset checking and typing rules. There is a
1.588 - * very minor performance hit from this.
1.589 - *
1.590 - * @param entity Entity/edict index.
1.591 - * @param type Property type.
1.592 - * @param prop Property name.
1.593 - * @param vec Vector buffer to store data in.
1.594 - * @noreturn
1.595 - * @error Invalid entity, property not found, or property not
1.596 - * actually a vector data type.
1.597 - */
1.598 -native GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3]);
1.599 -
1.600 -/**
1.601 - * Sets a vector of floats in an entity, given a named network property.
1.602 - *
1.603 - * This function is considered safer and more robust over SetEntDataVector,
1.604 - * because it performs strict offset checking and typing rules. There is a
1.605 - * very minor performance hit from this.
1.606 - *
1.607 - * @param entity Entity/edict index.
1.608 - * @param type Property type.
1.609 - * @param prop Property name.
1.610 - * @param vec Vector to set.
1.611 - * @noreturn
1.612 - * @error Invalid entity, property not found, or property not
1.613 - * actually a vector data type.
1.614 - */
1.615 -native SetEntPropVector(entity, PropType:type, const String:prop[], const Float:vec[3]);
1.616 -
1.617 -/**
1.618 - * Gets a network property as a string.
1.619 - *
1.620 - * @param entity Edict index.
1.621 - * @param type Property type.
1.622 - * @param prop Property to use.
1.623 - * @param buffer Destination string buffer.
1.624 - * @param maxlen Maximum length of output string buffer.
1.625 - * @return Number of non-null bytes written.
1.626 - * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
1.627 - */
1.628 -native GetEntPropString(entity, PropType:type, const String:prop[], String:buffer[], maxlen);
1.629 -
1.630 -/**
1.631 - * Sets a network property as a string.
1.632 - *
1.633 - * This cannot set property fields of type PropField_String_T (such as "m_target").
1.634 - * To set such fields, you should use DispatchKeyValue() from SDKTools.
1.635 - *
1.636 - * @param entity Edict index.
1.637 - * @param type Property type.
1.638 - * @param prop Property to use.
1.639 - * @param buffer String to set.
1.640 - * @return Number of non-null bytes written.
1.641 - * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
1.642 - */
1.643 -native SetEntPropString(entity, PropType:type, const String:prop[], const String:buffer[]);
1.644 -
1.645 -/**
1.646 - * Copies an array of cells from an entity at a given offset.
1.647 - *
1.648 - * @param entity Entity index.
1.649 - * @param offset Offset to use.
1.650 - * @param array Array to read into.
1.651 - * @param arraySize Number of values to read.
1.652 - * @param dataSize Size of each value in bytes (1, 2, or 4).
1.653 - * @noreturn
1.654 - * @error Invalid entity or offset out of reasonable bounds.
1.655 - */
1.656 -stock GetEntDataArray(entity, offset, array[], arraySize, dataSize=4)
1.657 -{
1.658 - for (new i=0; i<arraySize; i++)
1.659 - {
1.660 - array[i] = GetEntData(entity, offset + i*dataSize, dataSize)
1.661 - }
1.662 -}
1.663 -
1.664 -/**
1.665 - * Copies an array of cells to an entity at a given offset.
1.666 - *
1.667 - * @param entity Entity index.
1.668 - * @param offset Offset to use.
1.669 - * @param array Array of values to copy.
1.670 - * @param arraySize Number of values to copy.
1.671 - * @param dataSize Size of each value in bytes (1, 2, or 4).
1.672 - * @param changeState True to set the network state as changed; false otherwise.
1.673 - * @noreturn
1.674 - * @error Invalid entity or offset out of reasonable bounds.
1.675 - */
1.676 -stock SetEntDataArray(entity, offset, const array[], arraySize, dataSize=4, bool:changeState=false)
1.677 -{
1.678 - for (new i=0; i<arraySize; i++)
1.679 - {
1.680 - SetEntData(entity, offset + i*dataSize, array[i], dataSize, changeState);
1.681 - }
1.682 -}