ExtraCommands: Make OutputInfo optional.

This commit is contained in:
zaCade 2022-12-07 14:44:40 +01:00
parent 2367266604
commit 9aefd25b20

View File

@ -4,11 +4,16 @@
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <outputinfo>
#include <halflife>
#undef REQUIRE_EXTENSIONS
#tryinclude <outputinfo>
#define REQUIRE_EXTENSIONS
#pragma newdecls required
bool g_Extension_OutputInfo = false;
bool g_bInBuyZoneAll = false;
bool g_bInBuyZone[MAXPLAYERS + 1] = {false, ...};
@ -84,6 +89,26 @@ public void OnPluginStart()
}
}
public void OnAllPluginsLoaded()
{
g_Extension_OutputInfo = LibraryExists("OutputInfo");
LogMessage("ExtraCommands capabilities:\nOutputInfo: %s",
(g_Extension_OutputInfo ? "loaded" : "not loaded"));
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, "OutputInfo"))
g_Extension_OutputInfo = true;
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, "OutputInfo"))
g_Extension_OutputInfo = false;
}
public void OnMapStart()
{
g_bInBuyZoneAll = false;
@ -1213,20 +1238,23 @@ stock void WAILA(int client, int iEntity)
PrintToConsole(client, "Entity Index: %i\nOrigin: %.f %.f %.f\nHammer ID: %d\nTarget name: %s\nModel Path: %s\nModel Index: %i\nClass Name: %s\nNet Class Name: %s",
iEntity, fvecOrigin[0], fvecOrigin[1], fvecOrigin[2], iHammerID, sTargetname, sModelPath, iEntityModelIdx, sClsName, sNetClsName);
char sOutputName[128];
for(int index = 0; ; index++)
if(g_Extension_OutputInfo)
{
sOutputName[0] = 0;
int len = GetOutputNames(iEntity, index, sOutputName, sizeof(sOutputName));
if(len < 0)
break;
int count = GetOutputCount(iEntity, sOutputName);
for(int i = 0; i < count; i++)
char sOutputName[128];
for(int index = 0; ; index++)
{
char sFormatted[1024];
GetOutputFormatted(iEntity, sOutputName, i, sFormatted, sizeof(sFormatted));
PrintToConsole(client, "%s: %s", sOutputName, sFormatted);
sOutputName[0] = 0;
int len = GetOutputNames(iEntity, index, sOutputName, sizeof(sOutputName));
if(len < 0)
break;
int count = GetOutputCount(iEntity, sOutputName);
for(int i = 0; i < count; i++)
{
char sFormatted[1024];
GetOutputFormatted(iEntity, sOutputName, i, sFormatted, sizeof(sFormatted));
PrintToConsole(client, "%s: %s", sOutputName, sFormatted);
}
}
}