Raised This Month: $ Target: $400
 0% 

[play sound] in_ATTACK only once


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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