Hello. This plugin is about health regeneration regarding all players on the server. It's about constant health regeneration, until the amount of the player's health reaches the maximum according to the settings of the ZP mod itself:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
new g_Status, g_Time, g_Amount, g_ZombiePlague, g_Nemesis, g_FirstZombie, g_LastZombie, g_heal
new const health_sound[] = "zb/zombi_heal.wav"
public plugin_init()
{
register_plugin("ZP: Regeneration", "1.3 Fix bug", "hleV")
g_Status = register_cvar("zp_regeneration", "1") //on/off
g_Time = register_cvar("zp_regen_time", "1") //vpema perena
g_Amount = register_cvar("zp_regen_amount", "10") //ckolko hp gavat npu perene
g_Nemesis = register_cvar("zp_regen_nemesis", "1") //perenutca lu nemesis
g_FirstZombie = register_cvar("zp_regen_firstzombie", "1") //perenutca lu 1 zombu
g_LastZombie = register_cvar("zp_regen_lastzombie", "1") //perenutca lu last zombu
register_event("Damage", "SetRegeneration", "be", "2>0")
g_ZombiePlague = get_cvar_pointer("zp_on")
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheSound, health_sound)
g_heal = precache_model("sprites/cso_heal.spr")
}
public SetRegeneration(Client)
{
if(!g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client) || !zp_get_user_zombie(Client))
return
new Health = get_user_health(Client)
if(Health < 1)
return
if(!get_pcvar_num(g_Nemesis) && zp_get_user_nemesis(Client))
return
if(!get_pcvar_num(g_FirstZombie) && zp_get_user_first_zombie(Client))
return
if(!get_pcvar_num(g_LastZombie) && zp_get_user_last_zombie(Client))
return
if(get_user_health(Client) < zp_get_zombie_maxhealth(Client))
set_task(get_pcvar_float(g_Time), "Regenerate", Client, _, _, "b")
}
public Regenerate(Client)
{
if(!g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client))
return
new Health = pev(Client, pev_health)
if(Health < 1)
return
new NeededHealth = zp_get_zombie_maxhealth(Client) - Health
if(NeededHealth <= get_pcvar_num(g_Amount))
{
set_pev(Client, pev_health, Health + float(NeededHealth))
remove_task(Client)
return
}
set_pev(Client, pev_health, Health + get_pcvar_float(g_Amount))
engfunc(EngFunc_EmitSound, Client, CHAN_BODY, health_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
new origin[3]
get_user_origin(Client,origin)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_SPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]+=30)
write_short(g_heal)
write_byte(8)
write_byte(255)
message_end()
}
When players join the server, the plugin works perfectly during the first round. However, once the first round is finished, at the beginning of the next round, everyone will be dead, no one will be able to move, and when you press TAB no one is shown as "DEAD".
When this problem happens after the first round, in the beginning of the second round, everyone is spawned already dead, and has -1 health.
This option
"g_Amount = register_cvar("zp_regen_amount", "10")" suggests the amount of HP per second is 10. However, it's 1000-2000, because the plugin works ultra-fast, and the 10hp are coming multiple times per second, not only one time per second.
This sound:
"new const health_sound[] = "zb/zombi_heal.wav"" is never finished. You hear only the first fraction of the first second, after which it repeats only the first fraction of the second, but never finishes the whole sound. This explains that the plugin works ultra-fast, and there is no time for the sound of giving 10hp to be finished, because the next 10hp is given even before the sound finishes.
The sound has to be played once per received 10hp. Since you don't receive 10hp per second, but around 1000-2000hp per second, the sound is repeated 1000-2000 times per second.
The same goes for the .spr file that comes out of you when you receive 10hp. Instead of your model releasing one sprite per second, it releases thousands of sprites per second.
I think this 'ultra-fast' bug is causing the problem.
Do you understand what I'm trying to explain? If you have a zombie mod, i recommend you to test the plugin, so you can understand what I'm talking about.
If you don't know how to fix the problem, just tell me. I already know how to have regeneration for all zombies, however, i have to add separated codes to each .sma file of each zombie, which means that if i want to disable the regeneration, i will have to edit all zombie classes, instead of just putting ";" before the name of the regeneration plugin i presented in this thread. I prefer to have one plugin controlling the HP of all zombies, instead of having to individually interfere in every single .sma file each time i want to change the regeneration.
I know my English is not good. If you don't understand me, just say it, and i will try to explain it in better way.