public plugin_precache() { // Initialize arrays g_sound_zombie_madness = ArrayCreate(SOUND_MAX_LENGTH, 1)
// Load from external file amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ZOMBIE MADNESS", g_sound_zombie_madness)
// If we couldn't load custom sounds from file, use and save default ones new index if (ArraySize(g_sound_zombie_madness) == 0) { for (index = 0; index < sizeof sound_zombie_madness; index++) ArrayPushString(g_sound_zombie_madness, sound_zombie_madness[index])
// Save to external file amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ZOMBIE MADNESS", g_sound_zombie_madness) }
// Precache sounds new sound[SOUND_MAX_LENGTH] for (index = 0; index < ArraySize(g_sound_zombie_madness); index++) { ArrayGetString(g_sound_zombie_madness, index, sound, charsmax(sound)) precache_sound(sound) } }
public plugin_natives() { register_library("zp50_item_zombie_madness") register_native("zp_item_zombie_madness_get", "native_item_zombie_madness_get")
set_module_filter("module_filter") set_native_filter("native_filter") } public module_filter(const module[]) { if (equal(module, LIBRARY_NEMESIS) || equal(module, LIBRARY_GRENADE_FROST) || equal(module, LIBRARY_GRENADE_FIRE)) return PLUGIN_HANDLED;
return PLUGIN_CONTINUE; } public native_filter(const name[], index, trap) { if (!trap) return PLUGIN_HANDLED;
return PLUGIN_CONTINUE; }
public native_item_zombie_madness_get(plugin_id, num_params) { new id = get_param(1)
if (!is_user_alive(id)) { log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id) return false; }
// Set task to remove it set_task(get_pcvar_float(cvar_zombie_madness_time), "remove_zombie_madness", id+TASK_MADNESS) }
// Ham Player Spawn Post Forward public fw_PlayerSpawn_Post(id) { // Not alive or didn't join a team yet if (!is_user_alive(id) || !cs_get_user_team(id)) return;
// Remove zombie madness from a previous round remove_task(id+TASK_MADNESS) remove_task(id+TASK_AURA) flag_unset(g_MadnessBlockDamage, id)
}
// Ham Trace Attack Forward public fw_TraceAttack(victim, attacker) { // Non-player damage or self damage if (victim == attacker || !is_user_alive(attacker)) return HAM_IGNORED;
// Prevent attacks when victim has zombie madness if (flag_get(g_MadnessBlockDamage, victim)) return HAM_SUPERCEDE;
return HAM_IGNORED; }
// Ham Take Damage Forward (needed to block explosion damage too) public fw_TakeDamage(victim, inflictor, attacker) { // Non-player damage or self damage if (victim == attacker || !is_user_alive(attacker)) return HAM_IGNORED;
// Prevent attacks when victim has zombie madness if (flag_get(g_MadnessBlockDamage, victim)) return HAM_SUPERCEDE;
return HAM_IGNORED; }
public zp_fw_grenade_frost_pre(id) { // Prevent frost when victim has zombie madness if (flag_get(g_MadnessBlockDamage, id)) return PLUGIN_HANDLED;
return PLUGIN_CONTINUE; }
public zp_fw_grenade_fire_pre(id) { // Prevent burning when victim has zombie madness if (flag_get(g_MadnessBlockDamage, id)) return PLUGIN_HANDLED;
public client_disconnect(id) { // Remove tasks on disconnect remove_task(id+TASK_MADNESS) remove_task(id+TASK_AURA) flag_unset(g_MadnessBlockDamage, id) }
// Madness aura task public madness_aura(taskid) { // Get player's origin static origin[3] get_user_origin(ID_AURA, origin)
// Colored Aura message_begin(MSG_PVS, SVC_TEMPENTITY, origin) write_byte(TE_DLIGHT) // TE id write_coord(origin[0]) // x write_coord(origin[1]) // y write_coord(origin[2]) // z write_byte(20) // radius write_byte(get_pcvar_num(cvar_madness_aura_color_R)) // r write_byte(get_pcvar_num(cvar_madness_aura_color_G)) // g write_byte(get_pcvar_num(cvar_madness_aura_color_B)) // b write_byte(2) // life write_byte(0) // decay rate message_end() }