Raised This Month: $ Target: $400
 0% 

Making Sounds


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 07-27-2009 , 04:32   Re: Making Sounds
Reply With Quote #5

Okey i tryed to make like that plugin it didn't work i tryed to emiting the sounds here is the code:

Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

#define PLUGIN "[ZP] Class: Hunter"
#define VERSION "1.2.2"
#define AUTHOR "YKH =]"

#define i
#define hunter_attack1

new const zclass_name[] = { "Hunter" }
new const zclass_info[] = { "Can Leap" }
new const zclass_model[] = { "Hunter" }
new const zclass_clawmodel[] = { "models/v_Hunter_knife.mdl" }
const zclass_health = 200
const zclass_speed = 300
const Float:zclass_gravity = 0.8
const Float:zclass_knockback = 3.0

new const g_sound_miss[][] =
{ 
    "Sounds/L4D/Hunter_miss1.wav", 
    "Sounds/L4D/Hunter_miss2.wav" 
}

new const g_sound_hit[][] = 
{ 
    "Sounds/L4D/Hunter_strike1.wav", 
    "Sounds/L4D/Hunter_strike2.wav",
    "Sounds/L4D/Hunter_strike3.wav" 
}
new const g_sound_pain[][] =
{
    "Sounds/L4D/Hunter_pain1.wav",
    "Sounds/L4D/Hunter_pain2.wav",
    "Sounds/L4D/Hunter_pain1.wav"
}

new const g_sound_die[][] =
{
    "Sounds/L4D/Hunter_die1.wav",
    "Sounds/L4D/Hunter_die2.wav",
    "Sounds/L4D/Hunter_die3.wav"
}

new g_zclass_LongJump, g_LongJump_force, g_LongJump_height, cvar_cooldown
new Float:g_lastleaptime[33] // time leap was last used

public plugin_init()
{
    register_cvar("zp_zclass_leap_zombie",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
    register_forward(FM_EmitSound, "fw_EmitSound")
    g_LongJump_force = register_cvar("zp_zclass_leap_force", "600")
    g_LongJump_height = register_cvar("zp_zclass_leap_height", "245")
    cvar_cooldown = register_cvar("zp_leap_cooldown", "1.5")
    
    register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
}

public plugin_precache()
{
    g_zclass_LongJump = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)

    new iNum
    for (iNum = 0; iNum < sizeof g_sound_miss; iNum++)
        engfunc(EngFunc_PrecacheSound, g_sound_miss[iNum])
    for (iNum = 0; iNum < sizeof g_sound_hit; iNum++)
        engfunc(EngFunc_PrecacheSound, g_sound_hit[iNum])
    for (iNum = 0; iNum < sizeof g_sound_pain; iNum++)
        engfunc(EngFunc_PrecacheSound, g_sound_pain[iNum])
    for (iNum = 0; iNum < sizeof g_sound_die; iNum++)
        engfunc(EngFunc_PrecacheSound, g_sound_die[iNum])
    for (iNum = 0; iNum < sizeof ZOMBIE_FLESH; iNum++)
        engfunc(EngFunc_PrecacheModel, ZOMBIE_FLESH[iNum])
}

public zp_user_infected_post(player, infector)
{
    if (zp_get_user_zombie_class(player) == g_zclass_LongJump)
    {
        client_print(player, print_chat, "[ZP] Duck and press E to use leap !")    
    }
    return PLUGIN_CONTINUE
}

public fw_PlayerPreThink(id)
{
    if (!is_user_alive(id))
        return
        
    if (allowed_LongJump(id))
    {
        static Float:velocity[3]
        velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
        
        velocity[2] = get_pcvar_float(g_LongJump_height)
        
        set_pev(id, pev_velocity, velocity)

        // Set the current leap time
        g_lastleaptime[id] = get_gametime()
    }
}

public fw_EmitSound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
{
    if(!is_user_connected(id) || !g_zombie[id])
        return FMRES_IGNORED
        
    //KNIFE
    if (sample[0] == 'w' && sample[1] == 'e' && sample[8] == 'k' && sample[9] == 'n')
    {
        switch(sample[17])
        {
            case 'l': 
                return FMRES_SUPERCEDE
                
            case 's', 'w':
            {
                emit_sound(id, CHAN_WEAPON, g_sound_miss[random(sizeof g_sound_miss)], volume, attn, flag, pitch)
                return FMRES_SUPERCEDE
            }
            
            case 'b', '1', '2', '3', '4':
            {
                emit_sound(id, CHAN_WEAPON, g_sound_hit[random(sizeof g_sound_hit)], volume, attn, flag, pitch)
                return FMRES_SUPERCEDE
            }
        }
    }
    //PAIN
    else if (sample[1] == 'l' && sample[2] == 'a' && sample[3] == 'y' && ( (containi(sample, "bhit") != -1) || (containi(sample, "pain") != -1) || (containi(sample, "shot") != -1)))
    {
        emit_sound(id, CHAN_VOICE, g_sound_pain[random(sizeof g_sound_pain)], volume, attn, flag, pitch)
        return FMRES_SUPERCEDE
    }        
    //DEATH
    else if (sample[7] == 'd' && (sample[8] == 'i' && sample[9] == 'e' || sample[12] == '6'))
    {
        emit_sound(id, CHAN_VOICE, g_sound_die[random(sizeof g_sound_die)], volume, attn, flag, pitch)
        return FMRES_SUPERCEDE
    }    

allowed_LongJump(id)
{    
    if (!zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
        return false

    if (zp_get_user_zombie_class(id) != g_zclass_LongJump)
        return false
         
    if (!((pev(id, pev_flags) & FL_ONGROUND) && (pev(id, pev_flags) & FL_DUCKING)) || fm_get_speed(id) < 10)
        return false
    
    static buttons
    buttons = pev(id, pev_button)
    
    // Not doing a longjump (added bot support)
    if (!(buttons & IN_USE) && !is_user_bot(id))
        return false

    // Get cooldown cvar
    static Float:cooldown
    cooldown = get_pcvar_float(cvar_cooldown)

    // Cooldown not over yet
    if (get_gametime() - g_lastleaptime[id] < cooldown)
        return false
        
    return true
}

Last edited by DoviuX; 07-27-2009 at 04:43.
DoviuX is offline
Send a message via Skype™ to DoviuX
 



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 18:25.


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