Raised This Month: $ Target: $400
 0% 

How to make the sound played


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-12-2012 , 05:42   How to make the sound played
Reply With Quote #1

Code:
/* CSPB Helmet Protectoin Plugin

Special thanks to Cheap_Suit for Ultimate Helmet, xPaw for Spawn with armor plugin and tmen13 for helmet hit sound
Remerge by DavidJr
Sprites by Fe Ar

*/

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_stocks>

#define PLUGIN    "CSPB Helmet Protection, Cheap_Suit, xPaw, tmen13, DavidJr"
#define AUTHOR    "DavidJr"
#define VERSION    "1.0"

#define HelmetKB     50.0

#define OFFSET_ARMORTYPE 112
#define fm_get_user_armor_type(%1) get_pdata_int(%1, OFFSET_ARMORTYPE)

#define TE_SPRITE                   17       

new HELMET_SOUND[] = "debris/metal6.wav"
new HELMET_EFFECT_SOUND[] = "PBKill/helmet_protection.wav";

new bool:g_has_helmet[33]

new gCvarArmor;
new gCvarAmount;

new MAX_PLAYERS;

new sprite;

public plugin_cfg()
{
    MAX_PLAYERS = get_maxplayers();
}
public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    RegisterHam(Ham_TakeDamage, "player", "playerTakeDamage");    
    
    register_plugin("Ultimate Helmet", "1.1", "Carbine/Cheap_Suit")
    register_cvar("amx_ultimate_helmet", "1")
    register_cvar("amx_ultimate_helmet_cost", "0")
    
    register_clcmd("say /buyhelmet", "HelmetBuy")
    register_clcmd("say /drophelmet", "HelmetDrop")
    
    register_concmd("buyhelmet", "HelmetBuy")
    register_concmd("drophelmet", "HelmetDrop")
    
    register_forward(FM_TraceLine, "fw_traceline", 1)
    register_event("ResetHUD", "newRound", "b")
    register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")    
    
    gCvarArmor = register_cvar( "sv_armor",    "2" );
    gCvarAmount = register_cvar( "sv_armor_amount",    "100" );
    
    RegisterHam( Ham_Spawn, "player", "fwdPlayerSpawn", 1 );
}

public plugin_modules() {
    require_module("FakeMeta")
    require_module("cstrike")
    require_module("engine")
}
    
public plugin_precache() {
    precache_sound(HELMET_SOUND)
    precache_sound(HELMET_EFFECT_SOUND)    
    precache_model("models/cspb/headgear.mdl")
    sprite = precache_model("sprites/cspb/helmet.spr") 
}

public client_putinserver(id) {
    g_has_helmet[id] = false
}

public client_disconnect(id) {
    g_has_helmet[id] = false
}

public newRound()
{
    new helmet = find_ent_by_class(-1, "helmet")
    while(helmet) {
        remove_entity(helmet)
        helmet = find_ent_by_class(helmet, "helmet")
    }
}
public HelmetBuy(id)
{
    if(client_buy(id, get_cvar_num("amx_ultimate_helmet_cost"), "Helmet") == true)  {
        client_cmd(id, "spk items/gunpickup2.wav")
        g_has_helmet[id] = true
    }
    return PLUGIN_HANDLED
}

public HelmetDrop(id)
{
    if(g_has_helmet[id] == true) {
        g_has_helmet[id] = false 
        DropHelmet(id)
    }
    else {
        client_print(id, print_chat, "[CSPB] You aren't wear a headgear")
    }
    return PLUGIN_HANDLED
}

public fw_traceline(Float:TemporarySlot1[3], Float:TemporarySlot2[3], TemporarySlot3, id) 
{
    if(!is_user_connected(id) || !is_user_alive(id)) 
        return FMRES_IGNORED
    
    new victim = get_tr(TR_pHit)
    if(!is_user_connected(victim) || !is_user_alive(victim)) 
        return FMRES_IGNORED
        
    if(get_user_team(id) == get_user_team(victim))
        return FMRES_IGNORED

    new clip, ammo
    get_user_weapon(id, clip, ammo)
    if(clip > 0)
    {
        if(get_user_button(id) & IN_ATTACK)
        {
            if(g_has_helmet[victim] == true)
            {
                new hitplace = get_tr(TR_iHitgroup)
                if(hitplace == HIT_HEAD)
                {    
                    set_tr(TR_iHitgroup, random_num(HIT_LEFTLEG, HIT_RIGHTLEG))
                    emit_sound(victim, CHAN_BODY, HELMET_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
                    entity_set_vector(victim, EV_VEC_punchangle, Float:{-HelmetKB, 0.0, HelmetKB})
                    g_has_helmet[id] = false
                    DropHelmet(victim)
                }
            }
        }
    }
    return FMRES_IGNORED
}

public player_die() 
{
    new victim = read_data(2)
    if(g_has_helmet[victim] == true) {
        g_has_helmet[victim] = false
        DropHelmet(victim)
    }
}

public pfn_touch(ptr, ptd) 
{
    if(!is_valid_ent(ptd) || !is_valid_ent(ptr))
        return PLUGIN_CONTINUE
        
    if(!is_user_connected(ptd) || !is_user_alive(ptd))
        return PLUGIN_CONTINUE

    new classname[32]
    entity_get_string(ptr, EV_SZ_classname, classname, 31)
    if(equal(classname, "helmet")) 
    {
        if(g_has_helmet[ptd] == false) 
        {
            client_cmd(ptd, "spk items/gunpickup2.wav")
            g_has_helmet[ptd] = true
            remove_entity(ptr)
        }
    }
    return PLUGIN_CONTINUE
}

stock DropHelmet(id)
{
    if(g_has_helmet[id] == true)
        g_has_helmet[id] = false

    new Float:vAim[3], Float:vOrigin[3]
    entity_get_vector(id, EV_VEC_origin, vOrigin)
    VelocityByAim(id, random_num(100, 200), vAim)

    vOrigin[0] += vAim[0]
    vOrigin[1] += vAim[1]
    vOrigin[2] += 30.0

    new helmet = create_entity("info_target")
    if(helmet > 0)
    {
        entity_set_string(helmet, EV_SZ_classname, "helmet")
        entity_set_model(helmet, "models/cspb/headgear.mdl")    
        entity_set_size(helmet, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
        entity_set_int(helmet, EV_INT_solid, 2)
        entity_set_int(helmet, EV_INT_movetype, 6)
        entity_set_vector(helmet, EV_VEC_origin, vOrigin)
    }
}

stock bool:client_buy(id, cost, item[])
{
    if(get_cvar_num("amx_ultimate_helmet") >= 1)
    {
        new money = cs_get_user_money(id)
        if(money < cost)
        {
            client_print(id, print_chat, "[CSPB Non NST] You need $%d to buy a %s", cost, item)
            return false
        }
        else if(!is_user_alive(id))
        {
            client_print(id, print_chat, "[CSPB Non NST] You must be alive to buy a %s", item)
            return false
        }
        else if(g_has_helmet[id] == true)
        {
            client_print(id, print_chat, "[CSPB Non NST] You are already has a %s", item)
            return false
        }
        else
        {
            cs_set_user_money(id, money - cost)    
            client_print(id, print_chat, "[CSPB Non NST] You bought a %s", item)
            return true
        }
        return false
    }
    else
    {
        client_print(id, print_chat, "[CSPB Non NST] Sorry, the helmet shop is not on")
        return false
    }
    return false
}
public playerTakeDamage(victim, inflictor, attacker, Float:fDamage, bitDamage) 
{
    if( (1 <= victim <= MAX_PLAYERS) && (1 <= attacker <= MAX_PLAYERS) && is_user_connected(victim))
    {
        new gun,hitZone
        get_user_attacker(victim,gun,hitZone)
                
        if( (fm_get_user_armor_type(victim) & 2) && (hitZone == HIT_HEAD))
        {
            new Float:origin[3];
            pev(victim,pev_origin,origin);
            
            EF_EmitAmbientSound(0,origin, HELMET_EFFECT_SOUND, 1.0, ATTN_NORM, 0 , PITCH_NORM);
        }
    }
}
public fwdPlayerSpawn( id ) {
    if( is_user_alive( id ) ) {
        new iPluginArmorType = clamp( get_pcvar_num( gCvarArmor ), 0, 2 );
        
        if( iPluginArmorType > 0 ) {
            new CsArmorType:iPlayerArmorType;
            new iPlayerAmount = cs_get_user_armor( id, iPlayerArmorType );
            new iPluginAmount = min( get_pcvar_num( gCvarAmount ), 0xFF );

            cs_set_user_armor( id, max( iPluginAmount, iPlayerAmount ), CsArmorType:max( iPluginArmorType, _:iPlayerArmorType ) );
        }
    }
}
public on_damage(id)
{
new origin[3];
get_user_origin(id,origin,0)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITE);
write_coord(origin[0]);
write_coord(origin[1]);
write_coord(origin[2]);
write_short(sprite);
write_byte(1);
write_byte(127);
message_end();  
}
I'd combine 2 plugin.. which one is ultimate_helmet by cheapsuit and helmet hit sound by tmen13

How to play the helmet sound when hit the helmet.. not hit the head
Randomize 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 00:27.


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