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 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

View File

@ -1,7 +1,6 @@
#include maps\mp\gametypes\_hud_util;
init()
Init()
{
level thread OnPlayerConnected();
}
@ -12,9 +11,10 @@ OnPlayerConnected()
{
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;
}
@ -22,7 +22,7 @@ OnPlayerConnected()
player thread DisplayPlayerKillstreak();
}
}
}
DisplayPlayerKillstreak()
@ -30,17 +30,14 @@ DisplayPlayerKillstreak()
self endon ("disconnect");
level endon("game_ended");
self.hudkillstreak = createFontString( "Objective", 0.65 );
self.hudkillstreak setPoint( "CENTER", "TOP", "CENTER", 10 );
self.stats_text = createFontString( "Objective", 0.65 );
self.stats_text setPoint( "CENTER", "TOP", "CENTER", 7.5 );
while(true)
{
if(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.playerstreak = self.pers["cur_kill_streak"];
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