Some fix, hope you like it.
PHP Code:
#include <amxmodx>
#include <fun>
#include <zombieplague>
#define PLUGIN "[ZP] Addon: Auto Health"
#define VERSION "1.0"
#define AUTHOR "Dias"
new cvar_auto_health, cvar_stock_health
new g_maxplayers
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_maxplayers = get_maxplayers()
cvar_auto_health = register_cvar("zp_auto_health", "1")
cvar_stock_health = register_cvar("zp_stock_health", "1000")
}
public zp_user_infected_post(id)
{
// Nemesis? no need la
if(zp_get_user_nemesis(id)) return;
if(get_pcvar_num(cvar_auto_health))
{
new health
health = (get_player_count() / get_zombie_count()) * get_pcvar_num(cvar_stock_health)
set_user_health(id, health)
}
}
get_zombie_count()
{
new count
for(new i = 0; i < g_maxplayers; i++)
{
if(is_user_connected(i) && zp_get_user_zombie(i))
count++
}
return count
}
get_player_count()
{
new count
for(new i = 0; i < g_maxplayers; i++)
{
if(is_user_connected(i))
count++
}
return count
}
__________________