/** * An InjectedAttribute is an abstraction over the KeyValues representation of an attribute * definition. */ methodmap EconInjectedAttribute < Handle { /** * Creates a new, empty EconInjectedAttribute handle. * * The attribute is not injected into the schema until EconInjectedAttribute.Register() is * called. * * This handle should be freed by the calling plugin. */ public native EconInjectedAttribute(); /** * Sets the attribute class. All values under the same attribute class are combined. * This is required. */ public native void SetClass(const char[] attrClass); /** * Sets the attribute name. Only one instance of this per game entity can be active. * If this is empty or NULL_STRING, it will be set to the attribute class on registration. */ public native void SetName(const char[] attrName); /** * Sets the description format. This determines how multiple values with the same attribute * class are combined. * * Generally, "value_is_additive" and "value_is_percentage" are the main ones that matter, * but being precise is ideal in case you want to use the description format when displaying * values to players as with actual schema attributes. */ public native void SetDescriptionFormat(const char[] attrDescFmt); /** * Sets a custom key / value pair. * * Note that "injected" is a key reserved by the plugin that is set to 1 when registered, * overriding any other values set. * * The game has set other keys in the schema in the past, and it may use new ones in the * future. */ public native void SetCustom(const char[] key, const char[] value); /** * Sets the attribute's definition index. * * By default, the extension will automatically allocate a previously unused index. As the * schema may be reloaded between maps, there is no guarantee that an attribute will * continue to exist at a specific index. If an index is manually specified and a * attribute now exists at the index, the injection of the attribute will fail. * * Plugins are expected to either perform a lookup by attribute name, or preferably, use the * hook-style natives with the attribute class. * * This native is solely provided for backwards compatibility with schema formats that * manually specify indices. */ public native void SetDefIndex(int attrdef); /** * Clears the attribute's specified definition index. */ public native void ClearDefIndex(); /** * Stores a copy of the attribute properties in the core plugin to be injected. * * This operation does not clear existing values on the EconInjectedAttribute, so you can * create multiple attributes by repeatedly calling EconInjectedAttribute.SetName() and * EconInjectedAttribute.Register(). * * If an attribute with the same name already exists and is not an injected attribute * managed by the core plugin, this will fail. * * The attribute definition index may be reallocated if a new copy of the schema is loaded * in and the index is occupied by a non-injected attribute. */ public native bool Register(); /** * Imports the properties of an attribute by name to the EconInjectedAttribute handle, * replacing all values currently set. * * @return True if the attribute exists, otherwise false. */ // TODO this isn't implemented yet // public native bool Import(const char[] name); /** * Resets the container to its initial state. */ public native void Clear(); }