|
Senior Member
|

07-01-2018
, 17:34
Re: Emit Sound Problem. Fire sound is overlapping my sounds
|
#12
|
Quote:
Originally Posted by Celena Luna
If possible, show full code is recommended (or that is all you wrote?)
|
This is the actual code..
PHP Code:
#include < amxmodx > #include < fakemeta > #include < hamsandwich > #include < zombieplague >
const m_pPlayer = 41; const m_fInReload = 54; const m_fInSpecialReload = 55; const m_flTimeWeaponIdle = 48;
// SONIDOS DE RECARGA
new const reload1[] = "zombie_plague/zs_recargando_1.wav" new const reload2[] = "zombie_plague/zs_recargando_2.wav" new const reload3[] = "zombie_plague/zs_recargando_3.wav" new const reload4[] = "zombie_plague/zs_recargando_4.wav"
public plugin_init( ) { // 2 = CSW_SHIELD = UNDEFINED | PUT SHOTGUNS HERE TO SKIP IN LOOP AND REGISTER MANUALLY new const NO_RELOAD = ( 1 << 2 ) | ( 1 << CSW_KNIFE ) | ( 1 << CSW_C4 ) | ( 1 << CSW_M3 ) | ( 1 << CSW_XM1014 ) | ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ); new szWeaponName[ 20 ]; for( new i = CSW_P228; i <= CSW_P90; i++ ) { // If its no-reload weapon or shotgun skip it if( NO_RELOAD & ( 1 << i ) ) { continue; } // Get weapon name get_weaponname( i, szWeaponName, 19 ); // Register forward RegisterHam( Ham_Weapon_Reload, szWeaponName, "FwdHamWeaponReload", 1 ); } // Register shotguns, we need different function for additional checks RegisterHam( Ham_Weapon_Reload, "weapon_m3", "FwdHamShotgunReload", 1 ); RegisterHam( Ham_Weapon_Reload, "weapon_xm1014", "FwdHamShotgunReload", 1 ); }
public plugin_precache() { precache_sound(reload1) precache_sound(reload2) precache_sound(reload3) precache_sound(reload4)
}
public FwdHamWeaponReload( const iWeapon ) { // m_fInReload is set to TRUE in DefaultReload( ) // We are only checking if this offset is set to true because // Ham_Weapon_Reload is being called as long as player holds the reload key // But its only called once if weapon is being reloaded, and doesnt call more while its reloading if( get_pdata_int( iWeapon, m_fInReload, 4 ) ) { static id id = pev(iWeapon, pev_owner) if(!is_user_alive(id) || !is_user_connected(id) || zp_get_user_zombie(id)) return HAM_IGNORED // Weapon has started reload //console_print(0, "COMIENZA A RECARGAR EL ID: %i", id) new random = random_num(1, 4) if (random == 1) { emit_sound(id, CHAN_BODY , reload1, 1.0, ATTN_NORM, 0, PITCH_NORM ); //emit_sound(id, CHAN_VOICE, reload1, 1.0, ATTN_NORM, 0, PITCH_NORM) } else if (random == 2) { emit_sound(id, CHAN_BODY , reload2, 1.0, ATTN_NORM, 0, PITCH_NORM ); //emit_sound(id, CHAN_VOICE, reload2, 1.0, ATTN_NORM, 0, PITCH_NORM) } else if (random == 3) { emit_sound(id, CHAN_BODY , reload3, 1.0, ATTN_NORM, 0, PITCH_NORM ); //emit_sound(id, CHAN_VOICE, reload3, 1.0, ATTN_NORM, 0, PITCH_NORM) } else if (random == 4) { emit_sound(id, CHAN_BODY , reload4, 1.0, ATTN_NORM, 0, PITCH_NORM ); //emit_sound(id, CHAN_VOICE, reload4, 1.0, ATTN_NORM, 0, PITCH_NORM) } // To check if its reload by player or auto (0 ammo) you can do this: // Check !( get_user_button( id ) & IN_BUTTON ) // Or check if clip ammo equals to 0 } } public FwdHamShotgunReload( const iWeapon ) { // in Reload( ) there is switch of this offset // On case 0 it is being set to 1 and some weapon idle/nextattacks are being set to 0.55 // case 1: bullet input animation // case 2: adding bullet to clip itself // this case 1-2-1 is being looped while the shotgun is reloading if( get_pdata_int( iWeapon, m_fInSpecialReload, 4 ) != 1 ) { return; } // If you will remove the check below, you will be able to hook when engine // sets animation (M3_INSERT) bullet // The first set of m_fInSpecialReload to 1. m_flTimeWeaponIdle remains 0.55 set from Reload( ) new Float:flTimeWeaponIdle = get_pdata_float( iWeapon, m_flTimeWeaponIdle, 4 ); if( flTimeWeaponIdle != 0.55 ) { return; } // Shotgun has started reload }
In this code sound is in CHAN_BODY, but I tested all channels.
Last edited by esenrik; 07-01-2018 at 17:40.
|
|