From 522b41682e5b984d6a75ec35b0d142dc70a11f06 Mon Sep 17 00:00:00 2001 From: shavit Date: Sat, 29 Dec 2018 20:15:13 +0200 Subject: [PATCH] Fixed CS:GO HUD hint showing empty --- addons/sourcemod/scripting/shavit-hud.sp | 50 ++++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-hud.sp b/addons/sourcemod/scripting/shavit-hud.sp index b5465229..ed1ccefa 100644 --- a/addons/sourcemod/scripting/shavit-hud.sp +++ b/addons/sourcemod/scripting/shavit-hud.sp @@ -782,8 +782,9 @@ int GetGradient(int start, int end, int steps) return GetHex(aColorGradient); } -void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int maxlen) +int AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int maxlen) { + int iLines = 0; char sLine[128]; if(data.bReplay) @@ -802,11 +803,13 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma { FormatEx(sLine, 128, "%s %s%T", gS_StyleStrings[data.iStyle].sStyleName, sTrack, "ReplayText", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } char sPlayerName[MAX_NAME_LENGTH]; Shavit_GetReplayName(data.iStyle, data.iTrack, sPlayerName, MAX_NAME_LENGTH); AddHUDLine(buffer, maxlen, sPlayerName); + iLines++; if((gI_HUD2Settings[client] & HUD2_TIME) == 0) { @@ -818,12 +821,14 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma FormatEx(sLine, 128, "%s / %s\n(%.1f%)", sTime, sWR, ((data.fTime / data.fWR) * 100)); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if((gI_HUD2Settings[client] & HUD2_SPEED) == 0) { FormatEx(sLine, 128, "%d u/s", data.iSpeed); AddHUDLine(buffer, maxlen, sLine); + iLines++; } } @@ -831,9 +836,10 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma { FormatEx(sLine, 128, "%T", (gEV_Type == Engine_TF2)? "NoReplayDataTF2":"NoReplayData", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } - return; + return iLines; } if((gI_HUDSettings[client] & HUD_ZONEHUD) > 0 && data.iZoneHUD != ZoneHUD_None) @@ -841,7 +847,7 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma FormatEx(sLine, 128, "%T ", (data.iZoneHUD == ZoneHUD_Start)? "HudInStartZone":"HudInEndZone", client, data.iSpeed); AddHUDLine(buffer, maxlen, sLine); - return; + return ++iLines; } if(data.iTimerStatus != Timer_Stopped) @@ -849,12 +855,14 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma if((gI_HUD2Settings[client] & HUD2_STYLE) == 0) { AddHUDLine(buffer, maxlen, gS_StyleStrings[data.iStyle].sStyleName); + iLines++; } if(data.bPractice || data.iTimerStatus == Timer_Paused) { FormatEx(sLine, 128, "%T", (data.iTimerStatus == Timer_Paused)? "HudPaused":"HudPracticeMode", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if((gI_HUD2Settings[client] & HUD2_TIME) == 0) @@ -873,18 +881,21 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma } AddHUDLine(buffer, maxlen, sLine); + iLines++; } if((gI_HUD2Settings[client] & HUD2_JUMPS) == 0) { FormatEx(sLine, 128, "%T: %d", "HudJumpsText", client, data.iJumps); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if((gI_HUD2Settings[client] & HUD2_STRAFE) == 0) { FormatEx(sLine, 128, "%T: %d", "HudStrafeText", client, data.iStrafes); AddHUDLine(buffer, maxlen, sLine); + iLines++; } } @@ -903,6 +914,7 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma } AddHUDLine(buffer, maxlen, sLine); + iLines++; } if(data.iTimerStatus != Timer_Stopped && data.iTrack != Track_Main && (gI_HUD2Settings[client] & HUD2_TRACK) == 0) @@ -912,11 +924,15 @@ void AddHUDToBuffer_Source2013(int client, huddata_t data, char[] buffer, int ma Format(sTrack, 32, "%s", sTrack); AddHUDLine(buffer, maxlen, sTrack); + iLines++; } + + return iLines; } -void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) +int AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) { + int iLines = 0; char sLine[128]; if(data.bReplay) @@ -938,6 +954,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) FormatEx(sLine, 128, "%s %s%T %s", gS_StyleStrings[data.iStyle].sHTMLColor, gS_StyleStrings[data.iStyle].sStyleName, sTrack, "ReplayText", client, sPlayerName); AddHUDLine(buffer, maxlen, sLine); + iLines++; if((gI_HUD2Settings[client] & HUD2_TIME) == 0) { @@ -949,6 +966,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) FormatEx(sLine, 128, "%s / %s (%.1f%%)", sTime, sWR, ((data.fTime / data.fWR) * 100)); AddHUDLine(buffer, maxlen, sLine); + iLines++; } } @@ -956,11 +974,12 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) { FormatEx(sLine, 128, "%T", "NoReplayData", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } StrCat(buffer, maxlen, ""); - return; + return iLines; } if((gI_HUDSettings[client] & HUD_ZONEHUD) > 0 && data.iZoneHUD != ZoneHUD_None) @@ -972,7 +991,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) FormatEx(sZoneHUD, 64, "%T", (data.iZoneHUD == ZoneHUD_Start)? "HudInStartZoneCSGO":"HudInEndZoneCSGO", client, data.iSpeed); StrCat(buffer, maxlen, sZoneHUD); - return; + return ++iLines; } StrCat(buffer, maxlen, ""); @@ -983,6 +1002,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) { FormatEx(sLine, 128, "%T", (data.iTimerStatus == Timer_Paused)? "HudPaused":"HudPracticeMode", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if(data.iTimerStatus != Timer_Stopped && data.iTrack != Track_Main && (gI_HUD2Settings[client] & HUD2_TRACK) == 0) @@ -992,6 +1012,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) Format(sTrack, 32, "%s", sTrack); AddHUDLine(buffer, maxlen, sTrack); + iLines++; } if((gI_HUD2Settings[client] & HUD2_TIME) == 0) @@ -1016,6 +1037,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) } AddHUDLine(buffer, maxlen, sLine); + iLines++; } } @@ -1030,6 +1052,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) FormatEx(sLine, 128, "%d u/s", iColor, data.iSpeed); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if(data.iTimerStatus != Timer_Stopped) @@ -1038,6 +1061,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) { FormatEx(sLine, 128, "%d %T", data.iJumps, "HudJumpsText", client); AddHUDLine(buffer, maxlen, sLine); + iLines++; } if((gI_HUD2Settings[client] & HUD2_STRAFE) == 0) @@ -1053,6 +1077,7 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) } AddHUDLine(buffer, maxlen, sLine); + iLines++; } } @@ -1060,9 +1085,12 @@ void AddHUDToBuffer_CSGO(int client, huddata_t data, char[] buffer, int maxlen) { FormatEx(sLine, 128, "%s", gS_StyleStrings[data.iStyle].sHTMLColor, gS_StyleStrings[data.iStyle].sStyleName); AddHUDLine(buffer, maxlen, sLine); + iLines++; } StrCat(buffer, maxlen, ""); + + return iLines; } void UpdateMainHUD(int client) @@ -1129,23 +1157,21 @@ void UpdateMainHUD(int client) huddata.bPractice = (bReplay)? false:Shavit_IsPracticeMode(target); char sBuffer[512]; - int iLen = 0; + int iLines = 0; if(IsSource2013(gEV_Type)) { - AddHUDToBuffer_Source2013(client, huddata, sBuffer, 512); - iLen = strlen(sBuffer); + iLines = AddHUDToBuffer_Source2013(client, huddata, sBuffer, 512); } else { StrCat(sBuffer, 512, "
");
-		AddHUDToBuffer_CSGO(client, huddata, sBuffer, 512);
-		iLen = (strlen(sBuffer) - 5); // excluding 
+		iLines = AddHUDToBuffer_CSGO(client, huddata, sBuffer, 512);
 		StrCat(sBuffer, 512, "
"); } - if(iLen > 0) + if(iLines > 0) { PrintHintText(client, "%s", sBuffer); }