yes, the code is not good, if I have time I'll try to make a new version..
P.S: try the code of abdul..
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>
#include <zombieplague>
#include <cs_player_models_api>
// The mutated zombie's model ( only models folder name is required and the model must be in models/player/ )
new const model_mutate[] = "zombiemutate"
// The mutated zombie's v_model
new const model_mutatehands[] = "models/zombiemutate/zombiemutatehands.mdl"
// Only use wave sounds bcoz they can only be properly emitted
new const sound_mutate[] = "sound/zombiemutate/mutating.wav"
// Cvar pointers
new cvar_maxzombies, cvar_health, cvar_percent, g_max_player, cvar_healthreward
public plugin_init()
{
register_plugin("[ZP] Addon: Zombie Mutation", "1.0", "@bdul!")
cvar_health = register_cvar("zp_mutate_health", "300") // Minimum Amount of health a zombie needs to mutate (have a chance to)
cvar_maxzombies = register_cvar("zp_mutate_maxzombies", "3") // Last "x" zombies have a chance to mutate.
cvar_percent = register_cvar("zp_mutate_chance", "10") // 1 in "x"
cvar_healthreward = register_cvar("zp_mutate_health_reward", "3000") // Amount of health rewarded to the mutated zombie
RegisterHam(Ham_Killed, "player", "ham_killed_post", 1)
RegisterHam(Ham_Spawn, "player", "ham_player_spawn_post", 1)
g_max_player = get_maxplayers()
// Dont use deathmsg if you are including hamsandwich because ham_killed is better
//register_event("Event_DeathMsg", "DeathMsg", "a")
}
public plugin_precache()
{
new buffer[256]
// Format the model's path and then precache it
formatex(buffer, 255, "models/player/%s/%s.mdl", model_mutate, model_mutate)
precache_model(buffer)
precache_model(model_mutatehands)
// Precache our sound (must be wav)
precache_sound(sound_mutate)
}
// You need to check in all these forwards for the last zombies to mutate
public ham_player_spawn_post() check_for_zombie()
public ham_killed_post() check_for_zombie()
public client_disconnect(id) check_for_zombie()
public zp_user_humanized_post(id, unused) check_for_zombie()
check_for_zombie()
{
// Get the actual zombies count
if ((zp_get_zombie_count() - zp_get_nemesis_count()) <= get_pcvar_num(cvar_maxzombies))
{
static id
for (id = 1; id <= g_max_player; id++)
{
if (!zp_get_user_zombie(id) || (get_user_health(id) < get_pcvar_num(cvar_health)))
continue;
if (random_num(1, get_pcvar_num(cvar_percent)) == 1)
set_task(2.0, "mutate_user", id)
// This is necassary to make the loop continue
continue;
}
}
}
public mutate_user(id)
{
// Changing models rapidly can result in SVC_BAD kicks so its better to change it once only
cs_set_player_model(id, model_mutate)
// Set v_model
set_pev(id, pev_viewmodel2, model_mutatehands)
// Set his health
set_user_health(id, get_user_health(id) + get_pcvar_num(cvar_healthreward))
// Emit sound is used so that only near by players are informed of the mutation
emit_sound(id, CHAN_VOICE, sound_mutate, 1.0, ATTN_NORM, 0, PITCH_NORM)
}