Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <zombieplague>
  5.  
  6. #define PLUGIN "[ZP] Addon: Show Zombie Health"
  7. #define VERSION "1.0"
  8. #define AUTHOR "Dias : BlackCat (bug fix)"
  9.  
  10. new const healthbar_spr[] = "sprites/zb_healthbar.spr"
  11. new g_playerbar[33] , g_isAlive[33]
  12. new g_playerMaxHealth[33]
  13.  
  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN, VERSION, AUTHOR)
  17.  
  18. RegisterHam(Ham_Spawn, "player", "ham_spawn_post", 1)
  19. register_forward(FM_AddToFullPack, "fm_addtofullpack_post", 1)
  20.  
  21. register_event("ResetHUD", "event_resethud", "be")
  22. register_event("DeathMsg", "event_death", "a")
  23. register_event("Health", "event_health", "be")
  24.  
  25. make_healthbar()
  26. }
  27.  
  28. public make_healthbar()
  29. {
  30. static playerBar, allocString
  31. allocString = engfunc(EngFunc_AllocString, "env_sprite")
  32.  
  33. for( new id = 1; id <= get_maxplayers(); id ++ )
  34. {
  35. g_playerbar[id] = engfunc(EngFunc_CreateNamedEntity, allocString)
  36. playerBar = g_playerbar[id]
  37.  
  38. if(pev_valid(playerBar))
  39. {
  40. set_pev(playerBar, pev_scale, 0.25)
  41. engfunc(EngFunc_SetModel, playerBar, healthbar_spr)
  42. set_pev(playerBar, pev_effects, pev(playerBar, pev_effects ) | EF_NODRAW)
  43. }
  44. }
  45. }
  46.  
  47. public plugin_precache() engfunc(EngFunc_PrecacheModel, healthbar_spr)
  48.  
  49. public ham_spawn_post(id)
  50. {
  51. if(is_user_alive(id))
  52. {
  53. g_isAlive[id] = 1
  54. g_playerMaxHealth[id] = get_user_health(id)
  55.  
  56. if(cs_get_user_team(id) == CS_TEAM_CT)
  57. set_pev(g_playerbar[id], pev_effects, pev(g_playerbar[id], pev_effects) | EF_NODRAW)
  58. }
  59. }
  60.  
  61. public client_disconnect(id)
  62. {
  63. set_pev(g_playerbar[id], pev_effects, pev(g_playerbar[id], pev_effects) | EF_NODRAW)
  64. }
  65.  
  66. public event_resethud(id)
  67. {
  68. set_pev(g_playerbar[id], pev_effects, pev(g_playerbar[id], pev_effects) | EF_NODRAW)
  69. }
  70.  
  71. public event_death()
  72. {
  73. new id = read_data(2)
  74.  
  75. g_isAlive[id] = 0
  76. set_pev(g_playerbar[id], pev_effects, pev(g_playerbar[id], pev_effects) | EF_NODRAW)
  77. }
  78.  
  79. public event_health(id)
  80. {
  81. new hp = get_user_health(id)
  82.  
  83. if(g_playerMaxHealth[id] < hp)
  84. {
  85. g_playerMaxHealth[id] = hp
  86. set_pev(g_playerbar[id], pev_frame, 99.0)
  87. }
  88. else
  89. {
  90. set_pev(g_playerbar[id], pev_frame, 0.0 + (((hp - 1) * 100) / g_playerMaxHealth[id]))
  91. }
  92. }
  93.  
  94. public fm_addtofullpack_post(es, e, user, host, host_flags, player, p_set)
  95. {
  96. if(!player)
  97. return FMRES_IGNORED
  98.  
  99. if(!is_user_alive(host) || !is_user_alive(user))
  100. return FMRES_IGNORED
  101.  
  102. if(cs_get_user_team(user) != CS_TEAM_T)
  103. return FMRES_IGNORED
  104.  
  105. if(host == user)
  106. return FMRES_IGNORED
  107.  
  108. new Float:PlayerOrigin[3]
  109. pev(user, pev_origin, PlayerOrigin)
  110.  
  111. PlayerOrigin[2] += 60.0
  112.  
  113. engfunc(EngFunc_SetOrigin, g_playerbar[user], PlayerOrigin)
  114. set_pev(g_playerbar[user], pev_effects, pev(g_playerbar[user], pev_effects) & ~EF_NODRAW)
  115.  
  116. return FMRES_HANDLED
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement