ISource2ModFeatures

Asking whether something optional is there before using it.

SourceMod's GetFeatureStatus, for both kinds of plugin: a native C++ plugin asks before it calls into another plugin's interface or relies on a part of the core that may be switched off (GeoIP without a database), a SourcePawn plugin asks the same through GetFeatureStatus() / Source2ModFeatures.

What can be asked about:

  • a native -- a SourcePawn native, the core's own or one a plugin registered (CreateNative, ISource2ModNatives). A plugin native is Unavailable while its plugin is unloaded.
  • a capability -- a named part of the core that can be missing at runtime; the names are the SOURCE2MOD_CAPABILITY_* below.
  • an interface -- an interface Source2ModFactory() would hand out: the core's (at the exact revision asked for) or one a plugin serves through OnSource2ModQuery.
  • a library -- a name a plugin registered (RegPluginLibrary, ISource2ModNatives::RegisterLibrary).

Interface id ISource2ModFeatures001 (SOURCE2MOD_FEATURES_INTERFACE) · Global g_pSource2ModFeatures · Header source2mod/ISource2ModFeatures.h

Methods

GetFeatureStatus

virtual Source2ModFeatureStatus GetFeatureStatus(Source2ModFeatureType type, const char* name) = 0;

The status of a native, capability, interface or library.

ParameterTypeDescription
typeSource2ModFeatureTypeWhat name names.
nameconst char*The native, capability, interface ("ISource2ModMenus005") or library name.

IsNativeAvailable

virtual bool IsNativeAvailable(const char* name) = 0;

GetFeatureStatus(SOURCE2MOD_FEATURE_NATIVE, name) == AVAILABLE.

ParameterType
nameconst char*

IsInterfaceAvailable

virtual bool IsInterfaceAvailable(const char* iface) = 0;

Whether Source2ModFactory() would hand this interface out right now. Unlike asking the factory, a miss is not logged.

ParameterType
ifaceconst char*

IsLibraryAvailable

virtual bool IsLibraryAvailable(const char* name) = 0;

Whether some plugin registered this library and is still loaded.

ParameterType
nameconst char*

HasCapability

virtual bool HasCapability(const char* name) = 0;

Whether a SOURCE2MOD_CAPABILITY_* is usable.

ParameterType
nameconst char*

Enums

Source2ModFeatureType

enum Source2ModFeatureType

The same numbers as SourceMod's FeatureType, plus the two Source2Mod adds.

NameValue
SOURCE2MOD_FEATURE_NATIVE0
SOURCE2MOD_FEATURE_CAPABILITY1
SOURCE2MOD_FEATURE_INTERFACE2
SOURCE2MOD_FEATURE_LIBRARY3

Source2ModFeatureStatus

enum Source2ModFeatureStatus

The same numbers as SourceMod's FeatureStatus.

NameValueDescription
SOURCE2MOD_FEATURE_AVAILABLE0There, and usable.
SOURCE2MOD_FEATURE_UNAVAILABLE1Known, but not usable right now (its plugin unloaded, no database, ...).
SOURCE2MOD_FEATURE_UNKNOWN2Not known at all.

Macros

SOURCE2MOD_CAPABILITY_SOURCEPAWN

#define SOURCE2MOD_CAPABILITY_SOURCEPAWN "sourcepawn"

The SourcePawn VM: always there in this core.

SOURCE2MOD_CAPABILITY_GEOIP

#define SOURCE2MOD_CAPABILITY_GEOIP "geoip"

GeoIP lookups: a GeoLite2 database was found and opened.

SOURCE2MOD_CAPABILITY_CLIENTPREFS

#define SOURCE2MOD_CAPABILITY_CLIENTPREFS "clientprefs"

Client preferences: the cookie database is connected.

SOURCE2MOD_CAPABILITY_GAMESYSTEMS

#define SOURCE2MOD_CAPABILITY_GAMESYSTEMS "gamesystems"

Registering game systems (ISource2ModGameSystems::IsAvailable()).

On this page