|
| 1 | +global function playerPingPreCache |
| 2 | + |
| 3 | +//CHANGE SETTINGS HERE |
| 4 | +struct{ |
| 5 | + // Settings below to change the appearance of the display |
| 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 | + 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 | + 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 | + float textSize = 19 // value for font size, 19 is default |
| 12 | + float boldVal = 0.0 // How thick or bold the text appears, default: 0.0 |
| 13 | + bool addBackground = true // toggle for adding background, it's a little scuffed atm but improves readability |
| 14 | +} settings |
| 15 | + |
| 16 | + |
| 17 | +//No touchy tho feel free to use anything you find useful |
| 18 | +struct{ |
| 19 | + bool show = false |
| 20 | + bool adjusted = false |
| 21 | +}script |
| 22 | + |
| 23 | +var playerPing = null |
| 24 | +var playerName = null |
| 25 | +var playerKD = null |
| 26 | +var background = null |
| 27 | + |
| 28 | +void function playerPingPreCache(){ |
| 29 | + thread menusTread() |
| 30 | +} |
| 31 | + |
| 32 | +void function menusTread(){ |
| 33 | + WaitFrame() |
| 34 | + int noConsoleSpam = 0 |
| 35 | + while(IsLobby() && IsMenuLevel()){ |
| 36 | + if(noConsoleSpam <= 0 ){ |
| 37 | + print("<##############>Ping Display is waiting for a game<##############>") |
| 38 | + noConsoleSpam = 2 |
| 39 | + } |
| 40 | + else |
| 41 | + WaitForever() |
| 42 | + } |
| 43 | + thread displayPings() |
| 44 | +} |
| 45 | + |
| 46 | +void function displayPings(){ |
| 47 | + RegisterButtonPressedCallback(KEY_F1, displayOn) |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +void function displayOn(var button){ |
| 52 | + entity player = GetLocalClientPlayer() |
| 53 | + script.show = !script.show |
| 54 | + if(!script.show){ |
| 55 | + RuiDestroyIfAlive(playerPing) |
| 56 | + RuiDestroyIfAlive(playerName) |
| 57 | + RuiDestroyIfAlive(playerKD) |
| 58 | + if(settings.addBackground){ |
| 59 | + if(background != null){ |
| 60 | + RuiDestroyIfAlive(background) |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + if(script.show){ |
| 65 | + thread playerNameDisplay() |
| 66 | + if(settings.addBackground){ |
| 67 | + thread backgroundCreate() |
| 68 | + } |
| 69 | + EmitSoundOnEntity(player, "menu_click") |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +void function backgroundCreate(){ |
| 74 | + background = RuiCreate($"ui/scoreboard_background.rpak", clGlobal.topoCockpitHudPermanent, RUI_DRAW_COCKPIT, 10) |
| 75 | +} |
| 76 | + |
| 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 | +} |
| 89 | + |
| 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() |
| 101 | +} |
| 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() |
| 112 | +} |
| 113 | + |
| 114 | +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 |
| 121 | + |
| 122 | + float kdPos = 0 |
| 123 | + float pingPos = 0 |
| 124 | + |
| 125 | + while(script.show){ |
| 126 | + if(!IsLobby() && !IsMenuLevel()){ |
| 127 | + 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 = "" |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + } |
| 172 | + |
| 173 | + } |
| 174 | + } |
| 175 | +} |
0 commit comments