Raised This Month: $51 Target: $400
 12% 

Weapon pick up add hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
666
Senior Member
Join Date: Mar 2015
Old 06-19-2019 , 12:25   Weapon pick up add hud
Reply With Quote #1

I want to add a hud to this add-on, that when the player look at the weapon to pick it up, show a hudmessage with the name of the weapon.

PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("Weapon pick up""1.04""daedhelil");
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE;
    
    static 
oldbuttons;
    
oldbuttons get_user_oldbutton(id);
    
    if(
oldbuttons IN_USE)
        return 
PLUGIN_CONTINUE;
    
    static 
buttons;
    
buttons get_user_button(id);
    
    if((
buttons IN_USE))
    {
        new 
aimOrigin[3];
        
get_user_origin(idaimOrigin3);
        
        new 
entity = -1;
        
        while((
entity find_ent_by_class(entity"weaponbox")))
        {
            new 
Float:min_weaponboxOrigin[3];
            
entity_get_vector(entityEV_VEC_absminmin_weaponboxOrigin);
            
            new 
Float:max_weaponboxOrigin[3];
            
entity_get_vector(entityEV_VEC_absmaxmax_weaponboxOrigin);
            
            new 
Float:playerOrigin[3];
            
entity_get_vector(idEV_VEC_originplayerOrigin);
            
            new 
Float:weaponboxOrigin[3];
            
entity_get_vector(entityEV_VEC_originweaponboxOrigin);
            
            new 
Float:distance get_distance_f(playerOriginweaponboxOrigin);
            if(
distance 100.0)
            {
                if(
aimOrigin[0] < max_weaponboxOrigin[0] && aimOrigin[0] > min_weaponboxOrigin[0] && aimOrigin[1] < max_weaponboxOrigin[1] && aimOrigin[1] > min_weaponboxOrigin[1])
                {
                    new 
type cs_get_weapon_by(entityEV_ENT_owner);
                    
                    switch(
type)
                    {
                        case 
35781213141518192021222324272830:
                        {
                            new 
primary cs_get_weapon_by(get_pdata_cbase(id368), EV_ENT_pContainingEntity);
                            
                            if(
primary)
                            
drop(idprimary);
                            
pick_up(identity);
                            return 
PLUGIN_CONTINUE;
                        }
                        case 
11011161726:
                        {
                            new 
secondary cs_get_weapon_by(get_pdata_cbase(id369), EV_ENT_pContainingEntity);
                            
                            if(
secondary)
                            
drop(idsecondary);
                            
pick_up(identity);
                            return 
PLUGIN_CONTINUE;
                        }
                    }
                }
            }
        }
        
entity_set_int(idEV_INT_buttonget_user_oldbutton(id) & ~IN_USE);
        
entity_set_int(idEV_INT_buttonget_user_button(id) & ~IN_USE);
    }
    return 
PLUGIN_CONTINUE;
}

pick_up(identity)
{
    new 
Float:origin[3];
    
entity_get_vector(idEV_VEC_originorigin);
    
    if(
get_user_button(id) & IN_DUCK)
        
origin[2] -= 16.0;
    else
        
origin[2] -= 36.0;
    
entity_set_origin(entityorigin);
}

drop(idweaponID)
{
    if(
weaponID 0)
    {
        new 
name[32];
        
get_weaponname(weaponIDname31);
        
engclient_cmd(id"drop"name);
    }
}

cs_get_weapon_by(entityentity_type)
{
    for(new 
32 1512; ++i)
    {
        if(
is_valid_ent(i) && entity == entity_get_edict(ientity_type))
        {
            new 
name[32];
            
entity_get_string(iEV_SZ_classnamenamesizeof name 1)
            return 
get_weaponid(name);
        }
    }
    return 
0;

__________________
666 is offline
Reply



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 06:33.


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