cs_create_entity

Синтаксис

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