Raised This Month: $ Target: $400
 0% 

How to show sprites


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-06-2012 , 20:13   How to show sprites
Reply With Quote #1

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

#define PLUGIN    "CSPB Helmet Protection, Cheap_Suit, tmen13"
#define AUTHOR    "Cheap_Suit"
#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)

new HELMET_SOUND[] = "debris/metal6.wav"
new bool:g_has_helmet[33]

new MAX_PLAYERS;

new const SOUND[] = "misc/helmet.wav";

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")
}

public plugin_modules() {
    require_module("FakeMeta")
    require_module("cstrike")
    require_module("engine")
}
    
public plugin_precache() {
    precache_sound(HELMET_SOUND)
    precache_sound(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)
                }
            }
        }
    }
    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/helmet.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,SOUND, 1.0, ATTN_NORM, 0 , PITCH_NORM);
        }
    }
}
How to show sprites when hit the helmet?
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:29.


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