native cs_create_entity(const classname[]);
classname | Entity class name |
Creates an entity using Counter-Strike's custom CreateNamedEntity wrapper.
Unlike other mods CS keeps track of entities using a custom hashtable. This function adds entities to this hashtable, providing benefits over the default CreateNamedEntity (used by create_entity() for example): - Storing entities in a hashtable allows CS to improve classname lookup performance compared to functions like FindEntityByString (used by find_ent_by_class() for example) that usually have to loop through all entities incrementally. - As CS exclusively uses the hashtable for classname lookup, entities created using the default engine functions will not be found by the game. For example "weaponbox" entities are supposed to be automatically cleaned up on round restart but are not considered if they have not been added to the hashtable.
The faster hashtable lookup can be utilized with cs_find_ent_by_class()
When creating an entity the classname has to be valid in the mod, as the engine needs to link the entity to an existing class internally. The classname string that is stored in the entvar struct (EV_SZ_classname) is separate from this association and can later be freely changed to serve other purposes.
Index of the created entity (> 0), 0 otherwise
This documentation was generated automatically using pawn-docgen written by xPaw for AlliedMods.