@@ -4,8 +4,6 @@ global function playerPingPreCache
4
4
struct{
5
5
// Settings below to change the appearance of the display
6
6
float size = 20 // UI element Size, basically it's bounding box kinda I think
7
- float verticalPos = 0.00 // Vertical Postion on-screen. 0.00 is max up, 1.00 is max down, default 0.00
8
- float horizPos = 0.68 // Horizontal position on-screen. 0.00 is max left, 1.00 is max right, default 0.68
9
7
vector color = Vector (1.0 , 1.0 , 1.0 ) // color of on-screen display, standard rgb values. Supported Range 0.00 to 1.00. For easy conversion of standard rgb values that look like 255,255,255 (white) lookup a rgb value to percentage converter. 1.00 would be considered 100% 0.50 for 50%, etc..
10
8
float alpha = 0.6 // this is the opacity of the on-screen display, 1.00 is solid, 0.00 would be completely see through and such will be invisible.
11
9
float textSize = 19 // value for font size, 19 is default
@@ -25,6 +23,18 @@ var playerName = null
25
23
var playerKD = null
26
24
var background = null
27
25
26
+ var friendlyHeader = null
27
+ var friendlyTeamMates = null
28
+ var friendlyKD = null
29
+ var friendlyPing = null
30
+
31
+ var enemyHeader = null
32
+ var enemyTeam = null
33
+ var enemyKD = null
34
+ var enemyPing = null
35
+ float shifter = 0
36
+ float horzShifter = 0
37
+
28
38
void function playerPingPreCache (){
29
39
thread menusTread ()
30
40
}
@@ -47,129 +57,204 @@ void function displayPings(){
47
57
RegisterButtonPressedCallback (KEY_F1, displayOn)
48
58
}
49
59
50
-
51
60
void function displayOn (var button){
52
61
entity player = GetLocalClientPlayer ()
53
62
script. show = ! script. show
54
63
if (! script. show ){
55
- RuiDestroyIfAlive (playerPing)
56
- RuiDestroyIfAlive (playerName)
57
- RuiDestroyIfAlive (playerKD)
64
+ RuiDestroyIfAlive (friendlyHeader)
65
+ RuiDestroyIfAlive (friendlyTeamMates)
66
+ RuiDestroyIfAlive (friendlyKD)
67
+ RuiDestroyIfAlive (friendlyPing)
68
+ RuiDestroyIfAlive (enemyHeader)
69
+ RuiDestroyIfAlive (enemyTeam)
70
+ RuiDestroyIfAlive (enemyKD)
71
+ RuiDestroyIfAlive (enemyPing)
58
72
if (settings. addBackground ){
59
73
if (background != null ){
60
74
RuiDestroyIfAlive (background)
61
75
}
62
76
}
63
77
}
64
78
if (script. show ){
65
- thread playerNameDisplay ()
79
+ thread friendlyTeamDisplay ()
80
+ thread enemyTeamDisplay ()
66
81
if (settings. addBackground ){
67
82
thread backgroundCreate ()
68
83
}
69
84
EmitSoundOnEntity (player, " menu_click" )
85
+ thread playerPingBrain ()
70
86
}
71
87
}
72
88
73
89
void function backgroundCreate (){
74
- background = RuiCreate ($" ui/scoreboard_background.rpak" , clGlobal. topoCockpitHudPermanent , RUI_DRAW_COCKPIT , 10 )
90
+ background = RuiCreate ($" ui/scoreboard_background.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD , 10 )
75
91
}
92
+ struct {
93
+ float vertPos = 0.50
94
+ }overlay
95
+ void function friendlyTeamDisplay (){
96
+ friendlyHeader = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 15 )
97
+ RuiSetInt (friendlyHeader, " lineNum" , 1 )
98
+ RuiSetFloat2 (friendlyHeader, " msgPos" , < 0.68 , 0.0 , 0.0 > )
99
+ RuiSetString (friendlyHeader, " msgText" , " Your Team \n ---------------------------------------------------" )
100
+ RuiSetFloat (friendlyHeader, " msgFontSize" , 21 )
101
+ RuiSetFloat (friendlyHeader, " msgAlpha" , settings. alpha )
102
+ RuiSetFloat (friendlyHeader, " thicken" , settings. boldVal )
103
+ RuiSetFloat3 (friendlyHeader, " msgColor" , settings. color )
76
104
77
- void function playerNameDisplay (){
78
- playerName = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoCockpitHudPermanent , RUI_DRAW_COCKPIT, 15 )
79
- RuiSetInt (playerName, " lineNum" , 1 )
80
- RuiSetFloat2 (playerName, " msgPos" , < settings. horizPos , settings. verticalPos , 0.0 > )
81
- RuiSetString (playerName, " msgText" , " Name Display" )
82
- RuiSetFloat (playerName, " msgFontSize" , settings. textSize )
83
- RuiSetFloat (playerName, " msgAlpha" , settings. alpha )
84
- RuiSetFloat (playerName, " thicken" , settings. boldVal )
85
- RuiSetFloat3 (playerName, " msgColor" , settings. color )
86
-
87
- thread playerKDs ()
88
- }
105
+ friendlyTeamMates = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 15 )
106
+ RuiSetInt (friendlyTeamMates, " lineNum" , 1 )
107
+ RuiSetFloat2 (friendlyTeamMates, " msgPos" , < 0.68 , 0.04 , 0.0 > )
108
+ RuiSetString (friendlyTeamMates, " msgText" , " Name Display" )
109
+ RuiSetFloat (friendlyTeamMates, " msgFontSize" , settings. textSize )
110
+ RuiSetFloat (friendlyTeamMates, " msgAlpha" , settings. alpha )
111
+ RuiSetFloat (friendlyTeamMates, " thicken" , settings. boldVal )
112
+ RuiSetFloat3 (friendlyTeamMates, " msgColor" , settings. color )
89
113
90
- void function playerKDs (){
91
- playerKD = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoCockpitHudPermanent , RUI_DRAW_COCKPIT, 15 )
92
- RuiSetInt (playerKD, " lineNum" , 1 )
93
- RuiSetFloat2 (playerKD, " msgPos" , < settings. horizPos , settings. verticalPos , 0.0 > )
94
- RuiSetString (playerKD, " msgText" , " KD Display" )
95
- RuiSetFloat (playerKD, " msgFontSize" , settings. textSize )
96
- RuiSetFloat (playerKD, " msgAlpha" , settings. alpha )
97
- RuiSetFloat (playerKD, " thicken" , settings. boldVal )
98
- RuiSetFloat3 (playerKD, " msgColor" , settings. color )
99
-
100
- thread playerPingDisplay ()
114
+ friendlyKD = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 15 )
115
+ RuiSetInt (friendlyKD, " lineNum" , 1 )
116
+ RuiSetFloat2 (friendlyKD, " msgPos" , < 0.83 , 0.04 , 0.0 > )
117
+ RuiSetString (friendlyKD, " msgText" , " fKD Display" )
118
+ RuiSetFloat (friendlyKD, " msgFontSize" , settings. textSize )
119
+ RuiSetFloat (friendlyKD, " msgAlpha" , settings. alpha )
120
+ RuiSetFloat (friendlyKD, " thicken" , settings. boldVal )
121
+ RuiSetFloat3 (friendlyKD, " msgColor" , settings. color )
122
+
123
+ friendlyPing = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 15 )
124
+ RuiSetInt (friendlyPing, " lineNum" , 1 )
125
+ RuiSetFloat2 (friendlyPing, " msgPos" , < 0.93 , 0.04 , 0.0 > )
126
+ RuiSetString (friendlyPing, " msgText" , " fPing Display" )
127
+ RuiSetFloat (friendlyPing, " msgFontSize" , settings. textSize )
128
+ RuiSetFloat (friendlyPing, " msgAlpha" , settings. alpha )
129
+ RuiSetFloat (friendlyPing, " thicken" , settings. boldVal )
130
+ RuiSetFloat3 (friendlyPing, " msgColor" , settings. color )
101
131
}
102
- void function playerPingDisplay (){
103
- playerPing = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoCockpitHudPermanent , RUI_DRAW_COCKPIT, 15 )
104
- RuiSetInt (playerPing, " lineNum" , 1 )
105
- RuiSetFloat2 (playerPing, " msgPos" , < settings. horizPos , settings. verticalPos , 0.0 > )
106
- RuiSetString (playerPing, " msgText" , " Ping Display" )
107
- RuiSetFloat (playerPing, " msgFontSize" , settings. textSize )
108
- RuiSetFloat (playerPing, " msgAlpha" , settings. alpha )
109
- RuiSetFloat (playerPing, " thicken" , settings. boldVal )
110
- RuiSetFloat3 (playerPing, " msgColor" , settings. color )
111
- thread playerPingBrain ()
132
+ void function enemyTeamDisplay (){
133
+ shifter = 0
134
+ enemyHeader = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 15 )
135
+ RuiSetInt (enemyHeader, " lineNum" , 1 )
136
+ RuiSetFloat2 (enemyHeader, " msgPos" , < 0.68 , overlay. vertPos , 0.0 > )
137
+ RuiSetString (enemyHeader, " msgText" , " Enemy Team \n --------------------------------------------------------" )
138
+ RuiSetFloat (enemyHeader, " msgFontSize" , settings. textSize )
139
+ RuiSetFloat (enemyHeader, " msgAlpha" , settings. alpha )
140
+ RuiSetFloat (enemyHeader, " thicken" , settings. boldVal )
141
+ RuiSetFloat3 (enemyHeader, " msgColor" , settings. color )
142
+
143
+ shifter = overlay. vertPos + 0.04
144
+
145
+ enemyTeam = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 20 )
146
+ RuiSetInt (enemyTeam, " lineNum" , 1 )
147
+ RuiSetFloat2 (enemyTeam, " msgPos" , < 0.68 , shifter, 0.0 > )
148
+ RuiSetString (enemyTeam, " msgText" , " eName Display" )
149
+ RuiSetFloat (enemyTeam, " msgFontSize" , settings. textSize )
150
+ RuiSetFloat (enemyTeam, " msgAlpha" , settings. alpha )
151
+ RuiSetFloat (enemyTeam, " thicken" , settings. boldVal )
152
+ RuiSetFloat3 (enemyTeam, " msgColor" , settings. color )
153
+
154
+ enemyKD = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 20 )
155
+ RuiSetInt (enemyKD, " lineNum" , 1 )
156
+ RuiSetFloat2 (enemyKD, " msgPos" , < 0.83 , shifter, 0.0 > )
157
+ RuiSetString (enemyKD, " msgText" , " Name Display" )
158
+ RuiSetFloat (enemyKD, " msgFontSize" , settings. textSize )
159
+ RuiSetFloat (enemyKD, " msgAlpha" , settings. alpha )
160
+ RuiSetFloat (enemyKD, " thicken" , settings. boldVal )
161
+ RuiSetFloat3 (enemyKD, " msgColor" , settings. color )
162
+
163
+ enemyPing = RuiCreate ($" ui/cockpit_console_text_top_left.rpak" , clGlobal. topoFullScreen , RUI_DRAW_HUD, 20 )
164
+ RuiSetInt (enemyPing, " lineNum" , 1 )
165
+ RuiSetFloat2 (enemyPing, " msgPos" , < 0.93 , shifter, 0.0 > )
166
+ RuiSetString (enemyPing, " msgText" , " Name Display" )
167
+ RuiSetFloat (enemyPing, " msgFontSize" , settings. textSize )
168
+ RuiSetFloat (enemyPing, " msgAlpha" , settings. alpha )
169
+ RuiSetFloat (enemyPing, " thicken" , settings. boldVal )
170
+ RuiSetFloat3 (enemyPing, " msgColor" , settings. color )
171
+
112
172
}
113
173
174
+ // Updates the leaderboard overlay
114
175
void function playerPingBrain (){
115
- string nameString = " "
116
- string kdString = " "
117
- string pingString = " "
118
- entity localplayer = GetLocalClientPlayer ()
119
- string localname = localplayer. GetPlayerName ()
120
- int nameLength = 0
176
+ var clientTeam = GetLocalClientPlayer (). GetTeam ()
177
+ string friendlyNameString = " "
178
+ string friendlyKdString = " "
179
+ string friendlyPingString = " "
121
180
122
- float kdPos = 0
123
- float pingPos = 0
181
+ string enemyNameString = " "
182
+ string enemyKdString = " "
183
+ string enemyPingString = " "
184
+ overlay. vertPos = 0.50
124
185
186
+ // For setting (You) to the correct player
187
+ entity localplayer = GetLocalClientPlayer ()
188
+ string localname = localplayer. GetPlayerName ()
189
+ string sep = " --------------------------------------------------------\n "
190
+ // Avoids script attempting to set Ruis if destroyed.
125
191
while (script. show ){
126
192
if (! IsLobby () && ! IsMenuLevel ()){
127
193
WaitFrame ()
128
- foreach (entity player in GetPlayerArray ()){
129
- string userName = " "
130
- if (player. GetPlayerName () == localname){
131
- userName = " (You)" + player. GetPlayerName ()
132
- }
133
- else {
134
- userName = player. GetPlayerName ()
135
- }
136
- int playerPing = player. GetPlayerGameStat ( PGS_PING )
137
- int playerKills = player. GetPlayerGameStat ( PGS_KILLS )
138
- int playerDeaths = player. GetPlayerGameStat ( PGS_DEATHS )
139
- string sep = " -----------------------------------------------------------------\n "
140
-
141
- string converter = " 0." + nameLength. tostring ()
142
- float converter2 = converter. tofloat ()
143
-
144
- kdPos = settings. horizPos + 0.15
145
- // settings.horizPos + (converter2 - 15)
146
- pingPos = kdPos + 0.10
147
- // kdPos + 0.08
148
-
149
- nameString = nameString + " | " + userName + " \n " + sep
150
- kdString = kdString + " K/D: " + playerKills + " /" + playerDeaths + " \n\n "
151
- pingString = pingString + " Ping: " + playerPing + " ms\n\n "
152
-
153
- }
154
- if (script. show ){
155
- RuiSetString (playerName, " msgText" , nameString)
156
- RuiSetString (playerKD, " msgText" , kdString)
157
- RuiSetString (playerPing, " msgText" , pingString)
158
-
159
-
160
-
161
- RuiSetFloat2 (playerKD, " msgPos" , < kdPos, settings. verticalPos , 0.0 > )
162
- RuiSetFloat2 (playerPing, " msgPos" , < pingPos, settings. verticalPos , 0.0 > )
163
-
164
- nameString = " "
165
- kdString = " "
166
- pingString = " "
194
+ // Gathering player's game info
195
+ int counter = 0
196
+ foreach (entity player in GetPlayerArray ()){
197
+ string fUserName = " "
198
+ if (player. GetTeam () == clientTeam ){
199
+ if (player. GetPlayerName () == localname){
200
+ fUserName = " (You)" + player. GetPlayerName ()
201
+ }
202
+ else {
203
+ fUserName = player. GetPlayerName ()
204
+ }
205
+ int fPing = player. GetPlayerGameStat ( PGS_PING )
206
+ int fKills = player. GetPlayerGameStat ( PGS_KILLS )
207
+ int fDeaths = player. GetPlayerGameStat ( PGS_DEATHS )
167
208
168
-
209
+ counter ++
210
+ if (counter < 2 ){
211
+ overlay. vertPos = 0.15
212
+ }
213
+ if (counter > 2 ){
214
+ overlay. vertPos = 0.50
215
+ }
216
+ if (counter > 15 ){
217
+ overlay. vertPos = 0.70
218
+ }
219
+
169
220
221
+ friendlyNameString = friendlyNameString + " |" + fUserName + " \n\n " // + sep
222
+ friendlyKdString = friendlyKdString + " K/D: " + fKills + " /" + fDeaths + " \n\n "
223
+ friendlyPingString = friendlyPingString + fPing + " ms\n\n "
224
+ }
225
+ string eUserName = " "
226
+ if (player. GetTeam () != clientTeam){
227
+ int ePing = player. GetPlayerGameStat ( PGS_PING )
228
+ int eKills = player. GetPlayerGameStat ( PGS_KILLS )
229
+ int eDeaths = player. GetPlayerGameStat ( PGS_DEATHS )
230
+ eUserName = player. GetPlayerName ()
231
+
170
232
233
+ enemyNameString = enemyNameString + " |" + eUserName + " \n\n " // + sep
234
+ enemyKdString = enemyKdString + " K/D: " + eKills + " /" + eDeaths + " \n\n "
235
+ enemyPingString = enemyPingString + ePing + " ms\n\n "
171
236
}
172
237
173
- }
238
+ }
239
+ if (script. show ){
240
+ RuiSetString (friendlyTeamMates, " msgText" , friendlyNameString)
241
+ RuiSetString (friendlyKD, " msgText" , friendlyKdString)
242
+ RuiSetString (friendlyPing, " msgText" , friendlyPingString)
243
+
244
+ RuiSetString (enemyTeam, " msgText" , enemyNameString)
245
+ RuiSetString (enemyKD, " msgText" , enemyKdString)
246
+ RuiSetString (enemyPing, " msgText" , enemyPingString)
247
+
248
+ }
249
+ friendlyNameString = " "
250
+ friendlyKdString = " "
251
+ friendlyPingString = " "
252
+ counter = 0
253
+ enemyNameString = " "
254
+ enemyKdString = " "
255
+ enemyPingString = " "
256
+ }
174
257
}
175
258
}
259
+
260
+
0 commit comments