Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. MW3 Modding Releases & Resources
  3. HUD killstreak Player

HUD killstreak Player

Scheduled Pinned Locked Moved MW3 Modding Releases & Resources
11 Posts 7 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sorexundefined Offline
    Sorexundefined Offline
    Sorex
    Contributor
    wrote on last edited by Sorex
    #2

    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"));
    	}
    }
    
    birchyundefined 1 Reply Last reply
    1
    • Sorexundefined Sorex

      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"));
      	}
      }
      
      birchyundefined Offline
      birchyundefined Offline
      birchy
      wrote on last edited by
      #3

      Sorex you'd want to wait for player spawn also, so the value is updated if they die or switch teams

      1 Reply Last reply
      0
      • Sorexundefined Offline
        Sorexundefined Offline
        Sorex
        Contributor
        wrote on last edited by
        #4

        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

        birchyundefined 1 Reply Last reply
        0
        • Sorexundefined Sorex

          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

          birchyundefined Offline
          birchyundefined Offline
          birchy
          wrote on last edited by
          #5

          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

          1 Reply Last reply
          0
          • mrpsychoundefined Offline
            mrpsychoundefined Offline
            mrpsycho
            wrote on last edited by
            #6

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

            1 Reply Last reply
            1
            • Sorexundefined Offline
              Sorexundefined Offline
              Sorex
              Contributor
              wrote on last edited by
              #7

              Thanks for the info, good to know 🙂

              1 Reply Last reply
              0
              • Kalitosundefined Kalitos

                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

                alejandrodarzundefined Offline
                alejandrodarzundefined Offline
                alejandrodarz
                wrote on last edited by
                #8

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

                1 Reply Last reply
                0
                • Resxtundefined Offline
                  Resxtundefined Offline
                  Resxt
                  Plutonium Staff
                  wrote on last edited by Resxt
                  #9

                  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)

                  EternalHabitundefined 1 Reply Last reply
                  2
                  • Resxtundefined Resxt

                    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)

                    EternalHabitundefined Offline
                    EternalHabitundefined Offline
                    EternalHabit
                    wrote on last edited by EternalHabit
                    #10
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • EternalHabitundefined Offline
                      EternalHabitundefined Offline
                      EternalHabit
                      wrote on last edited by
                      #11
                      #include maps\mp\gametypes\_hud_util;
                      
                      init()
                      {
                          level thread onPlayerConnect();
                      }
                      
                      onPlayerConnect()
                      {
                          for(;;)
                          {
                              level waittill("connected", player);
                      
                              player thread onPlayerSpawned();
                          }
                      }
                      
                      onPlayerSpawned()
                      {
                      	self endon("disconnect");
                      	level endon("game_ended");
                      
                      	for(;;)
                      	{
                      	     self waittill("spawned_player");
                      
                                   if(!issubstr(self getguid() + "", "bot"))
                                   {
                                       self thread killstreakCounter();
                                       self thread destroyCounterOnGameEnd();
                                   }
                              
                                   break;
                      	}
                      }
                      
                      killstreakCounter()
                      {
                          self endon ("disconnect");
                          level endon("game_ended");
                      
                          self.counter = createFontString("Objective", 1);
                          self.counter setPoint("CENTER", "TOP", 0, 8);
                          self.counter.label = &"^2KILLSTREAK: ^7";
                          self.counter.sort = -3;
                          self.counter.alpha = 0.9;
                          self.counter.hideWhenInMenu = true;
                          self.counter setValue(self.pers["cur_kill_streak"]);
                      
                          playerStreak = 0;
                      
                          for(;;)
                          {
                              if(playerStreak != self.pers["cur_kill_streak"])
                              {
                                  playerStreak = self.pers["cur_kill_streak"];
                                  self.counter setValue(self.pers["cur_kill_streak"]);
                              }
                              wait 0.25;
                          }
                      }
                      
                      destroyCounterOnGameEnd()
                      {
                      	self endon("disconnect");
                      
                      	level waittill("game_ended");
                      
                          if(isDefined(self.counter))
                      	    self.counter hudFadenDestroy(0, .1);
                      }
                      
                      hudFadenDestroy(alpha,time)
                      {
                      	self fadeOverTime(time);
                      	self.alpha = alpha;
                      	wait time;
                              self destroy();
                      }
                      
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Donate