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()
{
set_module_filter("module_filter")
set_native_filter("native_filter")
}
public module_filter(const module[])
{
if (equal(module, LIBRARY_NEMESIS))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_items_select_pre(id, itemid, ignorecost)
{
// This is not our item
if (itemid != g_ItemID)
return ZP_ITEM_AVAILABLE;
// Zombie madness only available to zombies
if (!zp_core_is_zombie(id))
return ZP_ITEM_DONT_SHOW;
// Zombie madness not available to Nemesis
if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && zp_class_nemesis_get(id))
return ZP_ITEM_DONT_SHOW;
// Player already has madness
if (flag_get(g_MadnessBlockDamage, id))
return ZP_ITEM_NOT_AVAILABLE;
return ZP_ITEM_AVAILABLE;
}
public zp_fw_items_select_post(id, itemid, ignorecost)
{
// This is not our item
if (itemid != g_ItemID)
return;
// Do not take damage
flag_set(g_MadnessBlockDamage, id)
// 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;
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()
}
Arkshine
06-27-2012 06:31
Re: emit_sound is bugged?
Modify the sound to not loop. Don't ask how, search on google, it's unrelated to Amxx.
Heyka
06-27-2012 08:12
Re: emit_sound is bugged?
I did what you said. Unloop sound... still doesn't work.