CreateEntityByName Function

Creates an entity by string name, but does not spawn it (see DispatchSpawn). If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is invalid or there is already an edict using that index, it will error out.

int CreateEntityByName(const char[] classname, int ForceEdictIndex)

Parameters

const char[] classname

Entity classname.

int ForceEdictIndex

Edict index used by the created entity (ignored on Orangebox and above).

Return Value

Entity index on success, or -1 on failure.

Errors

Invalid edict index, no map is running, or lack of mod support.