I fixed the warnings in the console, I included the explanations at the bottom for those who are curious about it.
I also made it not unnecessarily thread on bots, just a small performance "fix"
Kalitos Maybe this will interest you or maybe you wanna update your script on the OP
#include maps\mp\gametypes\_hud_util;
Init()
{
level thread OnPlayerConnected();
}
OnPlayerConnected()
{
for(;;)
{
level waittill("connected", player);
// Don't thread DisplayPlayerKillstreak() on bots
if (isDefined(player.pers["isBot"]))
{
if (player.pers["isBot"])
{
continue; // skip
}
}
player thread DisplayPlayerKillstreak();
}
}
DisplayPlayerKillstreak()
{
self endon ("disconnect");
level endon("game_ended");
self.killstreak_text = createFontString( "Objective", 0.65 );
self.killstreak_text setPoint( 0, "TOP", 0, 7.5 );
self.killstreak_text.label = &"^1KILLSTREAK: ";
while(true)
{
if(!IsDefined(self.playerstreak) || self.playerstreak != self.pers["cur_kill_streak"])
{
self.playerstreak = self.pers["cur_kill_streak"];
self.killstreak_text setValue(self.pers["cur_kill_streak"]);
}
wait 0.01;
}
}
a4ceda64-034c-4d0e-9cdf-4e19d642f79b-image.png
For some reason the game seems to throw a warning when you pass "CENTER" in the setPoint function so I replaced it with 0.
f351ea10-85f0-4ed5-a7e3-411d0d042070-image.png
This was happening because when doing this
if(self.playerstreak != self.pers["cur_kill_streak"])
{
self.playerstreak = self.pers["cur_kill_streak"];
self.killstreak_text setValue(self.pers["cur_kill_streak"]);
}
the first time the playerstreak variable isn't defined yet because it's a variable created by the script in that if condition.
So to make sure the script works normally I added another case !IsDefined(self.playerstreak) || so that it will work both when our HUD needs to be updated and also when our variable isn't defined yet (first iteration)
b0c22f71-7c72-41a4-8826-e48601349c21-image.png
Same than above, when comparing undefined to a variable the result isn't true or false but undefined (to my understanding)