ty

2014-05-15 11:10 GMT+03:00 Tony "omega" Sergi <omegal...@gmail.com>:

> curstate.health
> not pev->health
>
> ie:
>     for (int i = 1; i < MAX_PLAYERS; i++)
>     {
>         cl_entity_t *pl = gEngfuncs.GetEntityByIndex(i);
>         if ( pl && pl->player )
>         {
>              ALERT( at_console, "[%s] has %i health\n",
> g_PlayerInfoList[i].name, pl->curstate.health );
>          }
>       }
>
>
>
>
>
> On Wed, May 14, 2014 at 9:35 PM, Matas Lešinskas <peon...@gmail.com>wrote:
>
>> Hi hlcoders, I have 1 problem with my goldsrc mod, I am trying to make hp
>> shown like in left 4 dead, question how to get other players hp’s? maybe I
>> can do something with it?
>>
>> void CBasePlayer::UpdateStatusBar()
>>
>> {
>>
>>       int newSBarState[ SBAR_END ];
>>
>>       char sbuf0[ SBAR_STRING_SIZE ];
>>
>>       char sbuf1[ SBAR_STRING_SIZE ];
>>
>>
>>
>>       memset( newSBarState, 0, sizeof(newSBarState) );
>>
>>       strcpy( sbuf0, m_SbarString0 );
>>
>>       strcpy( sbuf1, m_SbarString1 );
>>
>>
>>
>>       // Find an ID Target
>>
>>       TraceResult tr;
>>
>>       UTIL_MakeVectors( pev->v_angle + pev->punchangle );
>>
>>       Vector vecSrc = EyePosition();
>>
>>       Vector vecEnd = vecSrc + (gpGlobals->v_forward * MAX_ID_RANGE);
>>
>>       UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr);
>>
>>
>>
>>       if (tr.flFraction != 1.0)
>>
>>       {
>>
>>             if ( !FNullEnt( tr.pHit ) )
>>
>>             {
>>
>>                   CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
>>
>>
>>
>>                   if (pEntity->Classify() == CLASS_PLAYER )
>>
>>                   {
>>
>>                         newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX(
>> pEntity->edict() );
>>
>>                         strcpy( sbuf1, "1 %p1\n2 Health: %i2%%\n3 Armor:
>> %i3%%" );
>>
>>
>>
>>                         // allies and medics get to see the targets
>> health
>>
>>                         if ( g_pGameRules->PlayerRelationship( this,
>> pEntity ) == GR_TEAMMATE )
>>
>>                         {
>>
>>                               newSBarState[ SBAR_ID_TARGETHEALTH ] = 100
>> * (pEntity->pev->health / pEntity->pev->max_health);
>>
>>                               newSBarState[ SBAR_ID_TARGETARMOR ] =
>> pEntity->pev->armorvalue; //No need to get it % based since 100 it's the
>> max.
>>
>>                         }
>>
>>
>>
>>                         m_flStatusBarDisappearDelay = gpGlobals->time +
>> 1.0;
>>
>>                   }
>>
>>             }
>>
>>             else if ( m_flStatusBarDisappearDelay > gpGlobals->time )
>>
>>             {
>>
>>                   // hold the values for a short amount of time after
>> viewing the object
>>
>>                   newSBarState[ SBAR_ID_TARGETNAME ] = m_izSBarState[
>> SBAR_ID_TARGETNAME ];
>>
>>                   newSBarState[ SBAR_ID_TARGETHEALTH ] = m_izSBarState[
>> SBAR_ID_TARGETHEALTH ];
>>
>>                   newSBarState[ SBAR_ID_TARGETARMOR ] = m_izSBarState[
>> SBAR_ID_TARGETARMOR ];
>>
>>             }
>>
>>       }
>>
>>
>>
>>       BOOL bForceResend = FALSE;
>>
>>
>>
>>       if ( strcmp( sbuf0, m_SbarString0 ) )
>>
>>       {
>>
>>             MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev );
>>
>>                   WRITE_BYTE( 0 );
>>
>>                   WRITE_STRING( sbuf0 );
>>
>>             MESSAGE_END();
>>
>>
>>
>>             strcpy( m_SbarString0, sbuf0 );
>>
>>
>>
>>             // make sure everything's resent
>>
>>             bForceResend = TRUE;
>>
>>       }
>>
>>
>>
>>       if ( strcmp( sbuf1, m_SbarString1 ) )
>>
>>       {
>>
>>             MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev );
>>
>>                   WRITE_BYTE( 1 );
>>
>>                   WRITE_STRING( sbuf1 );
>>
>>             MESSAGE_END();
>>
>>
>>
>>             strcpy( m_SbarString1, sbuf1 );
>>
>>
>>
>>             // make sure everything's resent
>>
>>             bForceResend = TRUE;
>>
>>       }
>>
>>
>>
>>       // Check values and send if they don't match
>>
>>       for (int i = 1; i < SBAR_END; i++)
>>
>>       {
>>
>>             if ( newSBarState[i] != m_izSBarState[i] || bForceResend )
>>
>>             {
>>
>>                   MESSAGE_BEGIN( MSG_ONE, gmsgStatusValue, NULL, pev );
>>
>>                         WRITE_BYTE( i );
>>
>>                         WRITE_SHORT( newSBarState[i] );
>>
>>                   MESSAGE_END();
>>
>>
>>
>>                   m_izSBarState[i] = newSBarState[i];
>>
>>             }
>>
>>       }
>>
>> }
>>
>> Or  something with this part and make pev->health to  pEntity->pev->health,
>> but how get player id ect…
>>
>>       if (pev->health != m_iClientHealth)
>>
>>       {
>>
>>             int iHealth = max( pev->health, 0 );  // make sure that no
>> negative health values are sent
>>
>>
>>
>>             // send "health" update message
>>
>>             MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev );
>>
>>                   WRITE_BYTE( iHealth );
>>
>>             MESSAGE_END();
>>
>>
>>
>>             m_iClientHealth = pev->health;
>>
>>       }
>>
>>
>>
>> _______________________________________________
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>>
>>
>>
>
>
> --
> -Tony
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
>
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders

Reply via email to