Advertisement
ColdWar-Pawn

Show Damage Taken

Jul 11th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.56 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #pragma semicolon 1
  4.  
  5. #define TIMEDELAY_RESET 1.0
  6. #define TAKEDAMAGE_CHANNEL 2
  7. #define DEALDAMAGE_CHANNEL 3
  8.  
  9. #include "amxmodx.inc"
  10. #include "hamsandwich.inc"
  11. #include "cstrike.inc"
  12. #include "engine.inc"
  13.  
  14. new Float: g_flTime[MAX_PLAYERS][MAX_PLAYERS];
  15. new Float: g_flDamage[MAX_PLAYERS][MAX_PLAYERS];
  16. new g_pFriendlyFire;
  17.  
  18. public plugin_init()
  19. {
  20.     register_plugin("Damage Taken", "V1.0", "Yannay"); // for faggot yuval -- from 2014
  21.    
  22.     RegisterHamPlayer(Ham_TakeDamage, "Ham_TakeDamage_Post", 1);
  23.    
  24.     g_pFriendlyFire = get_cvar_pointer("mp_friendlyfire");
  25. }
  26.  
  27. public Ham_TakeDamage_Post(const iVictim, const iInflictor, const iAttacker, Float: flDamage)
  28. {
  29.     if(!(1 <= iVictim <= MaxClients) || !(1 <= iAttacker <= MaxClients))
  30.     {
  31.         return HAM_IGNORED;
  32.     }
  33.    
  34.     if(cs_get_user_team(iVictim) == cs_get_user_team(iAttacker))
  35.     {
  36.         if(get_pcvar_num(g_pFriendlyFire)) {
  37.             flDamage /= 3.0;
  38.         }
  39.         else
  40.         {
  41.             return HAM_IGNORED;
  42.         }
  43.     }
  44.    
  45.     if(halflife_time() - g_flTime[iVictim - 1][iAttacker - 1] >= TIMEDELAY_RESET)
  46.     {
  47.         g_flDamage[iVictim - 1][iAttacker - 1] = 0.0;
  48.     }
  49.  
  50.     g_flTime[iVictim - 1][iAttacker - 1] = halflife_time();
  51.     g_flDamage[iVictim - 1][iAttacker - 1] += flDamage;
  52.    
  53.     if(g_flDamage[iVictim - 1][iAttacker - 1] >= 1.0) {
  54.         static iSpectatingIndex;
  55.        
  56.         for(new i = 1; i <= MaxClients; i++) {
  57.             if(!is_user_connected(i) || is_user_alive(i) || i == iVictim || i == iAttacker) // is our player a spectator?
  58.             {
  59.                 continue;
  60.             }
  61.            
  62.             iSpectatingIndex = entity_get_int(i, EV_INT_iuser2); // figure out which player the index that we are looking at is spectating
  63.            
  64.             if(!(1 <= iSpectatingIndex <= MaxClients))
  65.             {
  66.                 continue;
  67.             }
  68.            
  69.             if(iSpectatingIndex == iVictim) {
  70.                 set_hudmessage(255, 0, 0, 0.45, 0.55, 0, 0.0, 1.5, .channel=TAKEDAMAGE_CHANNEL);
  71.                 show_hudmessage(i, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
  72.                 continue;
  73.             }
  74.            
  75.             if(iSpectatingIndex == iAttacker) {
  76.                 set_hudmessage(0, 127, 255, 0.55, 0.45, 0, 0.0, 1.5, .channel=DEALDAMAGE_CHANNEL);
  77.                 show_hudmessage(i, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
  78.                 continue;
  79.             }
  80.         }
  81.        
  82.         set_hudmessage(255, 0, 0, 0.45, 0.55, 0, 0.0, 1.5, .channel=TAKEDAMAGE_CHANNEL);
  83.         show_hudmessage(iVictim, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
  84.        
  85.         set_hudmessage(0, 127, 255, 0.55, 0.45, 0, 0.0, 1.5, .channel=DEALDAMAGE_CHANNEL);
  86.         show_hudmessage(iAttacker, "%i", floatround(g_flDamage[iVictim - 1][iAttacker - 1]));
  87.     }
  88.    
  89.     return HAM_IGNORED;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement