Raised This Month: $ Target: $400
 0% 

[play sound] in_ATTACK only once


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-05-2011 , 05:38   [play sound] in_ATTACK only once
Reply With Quote #1

when I press mouse1 I hear multiple sounds. Im using 1 sound....


PHP Code:
public fw_CmdStart(idhandleseed)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED
    
    
if(!g_HasRailgun[id])
        return 
FMRES_IGNORED
        
    
    
    
if(g_iCurWpn[id] != CSW_WPN)
        return 
FMRES_IGNORED
        
    
static iButton
    iButton 
get_uc(handleUC_Buttons)
 
          if(
iButton IN_ATTACK)
                    
emit_sound(idCHAN_WEAPONsnd_fire[random_num(0sizeof snd_fire 1)], VOL_NORMATTN_NORM0PITCH_NORM)      

    
    if(
iButton IN_ATTACK)
    {
        
set_uc(handleUC_ButtonsiButton & ~IN_ATTACK)
        
        static 
Float:flCurTime
        flCurTime 
halflife_time()
        
        if(
flCurTime g_flLastFireTime[id] < FIRERATE1)
            return 
FMRES_IGNORED
            
        
static iWpnIDiClip
        iWpnID 
get_pdata_cbase(idm_pActiveItem5)
        
iClip cs_get_weapon_ammo(iWpnID)
        
        if(
get_pdata_int(iWpnIDm_fInReload4))
            return 
FMRES_IGNORED
        
        set_pdata_float
(iWpnIDm_flNextPrimaryAttackFIRERATE14)
        
set_pdata_float(iWpnIDm_flNextSecondaryAttackFIRERATE14)
        
set_pdata_float(iWpnIDm_flTimeWeaponIdleFIRERATE14)
        
g_flLastFireTime[id] = flCurTime
        
if(iClip <= 0)
        {
            
ExecuteHamB(Ham_Weapon_PlayEmptySoundiWpnID)
            return 
FMRES_IGNORED
        
}
        
primary_attack(id)                        
        
cs_set_weapon_ammo(iWpnID, --iClip)
        
        return 
FMRES_IGNORED
    
}
    
    return 
FMRES_IGNORED

__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 08-05-2011 , 06:25   Re: [play sound] in_ATTACK only once
Reply With Quote #2

Make sure oldbutton is not IN_ATTACK
Code:
    static iButton, iOldButtons     iButton = get_uc(handle, UC_Buttons)     iOldButtons = pev( id, pev_oldbuttons )               if ( ( iButton & IN_ATTACK ) && !( iOldButtons & IN_ATTACK ) )                     emit_sound(id, CHAN_WEAPON, snd_fire[random_num(0, sizeof snd_fire - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-05-2011 , 06:42   Re: [play sound] in_ATTACK only once
Reply With Quote #3

thanks. do u want to take part in creation of new mod? we can discuss the payment./
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 08-05-2011 , 07:07   Re: [play sound] in_ATTACK only once
Reply With Quote #4

Well i m busy with some other project so i dont really have time, Sorry
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-05-2011 , 07:55   Re: [play sound] in_ATTACK only once
Reply With Quote #5

I mean small improvements like this one. I cant write all plugins.(|)

my current problem is. weapon animation is faster because of attack rate.
and emit_sound plays according to attack rate...
even I play sound in FwdCmdstart -> sound plays only once when I press mouse1 .... I dont know how to put correct animation without changing attack rate.

Here im not using fwcmdstart yet . but. when I press mouse1 ., I see Speed up animation. and the same sound. because of fast attack rate. ( it should be similar to saw plugin )




PHP Code:
#include <amxmodx> 
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <cstrike>

new VIEW_MODEL[]    = "models/v_q3melee.mdl" 
new PLAYER_MODEL[]    = "models/p_q3melee.mdl" 
new WORLD_MODEL[]    = "models/w_knife.mdl"

new OLDWORLD_MODEL[]    = "models/w_knife.mdl"

new  Sound_melee[][] = { "quad/fstrun.wav" }
new  
Sound_melee2[][] = { "quad/fstatk.wav" }

const 
m_pPlayer =         41
const m_flNextPrimaryAttack =     46
const m_flNextSecondaryAttack =    47
const m_flTimeWeaponIdle =     48

new cvar_pattack_ratecvar_sattack_rate

new const oldknife_sounds[][] =
{
    
"weapons/knife_deploy1.wav",    // Deploy Sound
    
"weapons/knife_hit1.wav",    // Hit 1
    
"weapons/knife_hit2.wav",    // Hit 2
    
"weapons/knife_hit3.wav",    // Hit 3
    
"weapons/knife_hit4.wav",    // Hit 4
    
"weapons/knife_hitwall1.wav",    // Hit Wall
    
"weapons/knife_slash1.wav",    // Slash 1
    
"weapons/knife_slash2.wav",    // Slash 2
    
"weapons/knife_stab.wav"    // Stab
}



new 
PLUGIN_NAME[]        = "q3 knife" 
new PLUGIN_AUTHOR[]    = "csp.admin" 
new PLUGIN_VERSION[]     = "1.0" 

static bool:g_i_status[33]

public 
plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)     
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
register_forward(FM_SetModel"fw_SetModel")
    
register_forward(FM_EmitSound"fw_EmitSound")
    
register_forward(FM_CmdStart"fw_CmdStart")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fw_Knife_PrimaryAttack_Post"1)
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fw_Knife_SecondaryAttack_Post"1)
    
cvar_pattack_rate register_cvar("q3_knife_attack1""0.2")
    
cvar_sattack_rate register_cvar("q3_knife_attack2""1.0")
   


public 
client_connect(id)
    
g_i_status[id]=false

public plugin_precache() 
{    
    
precache_model(VIEW_MODEL)     
    
precache_model(PLAYER_MODEL
    
precache_model(WORLD_MODEL)
    static 
i
    
for(0sizeof Sound_meleei++) 
    
precache_sound(Sound_melee[i])
     for(
0sizeof Sound_melee2i++)        
    
precache_sound(Sound_melee2[i])




public 
Event_CurWeapon(id
{     
    new 
weaponID read_data(2
    if(
weaponID != CSW_KNIFE)
        return 
PLUGIN_CONTINUE

    set_pev
(idpev_viewmodel2VIEW_MODEL)
    
set_pev(idpev_weaponmodel2PLAYER_MODEL)
   
    return 
PLUGIN_CONTINUE 
}


stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
    
set_pev(Playerpev_weaponanimSequence)    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player Player)
    
write_byte(Sequence)
    
write_byte(pev(Playerpev_body))
    
message_end()



public 
fw_SetModel(entitymodel[])
{
    if (!
pev_valid(entity)) 
        return 
FMRES_IGNORED

    
if (!equali(modelOLDWORLD_MODEL)) 
        return 
FMRES_IGNORED
   
    
new className[33]
    
pev(entitypev_classnameclassName32)
    
    if (
equal(className"weaponbox"/* || equal(className, "armoury_entity") */)
    {
        
engfunc(EngFunc_SetModelentityWORLD_MODEL)
        return 
FMRES_SUPERCEDE
    
}       

    return 
FMRES_IGNORED
}
 

    
public 
fw_CmdStart(idhandleseed)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED
    
        
    
if(get_user_weapon(id) != CSW_KNIFE)
        return 
FMRES_IGNORED
        
    
static iButtoniOldButtons
        iButton 
get_uc(handleUC_Buttons
        
iOldButtons pevidpev_oldbuttons )
    
         if ( ( 
iButton IN_ATTACK ) && !( iOldButtons IN_ATTACK ) ) 
 
//              emit_sound(id, CHAN_WEAPON, Sound_melee[random_num(0, sizeof Sound_melee - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)            
              
    
return FMRES_IGNORED
}





public 
fw_EmitSound(idchannel, const sound[])
{
    
// Non-player entity
    
if(!is_user_connected(id))
        return 
FMRES_IGNORED    
    
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED
        
    
// Check sound
    
for(new 0sizeof oldknife_soundsi++)
    {
        if(
equal(soundoldknife_sounds[i]))
        {                     
             
            return 
FMRES_SUPERCEDE
        
}
    }
            
    return 
FMRES_IGNORED
}


public 
fw_Knife_PrimaryAttack_Post(knife)
{    
    
    static 
id
    id 
get_pdata_cbase(knifem_pPlayer4)    
    
    if(
is_user_connected(id))
    {
        
// Get new fire rate
        
static Float:flRate
        flRate 
get_pcvar_float(cvar_pattack_rate)
        
        
// Set new rates
        
set_pdata_float(knifem_flNextPrimaryAttackflRate4)
        
set_pdata_float(knifem_flNextSecondaryAttackflRate4)
        
set_pdata_float(knifem_flTimeWeaponIdleflRate4)        
        
emit_sound(idCHAN_WEAPONSound_melee[random_num(0sizeof Sound_melee 1)], VOL_NORMATTN_NORM0PITCH_NORM)               
                 
UTIL_PlayWeaponAnimation(id2)    

    }
    
    return 
HAM_IGNORED
}

public 
fw_Knife_SecondaryAttack_Post(knife)
{    
    
// Get knife owner
    
static id
    id 
get_pdata_cbase(knifem_pPlayer4)
    
    
// has a Chainsaw
    
if(is_user_connected(id))
    {
        
// Get new fire rate
        
static Float:flRate
        flRate 
get_pcvar_float(cvar_sattack_rate)
        
        
// Set new rates
        
set_pdata_float(knifem_flNextPrimaryAttackflRate4)
        
set_pdata_float(knifem_flNextSecondaryAttackflRate4)
        
set_pdata_float(knifem_flTimeWeaponIdleflRate4)    
            
emit_sound(idCHAN_WEAPONSound_melee2[random_num(0sizeof Sound_melee2 1)], VOL_NORMATTN_NORM0PITCH_NORM)               
                
UTIL_PlayWeaponAnimation(id3)
                    
    }
    
    return 
HAM_IGNORED

__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 08-05-2011 at 08:09.
avril-lavigne is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-05-2011 , 08:58   Re: [play sound] in_ATTACK only once
Reply With Quote #6

can I block reload sound with FM_emitsound ?
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-05-2011 , 14:42   Re: [play sound] in_ATTACK only once
Reply With Quote #7

Quote:
Originally Posted by avril-lavigne View Post
can I block reload sound with FM_emitsound ?
Output all FM_EmitSound calls and see if the reload sound is played.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-05-2011 , 16:30   Re: [play sound] in_ATTACK only once
Reply With Quote #8

Also I looked into "Fire in the hole" remover plugin.
but. still I need to block ALL WEAPON/RADIO/TEXT messages from cs

it will be a huge plugin (

"silent hill" ? no , "Silent cs"


http://forums.alliedmods.net/showpos...0&postcount=12

Yes Im using it for my custom weapons.... but . what about radio sounds?
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 08-05-2011 at 16:36.
avril-lavigne is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 08-06-2011 , 03:22   Re: [play sound] in_ATTACK only once
Reply With Quote #9

finally found block money yayyyyy http://forums.alliedmods.net/showpos...47&postcount=2

but it doesnt block money icon (
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 08-06-2011 at 03:45.
avril-lavigne is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode