Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <hamsandwich>
  3. #include <fun>
  4. #include <colorchat>
  5.  
  6. #define AUTHOR "aSior - amxx.pl/user/60210-asiorr/"
  7.  
  8. new const damageInfoFormat[] = "Ofiara: %s^t^t-^t^tTrafienia: %i^t^t-^t^tDamage: %i^n";
  9.  
  10. // Display type: 0 - multiple lines, 1 - one line
  11. new const displayDamageMode = 0;
  12.  
  13. // Determines wether to display chat info with killer info.
  14. new const bool:displayChatMessage = true;
  15.  
  16. #define ForRange(%1,%2,%3) for(new %1 = %2; %1 <= %3; %1++)
  17. #define ForPlayers(%1) for(new %1 = 1; %1 <= MAX_PLAYERS + 1; %1++)
  18.  
  19.  
  20. new victimHits[MAX_PLAYERS + 1][MAX_PLAYERS + 1],
  21. victimDamage[MAX_PLAYERS + 1][MAX_PLAYERS + 1],
  22. victimName[MAX_PLAYERS + 1][MAX_PLAYERS + 1][33],
  23.  
  24. bool:damagePrinted[MAX_PLAYERS + 1];
  25.  
  26. public plugin_init()
  27. {
  28. register_plugin("CS:GO-like damage info", "v0.1", AUTHOR);
  29.  
  30. RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
  31.  
  32. register_event("DeathMsg", "playerDeathEvent", "a");
  33.  
  34. register_message(get_user_msgid("TextMsg"), "messageText");
  35.  
  36. register_logevent("roundEnd", 2, "1=Round_End");
  37. }
  38.  
  39. public messageText()
  40. {
  41. static textMessage[22];
  42. get_msg_arg_string(2, textMessage, charsmax(textMessage));
  43.  
  44. if(!equal(textMessage, "#Game_will_restart_in"))
  45. {
  46. return PLUGIN_CONTINUE;
  47. }
  48.  
  49. roundEnd();
  50.  
  51. return PLUGIN_CONTINUE;
  52. }
  53.  
  54. public roundEnd()
  55. {
  56. ForPlayers(index)
  57. {
  58. if(!is_user_connected(index))
  59. {
  60. continue;
  61. }
  62.  
  63. if(!damagePrinted[index])
  64. {
  65. printDamage(index);
  66. }
  67.  
  68. damagePrinted[index] = false;
  69. }
  70. }
  71.  
  72. public playerDeathEvent()
  73. {
  74. new killer = read_data(1),
  75. victim = read_data(2);
  76.  
  77. if(is_user_hltv(victim) || is_user_bot(victim))
  78. {
  79. return;
  80. }
  81.  
  82. printDamage(victim);
  83.  
  84. resetVariables(victim);
  85.  
  86. if(displayChatMessage && killer && killer != victim)
  87. {
  88. ColorChat(victim, RED, "[Death Info]^x01 Zostales zabity przez^x04 %n^x01. W konsoli (~) zostaly wypisane statystyki rundy.", killer);
  89. }
  90. }
  91.  
  92. public TakeDamage(victim, idinflictor, attacker, Float:damage, damagebits)
  93. {
  94. if(!is_user_alive(attacker) || !is_user_alive(victim) || is_user_hltv(victim))
  95. {
  96. return HAM_IGNORED;
  97. }
  98.  
  99. if(!victimName[attacker][victim][0])
  100. {
  101. get_user_name(victim, victimName[attacker][victim], charsmax(victimName[][]));
  102. }
  103.  
  104. victimHits[attacker][victim]++;
  105.  
  106. victimDamage[attacker][victim] += floatround(damage);
  107.  
  108. return HAM_IGNORED;
  109. }
  110.  
  111. printDamage(index)
  112. {
  113. if(!is_user_connected(index))
  114. {
  115. return;
  116. }
  117.  
  118. new bool:damageDealt,
  119. generalDamage,
  120. generalHits,
  121. generalVictims;
  122.  
  123. ForRange(i, 1, 32)
  124. {
  125. if(!victimHits[index][i])
  126. {
  127. continue;
  128. }
  129.  
  130. if(!damageDealt)
  131. {
  132. printSeparator(index, 1);
  133.  
  134. damageDealt = true;
  135. }
  136.  
  137. generalDamage += victimDamage[index][i];
  138. generalHits += victimHits[index][i];
  139. generalVictims++;
  140.  
  141. client_print(index, print_console, damageInfoFormat, victimName[index][i], victimHits[index][i], victimDamage[index][i]);
  142. }
  143.  
  144. if(damageDealt)
  145. {
  146. printSeparator(index, 2);
  147.  
  148. if(!displayDamageMode)
  149. {
  150. client_print(index, print_console, "Statystyka:^n^n^tTrafienia: %i^n^tObrazenia: %i^n^tOfiary: %i", generalHits, generalDamage, generalVictims);
  151. }
  152. else
  153. {
  154. client_print(index, print_console, "Statystyka: %i trafien%s, %i damage, %i ofiar%s.", generalHits, generalHits == 1 ? "e" : (generalHits < 5 ? "a" : "") , generalDamage, generalVictims, generalVictims == 1 ? "a" : (generalVictims < 5 ? "y" : ""));
  155. }
  156.  
  157. printSeparator(index, 1);
  158.  
  159. damagePrinted[index] = true;
  160. }
  161.  
  162. }
  163.  
  164. resetVariables(index)
  165. {
  166. ForRange(i, 1, 32)
  167. {
  168. victimName[index][i] = "";
  169. victimHits[index][i] = 0;
  170. victimDamage[index][i] = 0;
  171. }
  172.  
  173. damagePrinted[index] = false;
  174. }
  175.  
  176. printSeparator(index, times)
  177. {
  178. ForRange(i, 0, times - 1)
  179. {
  180. client_print(index, print_console, "\
  181. ^n\
  182. ----------------------------------------------------\
  183. ----------------------------------------------------\
  184. ^n\
  185. ");
  186. }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement