Raised This Month: $ Target: $400
 0% 

Sound not precached


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-14-2012 , 09:49   Re: Sound not precached
Reply With Quote #5

Here:

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, DavidJr"
#define AUTHOR    "DavidJr"
#define VERSION    "1.0"

#define HelmetKB     50.0


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

new bool:g_has_helmet[33]

new gCvarArmor;
new gCvarAmount;

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)    
    
    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")
    
    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")
}

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)
                }
            }
            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_EFFECT_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 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 ) );
        }
    }
}
Is there any slowhacking parts?

Last edited by Randomize; 05-14-2012 at 09:50.
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:24.


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