Obsidian Conflict Forums

Have you seen my coffee cup?
It is currently Fri Oct 20, 2017 9:52 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: C++ Suit power bar
PostPosted: Sat Jul 04, 2009 4:40 pm 
Offline
prop_static
prop_static
User avatar

Joined: Fri Jun 26, 2009 7:40 pm
Posts: 65
Location: Russian Israel
Has thanked: 0 time
Have thanks: 0 time
Hey.. I want to show the Battery level on a bar..

hud_armor.cpp (OnThink)
Code:
void CHudArmor:: OnThink (void)
{
   float newArmor = 0;
   C_BasePlayer * local = C_BasePlayer:: GetLocalPlayer ();
   CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player *>( pPlayer );

   if (!local)
      return;

   // Never below zero

   newArmor = max(pHL2Player->ArmorValue(), 0);


   if (newArmor == m_flArmor)
      return;

   m_flArmor = newArmor;
}

That does not seems to work.. Can you help me sort it out?

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 04, 2009 5:22 pm 
Offline
Lead Coder
Lead Coder
User avatar

Joined: Tue Aug 15, 2006 3:39 pm
Posts: 1812
Location: Germany
Has thanked: 12 times
Have thanks: 29 times
this code is a bit messy, also i don't understand in how would it help you displaying something on an bar, more infos and / or more code needed...

_________________
ImageImage

Image

Image

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 04, 2009 8:08 pm 
Offline
prop_static
prop_static
User avatar

Joined: Fri Jun 26, 2009 7:40 pm
Posts: 65
Location: Russian Israel
Has thanked: 0 time
Have thanks: 0 time
Here, take a look at this code.

The OnThink function of hud_hull.cpp
Code:
void CHudHull:: OnThink (void)
{
   float newHull = 0;
   C_BasePlayer * local = C_BasePlayer:: GetLocalPlayer ();

   if (!local)
      return;

   // Never below zero
   newHull = max(local->GetHealth(), 0);

   // DevMsg("Sheild at is at: %f\n",newShield);
   // Only update the fade if we've changed health
   if (newHull == m_flHull)
      return;

   m_flHull = newHull;
}


I am trying to do something similar, but instead of showing the players
health level, it will show the suit battery power.

And I'm almost 100% sure I'm doing it wrong. I mean, all what needs to be edited in hud_hull.cpp is the OnThink function,
Code:
void CHudArmor:: OnThink (void)
{
   float newArmor = 0;
   C_BasePlayer * local = C_BasePlayer:: GetLocalPlayer ();
   CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player *>( pPlayer );

   if (!local)
      return;

   // Never below zero
   // newArmor = max(local->GetHealth(), 0);
   newArmor = max(pHL2Player->ArmorValue(), 0);

   // DevMsg("Sheild at is at: %f\n",newShield);
   // Only update the fade if we've changed health
   if (newArmor == m_flArmor)
      return;

   m_flArmor = newArmor;
}


Can you try help me sort it out please?

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 05, 2009 2:35 pm 
Offline
Lead Coder
Lead Coder
User avatar

Joined: Tue Aug 15, 2006 3:39 pm
Posts: 1812
Location: Germany
Has thanked: 12 times
Have thanks: 29 times
CHL2_Player is an Server Class, you can't access it from the client...

i'll make you a fixed file, i'll edit this post as soon as i'm done

Edit: http://neic0.de/codepaste/

_________________
ImageImage

Image

Image

Image



For this message the author Neico has received thanks: Steamcrusher(Sun Apr 20, 2014 2:42 pm)
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

Protected by Anti-Spam ACP Powered by phpBB® Forum Software © phpBB Group