ds@1952: /**
ds@1952: * vim: set ts=4 :
ds@1952: * =============================================================================
ds@1952: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
ds@1952: * =============================================================================
ds@1952: *
ds@1952: * This file is part of the SourceMod/SourcePawn SDK.
ds@1952: *
ds@1952: * This program is free software; you can redistribute it and/or modify it under
ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952: * Free Software Foundation.
ds@1952: *
ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1952: * details.
ds@1952: *
ds@1952: * You should have received a copy of the GNU General Public License along with
ds@1952: * this program. If not, see .
ds@1952: *
ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1952: * this exception to all derivative works. AlliedModders LLC defines further
ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952: * or .
ds@1952: *
ds@1952: * Version: $Id$
ds@1952: */
ds@1952:
ds@1952: #if defined _entity_included
ds@1952: #endinput
ds@1952: #endif
ds@1952: #define _entity_included
ds@1952:
ds@1952: /**
ds@1952: * Property types for entities.
ds@1952: */
ds@1952: enum PropType
ds@1952: {
ds@1952: Prop_Send = 0, /**< This property is networked. */
ds@1952: Prop_Data = 1, /**< This property is for save game data fields. */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * @section For more information on these, see the HL2SDK (public/edict.h)
ds@1952: */
ds@1952: #define FL_EDICT_CHANGED (1<<0) /**< Game DLL sets this when the entity state changes
ds@1952: Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */
ds@1952: #define FL_EDICT_FREE (1<<1) /**< this edict if free for reuse */
ds@1952: #define FL_EDICT_FULL (1<<2) /**< this is a full server entity */
ds@1952: #define FL_EDICT_FULLCHECK (0<<0) /**< call ShouldTransmit() each time, this is a fake flag */
ds@1952: #define FL_EDICT_ALWAYS (1<<3) /**< always transmit this entity */
ds@1952: #define FL_EDICT_DONTSEND (1<<4) /**< don't transmit this entity */
ds@1952: #define FL_EDICT_PVSCHECK (1<<5) /**< always transmit entity, but cull against PVS */
ds@1952: #define FL_EDICT_PENDING_DORMANT_CHECK (1<<6)
ds@1952: #define FL_EDICT_DIRTY_PVS_INFORMATION (1<<7)
ds@1952: #define FL_FULL_EDICT_CHANGED (1<<8)
ds@1952:
ds@1952: enum PropFieldType
ds@1952: {
ds@1952: PropField_Unsupported, /**< The type is unsupported. */
ds@1952: PropField_Integer, /**< Valid for SendProp and Data fields */
ds@1952: PropField_Float, /**< Valid for SendProp and Data fields */
ds@1952: PropField_Entity, /**< Valid for Data fields only (SendProp shows as int) */
ds@1952: PropField_Vector, /**< Valid for SendProp and Data fields */
ds@1952: PropField_String, /**< Valid for SendProp and Data fields */
ds@1952: PropField_String_T, /**< Valid for Data fields. Read only.
ds@1952: Note that the size of a string_t is dynamic, and
ds@1952: thus FindDataMapOffs() will return the constant size
ds@1952: of the string_t container (which is 32 bits right now).
ds@1952: */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * @endsection
ds@1952: */
ds@1952:
ds@1952: /**
ds@1952: * Returns the maximum number of entities.
ds@1952: *
ds@1952: * @return Maximum number of entities.
ds@1952: */
ds@1952: native GetMaxEntities();
ds@1952:
ds@1952: /**
ds@1952: * Returns the number of entities in the server.
ds@1952: *
ds@1952: * @return Number of entities in the server.
ds@1952: */
ds@1952: native GetEntityCount();
ds@1952:
ds@1952: /**
ds@1952: * Returns whether or not an entity is valid. Returns false
ds@1952: * if there is no matching CBaseEntity for this edict index.
ds@1952: *
ds@1952: * @param edict Index of the entity/edict.
ds@1952: * @return True if valid, false otherwise.
ds@1952: */
ds@1952: native bool:IsValidEntity(edict);
ds@1952:
ds@1952: /**
ds@1952: * Returns whether or not an edict index is valid.
ds@1952: *
ds@1952: * @param edict Index of the edict.
ds@1952: * @return True if valid, false otherwise.
ds@1952: */
ds@1952: native bool:IsValidEdict(edict);
ds@1952:
ds@1952: /**
ds@1952: * Returns whether or not an entity is a valid networkable edict.
ds@1952: *
ds@1952: * @param edict Index of the edict.
ds@1952: * @return True if networkable, false if invalid or not networkable.
ds@1952: */
ds@1952: native bool:IsEntNetworkable(edict);
ds@1952:
ds@1952: /**
ds@1952: * Creates a new edict (the basis of a networkable entity)
ds@1952: *
ds@1952: * @return Index of the edict, 0 on failure.
ds@1952: */
ds@1952: native CreateEdict();
ds@1952:
ds@1952: /**
ds@1952: * Removes an edict from the world.
ds@1952: *
ds@1952: * @param edict Index of the edict.
ds@1952: * @noreturn
ds@1952: * @error Invalid edict index.
ds@1952: */
ds@1952: native RemoveEdict(edict);
ds@1952:
ds@1952: /**
ds@1952: * Returns the flags on an edict. These are not the same as entity flags.
ds@1952: *
ds@1952: * @param edict Index of the entity.
ds@1952: * @return Edict flags.
ds@1952: * @error Invalid edict index.
ds@1952: */
ds@1952: native GetEdictFlags(edict);
ds@1952:
ds@1952: /**
ds@1952: * Sets the flags on an edict. These are not the same as entity flags.
ds@1952: *
ds@1952: * @param edict Index of the entity.
ds@1952: * @param flags Flags to set.
ds@1952: * @noreturn
ds@1952: * @error Invalid edict index.
ds@1952: */
ds@1952: native SetEdictFlags(edict, flags);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves an edict classname.
ds@1952: *
ds@1952: * @param edict Index of the entity.
ds@1952: * @param clsname Buffer to store the classname.
ds@1952: * @param maxlength Maximum length of the buffer.
ds@1952: * @return True on success, false if there is no classname set.
ds@1952: */
ds@1952: native bool:GetEdictClassname(edict, String:clsname[], maxlength);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves an entity's networkable serverclass name.
ds@1952: * This is not the same as the classname and is used for networkable state changes.
ds@1952: *
ds@1952: * @param edict Index of the entity.
ds@1952: * @param clsname Buffer to store the serverclass name.
ds@1952: * @param maxlength Maximum lnegth of the buffer.
ds@1952: * @return True on success, false if the edict is not networkable.
ds@1952: * @error Invalid edict index.
ds@1952: */
ds@1952: native bool:GetEntityNetClass(edict, String:clsname[], maxlength);
ds@1952:
ds@1952: /**
ds@1952: * @section Entity offset functions
ds@1952: *
ds@1952: * Offsets should be specified in byte distance from the CBaseEntity
ds@1952: * structure, not short (double byte) or integer (four byte) multiples.
ds@1952: * It is somewhat common practice to use offsets aligned to their final
ds@1952: * type, and thus make sure you are not falling to this error in SourceMod.
ds@1952: * For example, if your "integer-aligned" offset was 119, your byte-aligned
ds@1952: * offset is 119*4, or 476.
ds@1952:
ds@1952: * Specifying incorrect offsets or the incorrect data type for an offset
ds@1952: * can have fatal consequences. If you are hardcoding offsets, and the
ds@1952: * layout of CBaseEntity does not match, you can easily crash the server.
ds@1952: *
ds@1952: * The reasonable bounds for offsets is greater than or equal to 0 and
ds@1952: * below 32768. Offsets out of these bounds will throw an error. However,
ds@1952: * this does not represent any real range, it is simply a sanity check for
ds@1952: * illegal values. Any range outside of the CBaseEntity structure's private
ds@1952: * size will cause undefined behaviour or even crash.
ds@1952: */
ds@1952:
ds@1952: /**
ds@1952: * Marks an entity as state changed. This can be useful if you set an offset
ds@1952: * and wish for it to be immediately changed over the network. By default this
ds@1952: * is not done for offset setting functions.
ds@1952: *
ds@1952: * @param edict Index to the edict.
ds@1952: * @param offset Offset to mark as changed. If 0,
ds@1952: * the entire edict is marked as changed.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of bounds.
ds@1952: */
ds@1952: native ChangeEdictState(edict, offset = 0);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and retrieves the integer value at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param size Number of bytes to read (valid values are 1, 2, or 4).
ds@1952: * @return Value at the given memory location.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntData(entity, offset, size=4);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and sets the integer value at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param size Number of bytes to write (valid values are 1, 2, or 4).
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @return Value at the given memory location.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetEntData(entity, offset, any:value, size=4, bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and retrieves the float value at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @return Value at the given memory location.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native Float:GetEntDataFloat(entity, offset);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and sets the integer value at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @return Value at the given memory location.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetEntDataFloat(entity, offset, Float:value, bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * This function is deprecated. Use GetEntDataEnt2 instead, for
ds@1952: * reasons explained in the notes.
ds@1952: *
ds@1952: * Note: This function returns 0 on failure, which may be misleading,
ds@1952: * as the number 0 is also used for the world entity index.
ds@1952: *
ds@1952: * Note: This function makes no attempt to validate the returned
ds@1952: * entity, and in fact, it could be garbage or completely unexpected.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @return Entity index at the given location, or 0 if none.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntDataEnt(entity, offset);
ds@1952:
ds@1952: /**
ds@1952: * This function is deprecated. Use GetEntDataEnt2 instead, for
ds@1952: * reasons explained in the notes.
ds@1952: *
ds@1952: * Note: This function uses 0 as an indicator to unset data, but
ds@1952: * 0 is also the world entity index. Thus, the a property cannot
ds@1952: * be set to the world entity using this native.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param other Entity index to set, or 0 to clear.
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntDataEnt(entity, offset, other, bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and retrieves the entity index
ds@1952: * at the given offset.
ds@1952: *
ds@1952: * Note: This will only work on offsets that are stored as "entity
ds@1952: * handles" (which usually looks like m_h* in properties). These
ds@1952: * are not SourceMod Handles, but internal Source structures.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @return Entity index at the given location. If there is no entity,
ds@1952: * or the stored entity is invalid, then -1 is returned.
ds@1952: * @error Invalid input entity, or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntDataEnt2(entity, offset);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and sets the entity index at the
ds@1952: * given offset.
ds@1952: *
ds@1952: * Note: This will only work on offsets that are stored as "entity
ds@1952: * handles" (which usually looks like m_h* in properties). These
ds@1952: * are not SourceMod Handles, but internal Source structures.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param other Entity index to set, or -1 to clear.
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @noreturn
ds@1952: * @error Invalid input entity, or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntDataEnt2(entity, offset, other, bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and retrieves the vector at the
ds@1952: * given offset.
ds@1952: * @note Both a Vector and a QAngle are three floats. This is a
ds@1952: * convenience function and will work with both types.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param vec Vector buffer to store data in.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntDataVector(entity, offset, Float:vec[3]);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and sets the vector at the given
ds@1952: * offset.
ds@1952: * @note Both a Vector and a QAngle are three floats. This is a
ds@1952: * convenience function and will work with both types.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param vec Vector to set.
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntDataVector(entity, offset, const Float:vec[3], bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and retrieves the string at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param buffer Destination string buffer.
ds@1952: * @param maxlen Maximum length of output string buffer.
ds@1952: * @return Number of non-null bytes written.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntDataString(entity, offset, String:buffer[], maxlen);
ds@1952:
ds@1952: /**
ds@1952: * Peeks into an entity's object data and sets the string at
ds@1952: * the given offset.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param buffer String to set.
ds@1952: * @param maxlen Maximum length of bytes to write.
ds@1952: * @param changeState If true, change will be sent over the network.
ds@1952: * @return Number of non-null bytes written.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntDataString(entity, offset, const String:buffer[], maxlen, bool:changeState=false);
ds@1952:
ds@1952: /**
ds@1952: * @endsection
ds@1952: */
ds@1952:
ds@1952: /**
ds@1952: * Given a ServerClass name, finds a networkable send property offset.
ds@1952: * This information is cached for future calls.
ds@1952: *
ds@1952: * Note, this function may return offsets that do not work!
ds@1952: * If a property is nested beneath a parent object, the resulting offset
ds@1952: * will be invalid for direct use with data functions. Therefore, you
ds@1952: * should use FindSendPropInfo() instead. An example of such a property is
ds@1952: * CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress.
ds@1952: *
ds@1952: * @param cls Classname.
ds@1952: * @param prop Property name.
ds@1952: * @return An offset, or -1 on failure.
ds@1952: */
ds@1952: native FindSendPropOffs(const String:cls[], const String:prop[]);
ds@1952:
ds@1952: /**
ds@1952: * Given a ServerClass name, finds a networkable send property offset.
ds@1952: * This information is cached for future calls.
ds@1952: *
ds@1952: * Note: This function will correctly compute nested offsets, unlike
ds@1952: * FindSendPropOffs(). YOU SHOULD NOT use this function to self-compute
ds@1952: * nested offsets. For example, it is okay to add indexes for arrays,
ds@1952: * but not to add DT_LocalPlayer to m_nDisguiseClass.
ds@1952: *
ds@1952: * @param cls Classname.
ds@1952: * @param prop Property name.
ds@1952: * @param type Optional parameter to store the type.
ds@1952: * @param num_bits Optional parameter to store the number of bits the field
ds@1952: * uses, if applicable (otherwise 0 is stored). The number
ds@1952: * of bits varies for integers and floats, and is always 0
ds@1952: * for strings.
ds@1952: * @param local_offset Optional parameter to store the local offset, as
ds@1952: * FindSendPropOffs() would return.
ds@1952: * @return On success, returns an absolutely computed offset.
ds@1952: * If no offset is available, 0 is returned.
ds@1952: * If the property is not found, -1 is returned.
ds@1952: */
ds@1952: native FindSendPropInfo(const String:cls[],
ds@1952: const String:prop[],
ds@1952: &PropFieldType:type=PropFieldType:0,
ds@1952: &num_bits=0,
ds@1952: &local_offset=0);
ds@1952:
ds@1952: /**
ds@1952: * Given an entity, finds a datamap property offset.
ds@1952: * This information is cached for future calls.
ds@1952: *
ds@1952: * @param entity Entity index.
ds@1952: * @param prop Property name.
ds@1952: * @param type Optional parameter to store the type.
ds@1952: * @param num_bits Optional parameter to store the number of bits the field
ds@1952: * uses. The bit count will either be 1 (for boolean) or
ds@1952: * divisible by 8 (including 0 if unknown).
ds@1952: * @return An offset, or -1 on failure.
ds@1952: */
ds@1952: native FindDataMapOffs(entity,
ds@1952: const String:prop[],
ds@1952: &PropFieldType:type=PropFieldType:0,
ds@1952: &num_bits=0);
ds@1952:
ds@1952: /**
ds@1952: * Wrapper function for finding a send property for a particular entity.
ds@1952: *
ds@1952: * @param ent Entity index.
ds@1952: * @param prop Property name.
ds@1952: * @param actual Defaults to false for backwards compatibility.
ds@1952: * If true, the newer FindSendPropInfo() function
ds@1952: * is used instead.
ds@1952: * @return An offset, or -1 on failure.
ds@1952: */
ds@1952: stock GetEntSendPropOffs(ent, const String:prop[], bool:actual=false)
ds@1952: {
ds@1952: decl String:cls[64];
ds@1952:
ds@1952: if (!GetEntityNetClass(ent, cls, sizeof(cls)))
ds@1952: {
ds@1952: return -1;
ds@1952: }
ds@1952:
ds@1952: if (actual)
ds@1952: {
ds@1952: return FindSendPropInfo(cls, prop);
ds@1952: }
ds@1952: else
ds@1952: {
ds@1952: return FindSendPropOffs(cls, prop);
ds@1952: }
ds@1952: }
ds@1952:
ds@1952: /**
ds@1952: * Retrieves an integer value from an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over GetEntData,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param size Number of bytes to write (valid values are 1, 2, or 4).
ds@1952: * This value is auto-detected, and the size parameter is
ds@1952: * only used as a fallback in case detection fails.
ds@1952: * @return Value at the given property offset.
ds@1952: * @error Invalid entity or property not found.
ds@1952: */
ds@1952: native GetEntProp(entity, PropType:type, const String:prop[], size=4);
ds@1952:
ds@1952: /**
ds@1952: * Sets an integer value in an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over SetEntData,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param size Number of bytes to write (valid values are 1, 2, or 4).
ds@1952: * This value is auto-detected, and the size parameter is
ds@1952: * only used as a fallback in case detection fails.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetEntProp(entity, PropType:type, const String:prop[], any:value, size=4);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves a float value from an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over GetEntDataFloat,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @return Value at the given property offset.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native Float:GetEntPropFloat(entity, PropType:type, const String:prop[]);
ds@1952:
ds@1952: /**
ds@1952: * Sets a float value in an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over SetEntDataFloat,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param value Value to set.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntPropFloat(entity, PropType:type, const String:prop[], Float:value);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves an entity index from an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over GetEntDataEnt*,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @return Entity index at the given property.
ds@1952: * If there is no entity, or the entity is not valid,
ds@1952: * then -1 is returned.
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native GetEntPropEnt(entity, PropType:type, const String:prop[]);
ds@1952:
ds@1952: /**
ds@1952: * Sets an entity index in an entity's property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over SetEntDataEnt*,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param other Entity index to set, or -1 to unset.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: native SetEntPropEnt(entity, PropType:type, const String:prop[], other);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves a vector of floats from an entity, given a named network property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over GetEntDataVector,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param vec Vector buffer to store data in.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity, property not found, or property not
ds@1952: * actually a vector data type.
ds@1952: */
ds@1952: native GetEntPropVector(entity, PropType:type, const String:prop[], Float:vec[3]);
ds@1952:
ds@1952: /**
ds@1952: * Sets a vector of floats in an entity, given a named network property.
ds@1952: *
ds@1952: * This function is considered safer and more robust over SetEntDataVector,
ds@1952: * because it performs strict offset checking and typing rules. There is a
ds@1952: * very minor performance hit from this.
ds@1952: *
ds@1952: * @param entity Entity/edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property name.
ds@1952: * @param vec Vector to set.
ds@1952: * @noreturn
ds@1952: * @error Invalid entity, property not found, or property not
ds@1952: * actually a vector data type.
ds@1952: */
ds@1952: native SetEntPropVector(entity, PropType:type, const String:prop[], const Float:vec[3]);
ds@1952:
ds@1952: /**
ds@1952: * Gets a network property as a string.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property to use.
ds@1952: * @param buffer Destination string buffer.
ds@1952: * @param maxlen Maximum length of output string buffer.
ds@1952: * @return Number of non-null bytes written.
ds@1952: * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
ds@1952: */
ds@1952: native GetEntPropString(entity, PropType:type, const String:prop[], String:buffer[], maxlen);
ds@1952:
ds@1952: /**
ds@1952: * Sets a network property as a string.
ds@1952: *
ds@1952: * This cannot set property fields of type PropField_String_T (such as "m_target").
ds@1952: * To set such fields, you should use DispatchKeyValue() from SDKTools.
ds@1952: *
ds@1952: * @param entity Edict index.
ds@1952: * @param type Property type.
ds@1952: * @param prop Property to use.
ds@1952: * @param buffer String to set.
ds@1952: * @return Number of non-null bytes written.
ds@1952: * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
ds@1952: */
ds@1952: native SetEntPropString(entity, PropType:type, const String:prop[], const String:buffer[]);
ds@1952:
ds@1952: /**
ds@1952: * Copies an array of cells from an entity at a given offset.
ds@1952: *
ds@1952: * @param entity Entity index.
ds@1952: * @param offset Offset to use.
ds@1952: * @param array Array to read into.
ds@1952: * @param arraySize Number of values to read.
ds@1952: * @param dataSize Size of each value in bytes (1, 2, or 4).
ds@1952: * @noreturn
ds@1952: * @error Invalid entity or offset out of reasonable bounds.
ds@1952: */
ds@1952: stock GetEntDataArray(entity, offset, array[], arraySize, dataSize=4)
ds@1952: {
ds@1952: for (new i=0; i