display_player_stats 1.1

Fix threading on bots
Fix stats only changing when player did a kill
Refactor
Add image
This commit is contained in:
Resxt 2022-03-10 14:31:54 +01:00
parent bd4bdc06f4
commit 7a9b271e1f
3 changed files with 15 additions and 13 deletions

View File

@ -5,6 +5,11 @@ Simple drag and drop scripts
## display_player_stats.gsc ## display_player_stats.gsc
Display the player's killstreak, total kills and deaths on top of the screen Display the player's killstreak, total kills and deaths on top of the screen
<details>
<summary>Image</summary>
![image](images/display_player_stats.png)
</details>
## change_team_names.gsc ## change_team_names.gsc

View File

@ -1,7 +1,6 @@
#include maps\mp\gametypes\_hud_util; #include maps\mp\gametypes\_hud_util;
Init()
init()
{ {
level thread OnPlayerConnected(); level thread OnPlayerConnected();
} }
@ -12,9 +11,10 @@ OnPlayerConnected()
{ {
level waittill("connected", player); level waittill("connected", player);
if (isDefined(self.pers["isBot"])) // Don't thread DisplayPlayerKillstreak() on bots
if (isDefined(player.pers["isBot"]))
{ {
if (self.pers["isBot"]) if (player.pers["isBot"])
{ {
return; return;
} }
@ -30,16 +30,13 @@ DisplayPlayerKillstreak()
self endon ("disconnect"); self endon ("disconnect");
level endon("game_ended"); level endon("game_ended");
self.hudkillstreak = createFontString( "Objective", 0.65 ); self.stats_text = createFontString( "Objective", 0.65 );
self.hudkillstreak setPoint( "CENTER", "TOP", "CENTER", 10 ); self.stats_text setPoint( "CENTER", "TOP", "CENTER", 7.5 );
while(true) while(true)
{
if(self.playerstreak != self.pers["cur_kill_streak"])
{ {
self.playerstreak = self.pers["cur_kill_streak"]; self.playerstreak = self.pers["cur_kill_streak"];
self.hudkillstreak setText("^1KILLSTREAK: " + self.pers["cur_kill_streak"] + " | KILLS: " + self.pers["kills"] + " | DEATHS: " + self.pers["deaths"]); self.stats_text setText("^1KILLSTREAK: " + self.pers["cur_kill_streak"] + " | KILLS: " + self.pers["kills"] + " | DEATHS: " + self.pers["deaths"]);
}
wait 0.01; wait 0.01;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 MiB