I faced same issue in our 'sound attenuation' plugin. The only official way I know is:
PHP Code:
if (GetExtensionFileStatus("VoiceHook.ext") == 1)
but it is not reliable since heavily depends on filename. Easily can break your plugin by next extension update (or admin can decide to rename).
And that's bad sm doesn't expose more functions for such check, at least to retrieve extension's name by index.
There is one walkaround: you can send
ServerCommandEx cmd:
Spoiler
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#define EXT_NAME "VoiceHook"
public void OnPluginStart()
{
RegConsoleCmd("sm_ex", CmdExt);
}
Action CmdExt(int client, int args)
{
if ( IsExtensionLoaded(EXT_NAME) )
{
PrintToChatAll("Extension found: %s", EXT_NAME);
}
else {
PrintToChatAll("No extension: %s", EXT_NAME);
}
return Plugin_Handled;
}
bool IsExtensionLoaded(char[] sExtensionName)
{
char ret[3000], buf[32][256];
ServerCommandEx(ret, sizeof(ret), "sm exts list");
ServerExecute();
int cnt = ExplodeString(ret, "\x0A", buf, sizeof(buf), sizeof(buf[]), true);
for (int i = 0; i < cnt; i++)
{
if ( -1 != StrContains(buf[i], sExtensionName, false) )
{
return -1 == StrContains(buf[i], "<FAILED>", false);
}
}
return false;
}
to intercept server answer.
So, by parsing that you can surely identify whether extension of your interest is loaded.
Again, until somebody patch sm exts command to hide output.
__________________