Stamina Tutorial New defines: #define REGAIN_RATE 2 // 2 pts per second #define MAX_STAMINA 100 New Functions/Variables for CBasePlayer: bool HasEnoughStamina ( int x ); // stamina based on 0 - 100 bool BurnStamina ( int x ); // stamina based on 0 - 100 float m_flRegainStamina; Add this to CBasePlayer::PreThink() if (m_flRegainStamina <= gpGlobals->time) { BurnStamina( -REGAIN_RATE ); // other idea: // if (pev->iuser3 != 0) // BurnStamina ( -pev->iuser3 * .05 ); // else // pev->iuser3 += 10; // m_flRegainStamina = gpGlobals->time + 1.0; // gains 5% per second } bool CBasePlayer::BurnStamina ( int burn ) { if (HasEnoughStamina ( burn ) && burn > 0) { // uses stamina pev->iuser3 -= burn; m_flRegainStamina = gpGlobals->time + 1.5; return true; } else if ( ((pev->iuser3 - burn) < MAX_STAMINA ) && burn < 0 ) { // regains stamina pev->iuser3 -= burn; m_flRegainStamina = gpGlobals->time + 1.0; return true; } else (!HasEnoughStamina ( burn )) { m_flRegainStamina = gpGlobals->time + 1.0; return false; } } bool CBasePlayer::HasEnoughStamina ( int stamina ) { if ((pev->iuser3 - stamina) >= 0) return true; else return false; } CBasePlayer::Spawn(): pPlayer->pev->iuser3 = MAX_STAMINA; // this is full Basic Usage: if (BurnStamina(10)) // burn 10pts of stamina for jumping (if we cant, this returns false) { // jump } else { // nothing } iuser3 additions: Add this to client.cpp UpdateClientData() cd->iuser3 = ent->v.iuser3; Add this to delta.lst in clientdata_t DEFINE_DELTA( iuser3, DT_INTEGER, 7, 1.0 ), Client workspace hud.h (bottom) extern int g_iStamina; entity.cpp HUD_ProcessPlayerState() (towards bottom, other iusers will be there) g_iStamina = src->iuser3; Quick and dirty stamina bar... hud_redraw.cpp (below includes) int g_iStamina; CHud::Think() FillRGBA( ScreenWidth - XRES(55), (3*ScreenHeight)/4 + YRES(5), XRES( 50 ), YRES( 100 ), 32, 64, 128, 100 ); FillRGBA( ScreenWidth - XRES(50), (3*ScreenHeight)/4, XRES( 40 ), YRES( g_iStamina ), 128, 64, 32, 100 );