HUD killstreak Player

Topic created ยท 8 Posts ยท 443 Views
  • I have been looking for this for a long time and I think I could do it, so I share with you I know that I am not the only one who needed it.
    I have relied on coding found in this same forum and the guides given.

    Credits: https://forum.plutonium.pw/topic/2113/storing-players-data-with-chaiscript/3

    :: CODE UPDATE :: 23-05-2021 ::
    Now correctly registers the kills that the player gets when he has a hard line pro and gets 2 assists counting as kill

    /*
    *	 Black Ops 2 - GSC Studio by iMCSx
    *
    *	 Creator : Kalitos
    *	 Project : killstreakHUD
    *    Mode : Multiplayer
    *	 Date : 2021/05/15 - 11:22:19	
    *
    */	
    
    #include maps\mp\gametypes\_hud_util;
    
    
    init()
    {
        level thread onPlayerConnect();
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);        
            player thread killstreakPlayer();      
        }
    }	
    
    
    killstreakPlayer ()
    {
    	self endon ("disconnect");
    	level endon("game_ended");
    	self.hudkillstreak = createFontString ("Objective", 1);
    	self.hudkillstreak setPoint ("CENTER", "TOP", "CENTER", 10);
    	self.hudkillstreak.label = &"^2 KILLSTREAK: ^7";
    	
    	while(true)
    	{
    		self.hudkillstreak setValue(self.pers["cur_kill_streak"]);
    		wait 0.5;
    	}
    	
    	
    }
    

    To implement it they must create a .GSC file and paste the code in it, then follow the guide on how to load a scripthere

    HUDkillstreak.png

  • @Kalitos This code can be improved, self.killstreaks in onPlayerConnected does not make any sense. It is also completely useless since it is a value you take from a function. Just use that function and you're done.
    Also, as far as anything goes, if you can avoid non-stop loops, that's better. In this case you just need to see when an enemy is killed to update the value.

    /*
    *	 Black Ops 2 - GSC Studio by iMCSx
    *
    *	 Creator : Kalitos
    *	 Project : killstreakHUD
    *      Mode : Multiplayer
    *	 Date : 2021/05/15 - 11:22:19	
    *
    */	
    
    #include maps\mp\gametypes\_hud_util;
    
    init()
    {
        level thread onPlayerConnect();
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread killstreakPlayer();	
        }
    }
    
    
    
    killstreakPlayer ()
    {
    	self endon ("disconnect");
    	level endon("game_ended");
    	hudkillstreak = createFontString ("Objective", 1);
    	hudkillstreak setPoint ("CENTER", "TOP", "CENTER", 10);
    	hudkillstreak.label = &"^2 KILLSTREAK: ^7";
    	
    	while (true)
    	{
                    self waittill_any("killed_enemy", "spawned_player"); 
    		hudkillstreak setValue(self getPlayerData("killstreaksState","count"));
    	}
    }
    
  • @Sorex you'd want to wait for player spawn also, so the value is updated if they die or switch teams

  • @birchy I do not remeber if killstreaks on iw5 keep going also if player die. idk so if not happen its needed another system to reset the value

  • @Sorex what i'm saying is you only get the new value on player_killed, so the HUD won't be updated if the player switches team or dies

  • @Sorex said in HUD killstreak Player:

    self getPlayerData("killstreaksState","count")

    this will only get killstreak toward killstreaks as in UAV and all that stuff, so if ur highest selected killstreak is let's say a osprey gunner which is a 18 killstreak, once u get to that, this will reset back to 0, so i'd just use self.pers["cur_kill_streak"]

  • Thanks for the info, good to know ๐Ÿ™‚

  • @Kalitos You should do it like this, this way it does not update all the time ๐Ÿ˜‰

    KillstreakPlayer()
    {
    self endon ("disconnect");
    level endon("game_ended");
    self.hudkillstreak = createFontString( "Objective", 1 );
    self.hudkillstreak setPoint( "CENTER", "TOP", "CENTER", 10 );
    self.hudkillstreak.label = &"^2 KILLSTREAK: ^7";
    while(true)
    {
    if(self.playerstreak != self.pers["cur_kill_streak"])
    {
    self.playerstreak = self.pers["cur_kill_streak"];
    self.hudkillstreak setValue(self.pers["cur_kill_streak"]);
    }
    wait 0.01;
    }
    }

Log in to reply