In order to fetch VScript functions and use them, the script system needs to be initialized. You can do this in OnMapStart but since this calls every map, it's not ideal.
It would be better to have a OnVScriptServerInitPost (suggested name) forward. It should also be late-called when the plugin first loads and the script system is already initialized. That way plugins using this library have a one-stop function to fetch and initialize everything requiring VScript functions.
public void OnPluginStart()
{
// Script system might not be initialized when this calls e.g. on server start.
}
public void OnVScriptServerInitPost()
{
// Script system is guaranteed to be initialized here.
VScriptFunction hScriptGetSubType = VScript_GetClassFunction("CBaseCombatWeapon", "GetSubType");
if (hScriptGetSubType)
g_hSDKCallGetSubType = hScriptGetSubType.CreateSDKCall();
}
In order to fetch VScript functions and use them, the script system needs to be initialized. You can do this in
OnMapStartbut since this calls every map, it's not ideal.It would be better to have a
OnVScriptServerInitPost(suggested name) forward. It should also be late-called when the plugin first loads and the script system is already initialized. That way plugins using this library have a one-stop function to fetch and initialize everything requiring VScript functions.