HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4.  
  5. #define PLUGIN_NAME "Health Display"
  6. #define PLUGIN_VERSION "11.1"
  7. #define PLUGIN_AUTHOR "Exolent"
  8.  
  9.  
  10. #pragma semicolon 1
  11.  
  12.  
  13. new bool:g_player_didnt_spawn[33];
  14.  
  15. new health_on;
  16. new health_time;
  17. new health_color;
  18. new health_custom;
  19. new health_effects;
  20. new health_always;
  21.  
  22. public plugin_init()
  23. {
  24. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  25. register_cvar("health_display", PLUGIN_VERSION, FCVAR_SPONLY);
  26.  
  27. register_clcmd("say /health", "CmdHealth");
  28. register_clcmd("say_team /health", "CmdHealth");
  29. register_clcmd("fullupdate", "CmdFullupdate");
  30.  
  31. register_event("Health", "EventHealth", "be", "1>0");
  32. register_event("ResetHUD", "EventResetHud", "be");
  33. register_event("TextMsg", "EventRestartAttempt", "a", "2&#Game_w");
  34. register_event("DeathMsg", "EventDeathMsg", "a");
  35.  
  36. health_on = register_cvar("health_on", "1");
  37. health_time = register_cvar("health_time", "12");
  38. health_color = register_cvar("health_color", "1");
  39. health_custom = register_cvar("health_custom", "255 255 0");
  40. health_effects = register_cvar("health_effects", "1");
  41. health_always = register_cvar("health_always", "0");
  42. }
  43.  
  44. public client_disconnect(client)
  45. {
  46. remove_task(client);
  47. }
  48.  
  49. public CmdHealth(client)
  50. {
  51. if( !get_pcvar_num(health_on) )
  52. {
  53. client_print(client, print_chat, "Az élet kijelzõ most nem látható.");
  54. }
  55. else if( is_user_alive(client) )
  56. {
  57. ShowHealth(client);
  58. }
  59.  
  60. return PLUGIN_HANDLED;
  61. }
  62.  
  63. public CmdFullupdate(client)
  64. {
  65. return PLUGIN_HANDLED_MAIN;
  66. }
  67.  
  68. public EventHealth(client)
  69. {
  70. if( get_pcvar_num(health_on) )
  71. {
  72. ShowHealth(client);
  73. }
  74. }
  75.  
  76. public EventResetHud(client)
  77. {
  78. if( g_player_didnt_spawn[client] )
  79. {
  80. g_player_didnt_spawn[client] = false;
  81. }
  82. else if( is_user_alive(client) && get_pcvar_num(health_always) )
  83. {
  84. set_task(0.1, "ShowHealth", client);
  85. }
  86. }
  87.  
  88. public EventRestartAttempt()
  89. {
  90. new players[32], pnum;
  91. get_players(players, pnum, "a");
  92.  
  93. for( new i = 0; i < pnum; i++ )
  94. {
  95. g_player_didnt_spawn[players[i]] = true;
  96. }
  97. }
  98.  
  99. public EventDeathMsg()
  100. {
  101. new client = read_data(2);
  102.  
  103. remove_task(client);
  104.  
  105. set_hudmessage(_, _, _, _, _, _, _, _, _, _, 3);
  106. show_hudmessage(client, "");
  107. }
  108.  
  109. public ShowHealth(client)
  110. {
  111. remove_task(client);
  112.  
  113. new hud_red, hud_green, hud_blue;
  114. switch( get_pcvar_num(health_color) )
  115. {
  116. case 0:
  117. {
  118. hud_red = 255;
  119. hud_green = 255;
  120. hud_blue = 255;
  121. }
  122. case 1:
  123. {
  124. new color[16], red[4], green[4], blue[4];
  125. get_pcvar_string(health_custom, color, 15);
  126. parse(color, red, 3, green, 3, blue, 3);
  127.  
  128. hud_red = str_to_num(red);
  129. hud_green = str_to_num(green);
  130. hud_blue = str_to_num(blue);
  131. }
  132. case 2:
  133. {
  134. hud_red = random(256);
  135. hud_green = random(256);
  136. hud_blue = random(256);
  137. }
  138. }
  139.  
  140. new Float:hud_time = get_pcvar_float(health_time);
  141.  
  142. set_hudmessage(hud_red, hud_green, hud_blue, -1.0, 0.9, get_pcvar_num(health_effects), hud_time, hud_time, 0.1, 0.2, 3);
  143. show_hudmessage(client, "Health: %i", get_user_health(client));
  144.  
  145. if( get_pcvar_num(health_always) )
  146. {
  147. set_task(hud_time - 0.1, "ShowHealth", client);
  148. }
  149. }
  150.