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

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. [Support] On-Screen Player Health Information. GSC Code

[Support] On-Screen Player Health Information. GSC Code

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
19 Posts 10 Posters 2.8k Views 2 Watching
  • 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.
  • Ioofundefined Offline
    Ioofundefined Offline
    Ioof
    Contributor
    wrote on last edited by
    #4

    oh yeah havent tought about that

    1 Reply Last reply
    0
    • Gangorraundefined Offline
      Gangorraundefined Offline
      Gangorra
      wrote on last edited by
      #5

      Why this happens?

      **** 3 script error(s):
      **** Unresolved external : "onplayerspawned" with 0 parameters in "_clientids" at line 1 ****
      **** Unresolved external : "createfontstring" with 2 parameters in "_clientids" at line 1 ****
      **** Unresolved external : "setpoint" with 4 parameters in "_cl

      Kalitosundefined 1 Reply Last reply
      0
      • Gangorraundefined Gangorra

        Why this happens?

        **** 3 script error(s):
        **** Unresolved external : "onplayerspawned" with 0 parameters in "_clientids" at line 1 ****
        **** Unresolved external : "createfontstring" with 2 parameters in "_clientids" at line 1 ****
        **** Unresolved external : "setpoint" with 4 parameters in "_cl

        Kalitosundefined Offline
        Kalitosundefined Offline
        Kalitos
        wrote on last edited by
        #6

        @GangorraAidetica Did you add the include you need to execute the functions you use?

        1 Reply Last reply
        0
        • Gangorraundefined Offline
          Gangorraundefined Offline
          Gangorra
          wrote on last edited by Gangorra
          #7

          I threw in some hud imports and utils, but I believe it's supposed to be zombies specific utils, right?
          (I dont have em now because I was exploring scripts and already changed everything :P)

          Base 115undefined 1 Reply Last reply
          0
          • Ojotaundefined Offline
            Ojotaundefined Offline
            Ojota
            wrote on last edited by
            #8

            Hey dude you got the include for the thing to work?

            1 Reply Last reply
            0
            • Gangorraundefined Gangorra

              I threw in some hud imports and utils, but I believe it's supposed to be zombies specific utils, right?
              (I dont have em now because I was exploring scripts and already changed everything :P)

              Base 115undefined Offline
              Base 115undefined Offline
              Base 115
              wrote on last edited by
              #9

              @GangorraAidetica Hi 👋, did you get it fixed?

              1 Reply Last reply
              0
              • Kalitosundefined Kalitos

                I have been working on a HUD that shows the health of the player in Zombies Mode.
                The code I have so far shows me the health of spawning the player.

                init()
                {
                	level.clientid = 0;
                	level.perk_purchase_limit = 9;
                	level thread onplayerconnect();
                	}
                
                onplayerconnect()
                {
                	for ( ;; )
                	{
                		level waittill( "connecting", player );
                		player thread onplayerspawned();
                		player.clientid = level.clientid;
                		level.clientid++;
                		player thread healthPlayer(); // Here I call my HUD HEALTH function
                		
                	}
                }
                
                onplayerspawned()
                {
                	level endon( "game_ended" );
                        self endon( "disconnect" );
                	for(;;)
                	{
                		self welcome();
                		self addScore();
                		
                	}
                }
                
                healthPlayer()
                {
                	self endon("disconnect");
                	self iPrintln("Entra a healthPlayer");
                	self iprintln( "HEALTH: "+ self.health);
                	self.healthText = createFontString("Objective" , 1.7);
                        self.healthText setPoint("CENTER", "TOP", 300, "CENTER");
                        while(true)
                              {
                               self.healthText setText( "^2HEALTH: ^7"+ self.health);
                               wait 0.5;
                              }
                }
                

                But I have a problem, when another player or more connects, it shows me my health on the screen it also shows the health of the other player or other players on my screen too. The same thing happens to the rest of the players, it shows them their health and the health of the other players is put on top of them.

                Any help on how to fix it, and to show each player the health that corresponds to them and not to show the health of all the players to each one?

                Dempsey_undefined Offline
                Dempsey_undefined Offline
                Dempsey_
                wrote on last edited by
                #10

                Kalitos i don’t understand how can i use this? Im new

                AdrX003undefined 1 Reply Last reply
                0
                • Dempsey_undefined Dempsey_

                  Kalitos i don’t understand how can i use this? Im new

                  AdrX003undefined Offline
                  AdrX003undefined Offline
                  AdrX003
                  wrote on last edited by
                  #11

                  Allmeta Its a file that will mod the game to show something else on the screen, a mod. we usually put them in the correct folder and they do what theyre written to do.

                  Dempsey_undefined 1 Reply Last reply
                  0
                  • AdrX003undefined AdrX003

                    Allmeta Its a file that will mod the game to show something else on the screen, a mod. we usually put them in the correct folder and they do what theyre written to do.

                    Dempsey_undefined Offline
                    Dempsey_undefined Offline
                    Dempsey_
                    wrote on last edited by
                    #12

                    AdrX003 for me it doesnt work do i need the main GSC and this GSC for it to work or what?

                    AdrX003undefined 1 Reply Last reply
                    0
                    • Dempsey_undefined Dempsey_

                      AdrX003 for me it doesnt work do i need the main GSC and this GSC for it to work or what?

                      AdrX003undefined Offline
                      AdrX003undefined Offline
                      AdrX003
                      wrote on last edited by AdrX003
                      #13

                      Allmeta this is not really a thread for users who just wanna use these stuff, but actually to teach new programmers on using the game code, so nothing here is ready to use.

                      Dempsey_undefined 1 Reply Last reply
                      0
                      • AdrX003undefined AdrX003

                        Allmeta this is not really a thread for users who just wanna use these stuff, but actually to teach new programmers on using the game code, so nothing here is ready to use.

                        Dempsey_undefined Offline
                        Dempsey_undefined Offline
                        Dempsey_
                        wrote on last edited by
                        #14

                        AdrX003 ty

                        AdrX003undefined 1 Reply Last reply
                        0
                        • Dempsey_undefined Dempsey_

                          AdrX003 ty

                          AdrX003undefined Offline
                          AdrX003undefined Offline
                          AdrX003
                          wrote on last edited by
                          #15

                          Allmeta In your case you might wanna look for for the "compiled" GSCs wich are converted to a format that the plutonium will read and load into COD. if you need to know if something is compiled to play or not heres an example:
                          "open code" on left and compiled in the right (but usually most posts will contain both and the uploader also tells us wich is wich, etc )
                          74376c60-9b30-4819-8613-aed84b1fed83-image.png

                          1 Reply Last reply
                          0
                          • Kalitosundefined Kalitos

                            I have been working on a HUD that shows the health of the player in Zombies Mode.
                            The code I have so far shows me the health of spawning the player.

                            init()
                            {
                            	level.clientid = 0;
                            	level.perk_purchase_limit = 9;
                            	level thread onplayerconnect();
                            	}
                            
                            onplayerconnect()
                            {
                            	for ( ;; )
                            	{
                            		level waittill( "connecting", player );
                            		player thread onplayerspawned();
                            		player.clientid = level.clientid;
                            		level.clientid++;
                            		player thread healthPlayer(); // Here I call my HUD HEALTH function
                            		
                            	}
                            }
                            
                            onplayerspawned()
                            {
                            	level endon( "game_ended" );
                                    self endon( "disconnect" );
                            	for(;;)
                            	{
                            		self welcome();
                            		self addScore();
                            		
                            	}
                            }
                            
                            healthPlayer()
                            {
                            	self endon("disconnect");
                            	self iPrintln("Entra a healthPlayer");
                            	self iprintln( "HEALTH: "+ self.health);
                            	self.healthText = createFontString("Objective" , 1.7);
                                    self.healthText setPoint("CENTER", "TOP", 300, "CENTER");
                                    while(true)
                                          {
                                           self.healthText setText( "^2HEALTH: ^7"+ self.health);
                                           wait 0.5;
                                          }
                            }
                            

                            But I have a problem, when another player or more connects, it shows me my health on the screen it also shows the health of the other player or other players on my screen too. The same thing happens to the rest of the players, it shows them their health and the health of the other players is put on top of them.

                            Any help on how to fix it, and to show each player the health that corresponds to them and not to show the health of all the players to each one?

                            lampikudoundefined Offline
                            lampikudoundefined Offline
                            lampikudo
                            wrote on last edited by
                            #16
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • Kalitosundefined Kalitos

                              I have been working on a HUD that shows the health of the player in Zombies Mode.
                              The code I have so far shows me the health of spawning the player.

                              init()
                              {
                              	level.clientid = 0;
                              	level.perk_purchase_limit = 9;
                              	level thread onplayerconnect();
                              	}
                              
                              onplayerconnect()
                              {
                              	for ( ;; )
                              	{
                              		level waittill( "connecting", player );
                              		player thread onplayerspawned();
                              		player.clientid = level.clientid;
                              		level.clientid++;
                              		player thread healthPlayer(); // Here I call my HUD HEALTH function
                              		
                              	}
                              }
                              
                              onplayerspawned()
                              {
                              	level endon( "game_ended" );
                                      self endon( "disconnect" );
                              	for(;;)
                              	{
                              		self welcome();
                              		self addScore();
                              		
                              	}
                              }
                              
                              healthPlayer()
                              {
                              	self endon("disconnect");
                              	self iPrintln("Entra a healthPlayer");
                              	self iprintln( "HEALTH: "+ self.health);
                              	self.healthText = createFontString("Objective" , 1.7);
                                      self.healthText setPoint("CENTER", "TOP", 300, "CENTER");
                                      while(true)
                                            {
                                             self.healthText setText( "^2HEALTH: ^7"+ self.health);
                                             wait 0.5;
                                            }
                              }
                              

                              But I have a problem, when another player or more connects, it shows me my health on the screen it also shows the health of the other player or other players on my screen too. The same thing happens to the rest of the players, it shows them their health and the health of the other players is put on top of them.

                              Any help on how to fix it, and to show each player the health that corresponds to them and not to show the health of all the players to each one?

                              Mr_Miksundefined Offline
                              Mr_Miksundefined Offline
                              Mr_Miks
                              wrote on last edited by
                              #17

                              Kalitos Hi, I know it's an old and probably solved topic, but in my case I was moding for BO1 zombies and found the same problem with a code very much like yours.

                              But this:

                              createFontString("Objective" , 1.7);
                              

                              Doesn't work for me (·__·) ...

                              My work around, tested for BO1 zombies (T6):

                              on_player_spawned()
                              {
                              	self endon("disconnect");
                              	self endon("death");
                              	
                              	while( true )
                              	{
                              		self waittill("spawned_player");
                              		
                              		
                              		if( !isdefined(self.myHealthTextHud) )
                              		{
                              			self.myHealthTextHud = newclientHudElem( self );	
                              		}
                              		
                              
                              		self.myHealthTextHud.alignX = "center";
                              		self.myHealthTextHud.alignY = "middle";
                              		self.myHealthTextHud.horzAlign = "center";
                              		self.myHealthTextHud.vertAlign = "bottom";
                              		self.myHealthTextHud.y = -20;
                              		self.myHealthTextHud.x = 0;
                              
                              		self.myHealthTextHud.foreground = true;
                              		self.myHealthTextHud.font = "default";
                              		self.myHealthTextHud.fontScale = 1.8;
                              		self.myHealthTextHud.alpha = 1;
                              		self.myHealthTextHud.color = ( 1.0, 0.0, 0.0 );
                              		self.myHealthTextHud setText( "HEALTH: "+self.health );
                              		
                              		self thread printHealth();
                              	}
                              }
                              
                              printHealth()
                              {
                              	self endon( "death" );
                              	self endon( "disconnect" );
                              
                              	while( true )
                              	{
                              		wait(1.5);
                              		self.myHealthTextHud setText( "HEALTH :"+self.health );
                              
                              	}
                              }
                              
                              
                              JezuzLizardundefined 1 Reply Last reply
                              0
                              • Mr_Miksundefined Mr_Miks

                                Kalitos Hi, I know it's an old and probably solved topic, but in my case I was moding for BO1 zombies and found the same problem with a code very much like yours.

                                But this:

                                createFontString("Objective" , 1.7);
                                

                                Doesn't work for me (·__·) ...

                                My work around, tested for BO1 zombies (T6):

                                on_player_spawned()
                                {
                                	self endon("disconnect");
                                	self endon("death");
                                	
                                	while( true )
                                	{
                                		self waittill("spawned_player");
                                		
                                		
                                		if( !isdefined(self.myHealthTextHud) )
                                		{
                                			self.myHealthTextHud = newclientHudElem( self );	
                                		}
                                		
                                
                                		self.myHealthTextHud.alignX = "center";
                                		self.myHealthTextHud.alignY = "middle";
                                		self.myHealthTextHud.horzAlign = "center";
                                		self.myHealthTextHud.vertAlign = "bottom";
                                		self.myHealthTextHud.y = -20;
                                		self.myHealthTextHud.x = 0;
                                
                                		self.myHealthTextHud.foreground = true;
                                		self.myHealthTextHud.font = "default";
                                		self.myHealthTextHud.fontScale = 1.8;
                                		self.myHealthTextHud.alpha = 1;
                                		self.myHealthTextHud.color = ( 1.0, 0.0, 0.0 );
                                		self.myHealthTextHud setText( "HEALTH: "+self.health );
                                		
                                		self thread printHealth();
                                	}
                                }
                                
                                printHealth()
                                {
                                	self endon( "death" );
                                	self endon( "disconnect" );
                                
                                	while( true )
                                	{
                                		wait(1.5);
                                		self.myHealthTextHud setText( "HEALTH :"+self.health );
                                
                                	}
                                }
                                
                                
                                JezuzLizardundefined Offline
                                JezuzLizardundefined Offline
                                JezuzLizard
                                Plutonium Staff
                                wrote on last edited by
                                #18

                                Mr_Miks I wouldn't recommend using setText() without an overflow fix because it eventually causes configstrings to overflow and error the game. Instead you should use .label for a static string, and setValue() for the health updating. Also "death" doesn't trigger in zombies so what will happen after running this code long enough you'll run out of script variables if players respawn. You would need to use "bled_out" instead.

                                Mr_Miksundefined 1 Reply Last reply
                                1
                                • JezuzLizardundefined JezuzLizard

                                  Mr_Miks I wouldn't recommend using setText() without an overflow fix because it eventually causes configstrings to overflow and error the game. Instead you should use .label for a static string, and setValue() for the health updating. Also "death" doesn't trigger in zombies so what will happen after running this code long enough you'll run out of script variables if players respawn. You would need to use "bled_out" instead.

                                  Mr_Miksundefined Offline
                                  Mr_Miksundefined Offline
                                  Mr_Miks
                                  wrote on last edited by
                                  #19

                                  JezuzLizard Thanks alot for the feedback! I really appreciate it!

                                  For those interested:

                                  Initialization:

                                  on_player_spawned()
                                  {
                                  	self endon("disconnect");
                                  	self endon("bled_out");
                                  
                                  	while( true )
                                  	{
                                  		self waittill("spawned_player");
                                  		
                                  		
                                  		if( !isdefined(self.myHealthTextHud) )
                                  		{
                                  			x = 0;
                                  			y = -20;
                                  			value = self.health;
                                  			self.myHealthTextHud = create_health_hud( x, y, value );	
                                  			// self.myHealthTextHud = newclientHudElem( self );	
                                  		}
                                  		
                                  		self thread printHealth();
                                  	}
                                  }
                                  

                                  Update loop:

                                  printHealth()
                                  {
                                  	self endon( "bled_out" );
                                  	self endon( "disconnect" );
                                  
                                  	while( true )
                                  	{
                                  		wait(1.5);
                                  		self.myHealthTextHud SetValue( self.health );
                                  
                                  	}
                                  }
                                  

                                  And HUD creation:

                                  // This is a modified version of:
                                  //common_zombie\maps\_zombiemode_score.gsc:584:	hud = self create_highlight_hud( x, y, value ); 
                                  create_health_hud( x, y, value )
                                  {
                                  	font_size = 1.8; 
                                  
                                  	hud = create_simple_hud( self ); //common_zombie_patch\maps\_zombiemode_utility.gsc:111
                                  	
                                  	level.hudelem_count++; 
                                  
                                  	hud.foreground = true; 
                                  	hud.sort = 0.5; 
                                  	hud.x = x; 
                                  	hud.y = y; 
                                  	hud.fontScale = font_size; 
                                  	
                                  	hud.alignX = "center"; 
                                  	hud.alignY = "middle"; 
                                  	hud.horzAlign = "center";
                                  	hud.vertAlign = "bottom";
                                  
                                  	hud.color = ( 0.9, 0.9, 0.0 );
                                  	
                                  	hud.alpha = 1;
                                  	hud.color = ( 1.0, 0.0, 0.0 );
                                  
                                  	//	hud.glowColor = ( 0.3, 0.6, 0.3 );
                                  	//	hud.glowAlpha = 1; 
                                  	
                                  	hud.hidewheninmenu = true; 
                                  	hud.hidewheninmenu = false; 
                                  	
                                  	hud.label = "HEALTH: ";
                                  
                                  	hud SetValue( value ); 
                                  
                                  	return hud; 	
                                  }
                                  
                                  1 Reply Last reply
                                  1
                                  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