1919#include <lerpmonitor>
2020#include <witch_and_tankifier>
2121
22- #define PLUGIN_VERSION " 3.8.6 "
22+ #define PLUGIN_VERSION " 3.9.0 "
2323
2424public Plugin myinfo =
2525{
@@ -33,7 +33,7 @@ public Plugin myinfo =
3333// ======================================================================
3434// Macros
3535// ======================================================================
36- #define SPECHUD_DRAW_INTERVAL 0.5
36+ #define SPECHUD_DRAW_INTERVAL 1.0
3737#define TRANSLATION_FILE " spechud.phrases"
3838
3939// ======================================================================
@@ -317,6 +317,19 @@ public void OnClientDisconnect(int client)
317317 bTankHudHintShown [client ] = false ;
318318}
319319
320+ Action Timer_RespectateSpecs (Handle hTimer )
321+ {
322+ for (int i = 1 ; i <= MaxClients ; i ++ )
323+ {
324+ if (IsClientInGame (i ) && ! IsFakeClient (i ) && GetClientTeam (i ) == L4D2Team_Spectator )
325+ {
326+ FakeClientCommand (i , " sm_spectate" );
327+ }
328+ }
329+
330+ return Plugin_Stop ;
331+ }
332+
320333public void OnMapStart () { bRoundLive = false ; }
321334public void OnRoundIsLive ()
322335{
@@ -326,11 +339,7 @@ public void OnRoundIsLive()
326339
327340 GetCurrentGameMode ();
328341
329- for (int i = 1 ; i <= MaxClients ; i ++ )
330- {
331- if (IsClientInGame (i ) && GetClientTeam (i ) == L4D2Team_Spectator && ! IsClientSourceTV (i ))
332- FakeClientCommand (i , " sm_spectate" );
333- }
342+ CreateTimer (0.2 , Timer_RespectateSpecs );
334343
335344 if (g_Gamemode == GAMEMODE_VERSUS )
336345 {
@@ -583,7 +592,7 @@ void FillHeaderInfo(Panel hSpecHud)
583592 iTickrate = RoundToNearest (1.0 / GetTickInterval ());
584593
585594 static char buf [64 ];
586- Format (buf , sizeof (buf ), " Server: %s [Slots %i /%i | %i T]" , sHostname , GetRealClientCount (), iMaxPlayers , iTickrate );
595+ Format (buf , sizeof (buf ), " %s [%i /%i | %i T]" , sHostname , GetRealClientCount (), iMaxPlayers , iTickrate );
587596 DrawPanelText (hSpecHud , buf );
588597}
589598
@@ -680,10 +689,24 @@ int SortSurvByCharacter(int elem1, int elem2, const int[] array, Handle hndl)
680689 else { return 0 ; }
681690}
682691
692+ void GetClientPing (int client , char [] buffer , int bufferSize )
693+ {
694+ if (IsFakeClient (client ))
695+ {
696+ Format (buffer , bufferSize , " BOT" );
697+ }
698+ else
699+ {
700+ int latency = RoundToNearest (GetClientAvgLatency (client , NetFlow_Both ) * 1000.0 );
701+ Format (buffer , bufferSize , " %i ms" , latency );
702+ }
703+ }
704+
683705void FillSurvivorInfo (Panel hSpecHud )
684706{
685707 static char info [100 ];
686708 static char name [MAX_NAME_LENGTH ];
709+ static char latency [8 ];
687710
688711 int SurvivorTeamIndex = GameRules_GetProp (" m_bAreTeamsFlipped" );
689712
@@ -692,18 +715,18 @@ void FillSurvivorInfo(Panel hSpecHud)
692715 case GAMEMODE_SCAVENGE :
693716 {
694717 int score = GetScavengeMatchScore (SurvivorTeamIndex );
695- FormatEx (info , sizeof (info ), " ->1. Survivors [%d of %d ]" , score , GetScavengeRoundLimit ());
718+ FormatEx (info , sizeof (info ), " ->1. Sur [%d of %d ]" , score , GetScavengeRoundLimit ());
696719 }
697720 case GAMEMODE_VERSUS :
698721 {
699722 if (bRoundLive )
700723 {
701- FormatEx (info , sizeof (info ), " ->1. Survivors [%d ]" ,
724+ FormatEx (info , sizeof (info ), " ->1. Sur [%d ]" ,
702725 L4D2Direct_GetVSCampaignScore (SurvivorTeamIndex ) + GetVersusProgressDistance (SurvivorTeamIndex ));
703726 }
704727 else
705728 {
706- FormatEx (info , sizeof (info ), " ->1. Survivors [%d ]" ,
729+ FormatEx (info , sizeof (info ), " ->1. Sur [%d ]" ,
707730 L4D2Direct_GetVSCampaignScore (SurvivorTeamIndex ));
708731 }
709732 }
@@ -729,23 +752,24 @@ void FillSurvivorInfo(Panel hSpecHud)
729752 int client = clients [i ];
730753
731754 GetClientFixedName (client , name , sizeof (name ));
755+ GetClientPing (client , latency , sizeof (latency ));
732756 if (! IsPlayerAlive (client ))
733757 {
734- FormatEx (info , sizeof (info ), " %s : Dead" , name );
758+ FormatEx (info , sizeof (info ), " %s | %s : Dead" , latency , name );
735759 }
736760 else
737761 {
738762 if (IsHangingFromLedge (client ))
739763 {
740764 // Nick: <300HP@Hanging>
741- FormatEx (info , sizeof (info ), " %s : <%i HP@Hanging> " , name , GetClientHealth (client ));
765+ FormatEx (info , sizeof (info ), " %s | %s : <%i HP@Hang> " , latency , name , GetClientHealth (client ));
742766 }
743767 else if (IsIncapacitated (client ))
744768 {
745769 int activeWep = GetEntPropEnt (client , Prop_Send , " m_hActiveWeapon" );
746770 GetLongWeaponName (IdentifyWeapon (activeWep ), info , sizeof (info ));
747771 // Nick: <300HP@1st> [Deagle 8]
748- Format (info , sizeof (info ), " %s : <%i HP@%s > [%s %i ]" , name , GetClientHealth (client ), (GetSurvivorIncapCount (client ) == 1 ? " 2nd" : " 1st" ), info , GetWeaponClipAmmo (activeWep ));
772+ Format (info , sizeof (info ), " %s | %s : <%i HP@%s > [%s %i ]" , latency , name , GetClientHealth (client ), (GetSurvivorIncapCount (client ) == 1 ? " 2nd" : " 1st" ), info , GetWeaponClipAmmo (activeWep ));
749773 }
750774 else
751775 {
@@ -758,13 +782,13 @@ void FillSurvivorInfo(Panel hSpecHud)
758782 {
759783 // "#" indicates that player is bleeding.
760784 // Nick: 99HP# [Chrome 8/72]
761- Format (info , sizeof (info ), " %s : %i HP%s [%s ]" , name , health , (tempHealth > 0 ? " #" : " " ), info );
785+ Format (info , sizeof (info ), " %s | %s : %i HP%s [%s ]" , latency , name , health , (tempHealth > 0 ? " #" : " " ), info );
762786 }
763787 else
764788 {
765789 // Player ever incapped should always be bleeding.
766790 // Nick: 99HP (#1st) [Chrome 8/72]
767- Format (info , sizeof (info ), " %s : %i HP (#%s ) [%s ]" , name , health , (incapCount == 2 ? " 2nd" : " 1st" ), info );
791+ Format (info , sizeof (info ), " %s | %s : %i HP (#%s ) [%s ]" , latency , name , health , (incapCount == 2 ? " 2nd" : " 1st" ), info );
768792 }
769793 }
770794 }
@@ -815,22 +839,22 @@ void FillScoreInfo(Panel hSpecHud)
815839
816840 DrawPanelText (hSpecHud , " " );
817841
818- // > HB: 100% | DB: 100% | Pills: 60 / 100%
819- // > Bonus: 860 <100.0 %>
820- // > Distance : 400
842+ // > HB: 860 <86%> | DB: 420 <84%> | Pills: 60 <60%>
843+ // > Bonus: 1340 <83.8 %>
844+ // > Dist : 400
821845
822846 FormatEx ( info ,
823847 sizeof (info ),
824- " > HB: %.0f%% | DB: %.0f%% | Pills: %i / %.0f%% " ,
825- L4D2Util_IntToPercentFloat (healthBonus , maxHealthBonus ),
826- L4D2Util_IntToPercentFloat (damageBonus , maxDamageBonus ),
848+ " > HB: %i < % .0f%%> | DB: %i < % .0f%%> | Pills: %i < %.0f%% > " ,
849+ healthBonus , L4D2Util_IntToPercentFloat (healthBonus , maxHealthBonus ),
850+ damageBonus , L4D2Util_IntToPercentFloat (damageBonus , maxDamageBonus ),
827851 pillsBonus , L4D2Util_IntToPercentFloat (pillsBonus , maxPillsBonus ));
828852 DrawPanelText (hSpecHud , info );
829853
830854 FormatEx (info , sizeof (info ), " > Bonus: %i <%.1f%% >" , totalBonus , L4D2Util_IntToPercentFloat (totalBonus , maxTotalBonus ));
831855 DrawPanelText (hSpecHud , info );
832856
833- FormatEx (info , sizeof (info ), " > Distance : %i " , iMaxDistance );
857+ FormatEx (info , sizeof (info ), " > Dist : %i " , iMaxDistance );
834858 //if (InSecondHalfOfRound())
835859 //{
836860 // Format(info, sizeof(info), "%s | R#1: %i <%.1f%%>", info, iFirstHalfScore, L4D2Util_IntToPercentFloat(iFirstHalfScore, L4D_GetVersusMaxCompletionScore() + maxTotalBonus));
@@ -844,13 +868,13 @@ void FillScoreInfo(Panel hSpecHud)
844868
845869 DrawPanelText (hSpecHud , " " );
846870
847- // > Health Bonus : 860
848- // > Distance : 400
871+ // > HB : 860
872+ // > Dist : 400
849873
850- FormatEx (info , sizeof (info ), " > Health Bonus : %i " , healthBonus );
874+ FormatEx (info , sizeof (info ), " > HB : %i " , healthBonus );
851875 DrawPanelText (hSpecHud , info );
852876
853- FormatEx (info , sizeof (info ), " > Distance : %i " , iMaxDistance );
877+ FormatEx (info , sizeof (info ), " > Dist : %i " , iMaxDistance );
854878 //if (InSecondHalfOfRound())
855879 //{
856880 // Format(info, sizeof(info), "%s | R#1: %i", info, iFirstHalfScore);
@@ -871,7 +895,7 @@ void FillScoreInfo(Panel hSpecHud)
871895
872896 // > Perm: 114 | Temp: 514 | Pills: 810
873897 // > Bonus: 114514 <100.0%>
874- // > Distance : 191
898+ // > Dist : 191
875899 // never ever played on Next so take it easy.
876900
877901 FormatEx ( info ,
@@ -883,7 +907,7 @@ void FillScoreInfo(Panel hSpecHud)
883907 FormatEx (info , sizeof (info ), " > Bonus: %i <%.1f%% >" , totalBonus , L4D2Util_IntToPercentFloat (totalBonus , maxTotalBonus ));
884908 DrawPanelText (hSpecHud , info );
885909
886- FormatEx (info , sizeof (info ), " > Distance : %i " , iMaxDistance );
910+ FormatEx (info , sizeof (info ), " > Dist : %i " , iMaxDistance );
887911 //if (InSecondHalfOfRound())
888912 //{
889913 // Format(info, sizeof(info), "%s | R#1: %i <%.1f%%>", info, iFirstHalfScore, ToPercent(iFirstHalfScore, L4D_GetVersusMaxCompletionScore() + maxTotalBonus));
@@ -899,6 +923,7 @@ void FillInfectedInfo(Panel hSpecHud)
899923 static char info [80 ];
900924 static char buffer [16 ];
901925 static char name [MAX_NAME_LENGTH ];
926+ static char latency [8 ];
902927
903928 int InfectedTeamIndex = ! GameRules_GetProp (" m_bAreTeamsFlipped" );
904929
@@ -907,11 +932,11 @@ void FillInfectedInfo(Panel hSpecHud)
907932 case GAMEMODE_SCAVENGE :
908933 {
909934 int score = GetScavengeMatchScore (InfectedTeamIndex );
910- FormatEx (info , sizeof (info ), " ->2. Infected [%d of %d ]" , score , GetScavengeRoundLimit ());
935+ FormatEx (info , sizeof (info ), " ->2. Inf [%d of %d ]" , score , GetScavengeRoundLimit ());
911936 }
912937 case GAMEMODE_VERSUS :
913938 {
914- FormatEx (info , sizeof (info ), " ->2. Infected [%d ]" ,
939+ FormatEx (info , sizeof (info ), " ->2. Inf [%d ]" ,
915940 L4D2Direct_GetVSCampaignScore (InfectedTeamIndex ));
916941 }
917942 }
@@ -926,19 +951,20 @@ void FillInfectedInfo(Panel hSpecHud)
926951 continue ;
927952
928953 GetClientFixedName (client , name , sizeof (name ));
954+ GetClientPing (client , latency , sizeof (latency ));
929955 if (! IsPlayerAlive (client ))
930956 {
931957 int timeLeft = RoundToFloor (L4D_GetPlayerSpawnTime (client ));
932958 if (timeLeft < 0 ) // Deathcam
933959 {
934960 // verygood: Dead
935- FormatEx (info , sizeof (info ), " %s : Dead" , name );
961+ FormatEx (info , sizeof (info ), " %s | %s : Dead" , latency , name );
936962 }
937963 else // Ghost Countdown
938964 {
939965 FormatEx (buffer , sizeof (buffer ), " %i s" , timeLeft );
940966 // verygood: Dead (15s)
941- FormatEx (info , sizeof (info ), " %s : Dead (%s )" , name , (timeLeft ? buffer : " Spawning... " ));
967+ FormatEx (info , sizeof (info ), " %s | %s : Dead (%s )" , latency , name , (timeLeft ? buffer : " S " ));
942968
943969 //char zClassName[10];
944970 //GetInfectedClassName(storedClass[client], zClassName, sizeof zClassName);
@@ -965,13 +991,13 @@ void FillInfectedInfo(Panel hSpecHud)
965991 // DONE: Handle a case of respawning chipped SI, show the ghost's health
966992 if (iHP < iMaxHP )
967993 {
968- // verygood: Charger (Ghost @1HP)
969- FormatEx (info , sizeof (info ), " %s : %s (Ghost @%i HP)" , name , zClassName , iHP );
994+ // verygood: Charger (G @1HP)
995+ FormatEx (info , sizeof (info ), " %s | %s : %s (G @%i HP)" , latency , name , zClassName , iHP );
970996 }
971997 else
972998 {
973- // verygood: Charger (Ghost )
974- FormatEx (info , sizeof (info ), " %s : %s (Ghost) " , name , zClassName );
999+ // verygood: Charger (G )
1000+ FormatEx (info , sizeof (info ), " %s | %s : %s (G) " , latency , name , zClassName );
9751001 }
9761002 }
9771003 else
@@ -995,12 +1021,12 @@ void FillInfectedInfo(Panel hSpecHud)
9951021 if (GetEntityFlags (client ) & FL_ONFIRE )
9961022 {
9971023 // verygood: Charger (1HP) [On Fire] [6s]
998- FormatEx (info , sizeof (info ), " %s : %s (%i HP) [On Fire]%s " , name , zClassName , iHP , buffer );
1024+ FormatEx (info , sizeof (info ), " %s | %s : %s (%i HP) [Fire]%s " , latency , name , zClassName , iHP , buffer );
9991025 }
10001026 else
10011027 {
10021028 // verygood: Charger (1HP) [6s]
1003- FormatEx (info , sizeof (info ), " %s : %s (%i HP)%s " , name , zClassName , iHP , buffer );
1029+ FormatEx (info , sizeof (info ), " %s | %s : %s (%i HP)%s " , latency , name , zClassName , iHP , buffer );
10041030 }
10051031 }
10061032 }
@@ -1011,7 +1037,7 @@ void FillInfectedInfo(Panel hSpecHud)
10111037
10121038 if (! infectedCount )
10131039 {
1014- DrawPanelText (hSpecHud , " There is no SI at this moment ." );
1040+ DrawPanelText (hSpecHud , " No SI ." );
10151041 }
10161042}
10171043
@@ -1054,11 +1080,11 @@ bool FillTankInfo(Panel hSpecHud, bool bTankHUD = false)
10541080 if (! IsFakeClient (tank ))
10551081 {
10561082 GetClientFixedName (tank , name , sizeof (name ));
1057- Format (info , sizeof (info ), " Control : %s (%s )" , name , info );
1083+ Format (info , sizeof (info ), " Ctrl : %s (%s )" , name , info );
10581084 }
10591085 else
10601086 {
1061- Format (info , sizeof (info ), " Control : AI (%s )" , info );
1087+ Format (info , sizeof (info ), " Ctrl : AI (%s )" , info );
10621088 }
10631089 DrawPanelText (hSpecHud , info );
10641090
@@ -1070,41 +1096,41 @@ bool FillTankInfo(Panel hSpecHud, bool bTankHUD = false)
10701096
10711097 if (health <= 0 || isIncapacitated )
10721098 {
1073- info = " Health : Dead" ;
1099+ info = " HP : Dead" ;
10741100 }
10751101 else
10761102 {
1077- FormatEx (info , sizeof (info ), " Health : %i / %i%% " , health , L4D2Util_GetMax (1 , RoundFloat (healthPercent )));
1103+ FormatEx (info , sizeof (info ), " HP : %i / %i%% " , health , L4D2Util_GetMax (1 , RoundFloat (healthPercent )));
10781104 }
10791105 DrawPanelText (hSpecHud , info );
10801106
10811107 // Draw frustration
10821108 if (! IsFakeClient (tank ))
10831109 {
1084- FormatEx (info , sizeof (info ), " Frustr. : %d%% " , GetTankFrustration (tank ));
1110+ FormatEx (info , sizeof (info ), " Frust : %d%% " , GetTankFrustration (tank ));
10851111 }
10861112 else
10871113 {
1088- info = " Frustr. : AI" ;
1114+ info = " Frust : AI" ;
10891115 }
10901116 DrawPanelText (hSpecHud , info );
10911117
10921118 // Draw network
10931119 if (! IsFakeClient (tank ))
10941120 {
1095- FormatEx (info , sizeof (info ), " Network : %i ms / %.1f " , RoundToNearest (GetClientAvgLatency (tank , NetFlow_Both ) * 1000.0 ), LM_GetLerpTime (tank ) * 1000.0 );
1121+ FormatEx (info , sizeof (info ), " Net : %i ms / %.1f " , RoundToNearest (GetClientAvgLatency (tank , NetFlow_Both ) * 1000.0 ), LM_GetLerpTime (tank ) * 1000.0 );
10961122 }
10971123 else
10981124 {
1099- info = " Network : AI" ;
1125+ info = " Net : AI" ;
11001126 }
11011127 DrawPanelText (hSpecHud , info );
11021128
11031129 // Draw fire status
11041130 if (! isIncapacitated && GetEntityFlags (tank ) & FL_ONFIRE )
11051131 {
11061132 int timeleft = RoundToCeil (healthPercent / 100.0 * fTankBurnDuration );
1107- FormatEx (info , sizeof (info ), " On Fire : %i s" , timeleft );
1133+ FormatEx (info , sizeof (info ), " Fire: %i s" , timeleft );
11081134 DrawPanelText (hSpecHud , info );
11091135 }
11101136
@@ -1189,7 +1215,7 @@ void FillGameInfo(Panel hSpecHud)
11891215 int tankClient = GetTankSelection ();
11901216 if (tankClient > 0 && IsClientInGame (tankClient ))
11911217 {
1192- FormatEx (info , sizeof (info ), " Tank -> %N " , tankClient );
1218+ FormatEx (info , sizeof (info ), " Tank: %N " , tankClient );
11931219 DrawPanelText (hSpecHud , info );
11941220 }
11951221 }
@@ -1260,10 +1286,10 @@ stock void GetClientFixedName(int client, char[] name, int length)
12601286
12611287 ValvePanel_ShiftInvalidString (name , length );
12621288
1263- if (strlen (name ) > 18 )
1289+ if (strlen (name ) > 12 )
12641290 {
1265- name [15 ] = name [16 ] = name [17 ] = ' .' ;
1266- name [18 ] = 0 ;
1291+ name [9 ] = name [10 ] = name [11 ] = ' .' ;
1292+ name [12 ] = ' \0 ' ;
12671293 }
12681294}
12691295
0 commit comments