This commit is contained in:
Dogan 2019-01-24 16:26:06 +01:00
commit 4f03e84096
12 changed files with 384 additions and 0 deletions

View File

@ -0,0 +1,11 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "EASY"
"2" "NORMAL"
"3" "HARD"
"4" "EXTREME"
"5" "INSAME"
"6" "ZM"
}

View File

@ -0,0 +1,10 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"0" "WARMUP"
"1" "CHAPTER 1"
"2" "CHAPTER 2"
"3" "CHAPTER 3"
"4" "CHAPTER 4"
}

View File

@ -0,0 +1,16 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "WARMUP"
"2" "NORMAL"
"3" "HARD"
"4" "EXTREME"
"5" "EXTREME II"
"6" "ZM"
"7" "EXTREME II (HEAL&ULTIMA ONLY)"
"8" "EXTREME II (SPECIAL LASERS)"
"9" "EXTREME III (HELLZ VERSION)"
"10" "EXTREME III (ZOMBIEDEN VERSION)"
"11" "RACE (ZOMBIEDEN VERSION)"
}

View File

@ -0,0 +1,9 @@
"stagedisplay"
{
"method" "counter"
"counter" "Map_WinCounter"
"1" "1 - NORMAL"
"2" "2 - NORMAL"
"3" "1 - INSANE"
"4" "2 - INSANE"
}

View File

@ -0,0 +1,14 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter_Progress"
"1" "HARD"
"2" "EXTREME"
"3" "EPIC"
"4" "GODMODE"
"5" "ZOMBIE MOD"
"6" "HARD - INSANE"
"7" "EXTREME - INSANE"
"8" "EPIC - INSANE"
"9" "GODMODE - INSANE"
}

View File

@ -0,0 +1,10 @@
"stagedisplay"
{
"method" "score"
"0" "1 - PRISON ESCAPE"
"1" "2 - CANNON"
"2" "3 - PIRATE"
"3" "4 - BARBOSSA"
"4" "5 - KRAKEN"
"5" "5 - GOD KRAKEN"
}

View File

@ -0,0 +1,11 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "WARMUP"
"2" "1"
"3" "2"
"4" "3"
"5" "4"
"6" "5"
}

View File

@ -0,0 +1,17 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "WARMUP"
"2" "OSGILIATH"
"3" "MAIN GATES"
"4" "CATAPULT"
"5" "THE LAST STAND"
"diffcounter"
{
"counter" "Diff_Counter"
"1" "NORMAL"
"2" "EXTREME"
}
}

View File

@ -0,0 +1,17 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "WARMUP"
"2" "OSGILIATH"
"3" "MAIN GATES"
"4" "CATAPULT"
"5" "THE LAST STAND"
"diffcounter"
{
"counter" "Diff_Counter"
"1" "NORMAL"
"2" "EXTREME"
}
}

View File

@ -0,0 +1,9 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "1 - NORMAL"
"2" "2 - HARD"
"3" "3 - HYPER"
"4" "4 - ULTIMATE"
}

View File

@ -0,0 +1,13 @@
"stagedisplay"
{
"method" "counter"
"counter" "Level_Counter"
"1" "WARMUP"
"2" "RAVINE - NORMAL"
"3" "TV - NORMAL"
"4" "HEAVEN - NORMAL"
"5" "RAVINE - EXTREME"
"6" "TV - EXTREME"
"7" "HEAVEN - EXTREME"
"8" "THE END"
}

View File

@ -0,0 +1,247 @@
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <cstrike>
KeyValues g_Config;
ConVar g_cvHostName;
char g_sHostName[128];
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "Stage Display",
author = "Neon",
description = "",
version = "1.0",
url = "https://steamcommunity.com/id/n3ontm"
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
g_cvHostName = FindConVar("hostname");
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
if(g_Config)
delete g_Config;
char sMapName[PLATFORM_MAX_PATH];
GetCurrentMap(sMapName, sizeof(sMapName));
char sConfigFile[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/stagedisplay/%s.cfg", sMapName);
if(!FileExists(sConfigFile))
{
LogMessage("Could not find mapconfig: \"%s\"", sConfigFile);
return;
}
LogMessage("Found mapconfig: \"%s\"", sConfigFile);
g_Config = new KeyValues("stagedisplay");
if(!g_Config.ImportFromFile(sConfigFile))
{
delete g_Config;
SetFailState("ImportFromFile() failed!");
return;
}
g_Config.Rewind();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnConfigsExecuted()
{
g_cvHostName.GetString(g_sHostName, sizeof(g_sHostName));
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
CreateTimer(3.0, CheckStageTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action CheckStageTimer(Handle timer)
{
CheckStage();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void CheckStage()
{
if(!g_Config)
return;
g_Config.Rewind();
char sMethod[64];
g_Config.GetString("method", sMethod, sizeof(sMethod));
if(!sMethod[0])
{
LogError("Could not find \"method\"");
return;
}
char sStageName[64];
char sDiffName[64];
if(StrEqual(sMethod, "counter"))
{
char sCounter[64];
if(!g_Config.GetString("counter", sCounter, sizeof(sCounter)))
{
LogError("Could not find \"counter\"");
return;
}
int iCounterEnt = INVALID_ENT_REFERENCE;
iCounterEnt = FindEntityByTargetname(iCounterEnt, sCounter, "*");
if(iCounterEnt == INVALID_ENT_REFERENCE)
{
LogError("Could not find entity: \"%s\"", sCounter);
return;
}
static int iOffset = -1;
if (iOffset == -1)
iOffset = FindDataMapInfo(iCounterEnt, "m_OutValue");
int iValue = RoundToNearest(GetEntDataFloat(iCounterEnt, iOffset));
char sValue[8];
IntToString(iValue, sValue, sizeof(sValue));
g_Config.GetString(sValue, sStageName, sizeof(sStageName));
if(!sStageName[0])
{
LogError("Could not find stage \"%s\"", sValue);
return;
}
}
else if(StrEqual(sMethod, "score"))
{
int iValue = CS_GetTeamScore(CS_TEAM_CT);
char sValue[8];
IntToString(iValue, sValue, sizeof(sValue));
g_Config.GetString(sValue, sStageName, sizeof(sStageName));
if(!sStageName[0])
{
LogError("Could not find stage \"%s\"", sValue);
return;
}
}
else
{
LogError("Unknown method \"%s\"", sMethod);
return;
}
g_Config.Rewind();
bool bHasDiffCounter = false;
if(g_Config.JumpToKey("diffcounter", false))
{
bHasDiffCounter = true;
char sDiffCounter[64];
if(!g_Config.GetString("counter", sDiffCounter, sizeof(sDiffCounter)))
{
LogError("Could not find \"diffcounter\"");
return;
}
int iDiffCounterEnt = INVALID_ENT_REFERENCE;
iDiffCounterEnt = FindEntityByTargetname(iDiffCounterEnt, sDiffCounter, "*");
if(iDiffCounterEnt == INVALID_ENT_REFERENCE)
{
LogError("Could not find entity: \"%s\"", sDiffCounter);
return;
}
static int iOffset = -1;
if (iOffset == -1)
iOffset = FindDataMapInfo(iDiffCounterEnt, "m_OutValue");
int iValue = RoundToNearest(GetEntDataFloat(iDiffCounterEnt, iOffset));
char sValue[8];
IntToString(iValue, sValue, sizeof(sValue));
g_Config.GetString(sValue, sDiffName, sizeof(sDiffName));
if(!sStageName[0])
{
LogError("Could not find difficulty \"%s\"", sValue);
return;
}
}
char sBuffer[sizeof(g_sHostName)];
if(bHasDiffCounter)
Format(sBuffer, sizeof(sBuffer), "%s | Stage: [%s - %s]", g_sHostName, sStageName, sDiffName);
else
Format(sBuffer, sizeof(sBuffer), "%s | Stage: [%s]", g_sHostName, sStageName);
g_cvHostName.SetString(sBuffer, false, false);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
int FindEntityByTargetname(int entity, const char[] sTargetname, const char[] sClassname="*")
{
if(sTargetname[0] == '#') // HammerID
{
int HammerID = StringToInt(sTargetname[1]);
while((entity = FindEntityByClassname(entity, sClassname)) != INVALID_ENT_REFERENCE)
{
if(GetEntProp(entity, Prop_Data, "m_iHammerID") == HammerID)
return entity;
}
}
else // Targetname
{
int Wildcard = FindCharInString(sTargetname, '*');
char sTargetnameBuf[64];
while((entity = FindEntityByClassname(entity, sClassname)) != INVALID_ENT_REFERENCE)
{
if(GetEntPropString(entity, Prop_Data, "m_iName", sTargetnameBuf, sizeof(sTargetnameBuf)) <= 0)
continue;
if(strncmp(sTargetnameBuf, sTargetname, Wildcard) == 0)
return entity;
}
}
return INVALID_ENT_REFERENCE;
}