new plugin HostnameManager
This commit is contained in:
@@ -7,9 +7,7 @@
|
||||
|
||||
KeyValues g_Config;
|
||||
|
||||
ConVar g_cvHostName;
|
||||
|
||||
char g_sHostName[128];
|
||||
char g_sStageName[32];
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@@ -28,16 +26,27 @@ public Plugin myinfo =
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_cvHostName = FindConVar("hostname");
|
||||
|
||||
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
|
||||
{
|
||||
CreateNative("SD_GetStage", Native_GetStage);
|
||||
|
||||
RegPluginLibrary("StageDisplay");
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapStart()
|
||||
{
|
||||
g_sStageName = "unknown";
|
||||
|
||||
if(g_Config)
|
||||
delete g_Config;
|
||||
|
||||
@@ -65,14 +74,6 @@ public void OnMapStart()
|
||||
g_Config.Rewind();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
g_cvHostName.GetString(g_sHostName, sizeof(g_sHostName));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -202,15 +203,26 @@ public void CheckStage()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char sBuffer[sizeof(g_sHostName)];
|
||||
|
||||
if(bHasDiffCounter)
|
||||
Format(sBuffer, sizeof(sBuffer), "%s | Stage: [%s - %s]", g_sHostName, sStageName, sDiffName);
|
||||
Format(g_sStageName, sizeof(g_sStageName), "%s - %s", sStageName, sDiffName);
|
||||
else
|
||||
Format(sBuffer, sizeof(sBuffer), "%s | Stage: [%s]", g_sHostName, sStageName);
|
||||
Format(g_sStageName, sizeof(g_sStageName), "%s", sStageName);
|
||||
}
|
||||
|
||||
g_cvHostName.SetString(sBuffer, false, false);
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_GetStage(Handle hPlugin, int numParams)
|
||||
{
|
||||
int length = GetNativeCell(2);
|
||||
|
||||
char[] sStage = new char[length + 1];
|
||||
Format(sStage, length + 1, "%s", g_sStageName);
|
||||
|
||||
if (strcmp(sStage, "unknown", true) == 0)
|
||||
return 0;
|
||||
|
||||
return !(SetNativeString(1, sStage, length + 1));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#if defined _StageDisplay_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define _StageDisplay_included
|
||||
|
||||
/**
|
||||
* Retrieve current stage name.
|
||||
*
|
||||
* @param name The buffer to write to.
|
||||
* @param maxlength The maximum buffer length.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool SD_GetStage(char[] name, int maxlength);
|
||||
|
||||
|
||||
public SharedPlugin __pl_StageDisplay =
|
||||
{
|
||||
name = "StageDisplay",
|
||||
file = "StageDisplay.smx",
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_StageDisplay_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("SD_GetStage");
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user