View Single Post
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-24-2009 , 17:40   Re: weapon and ammo box
Reply With Quote #4

Here you go:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <fakemeta>
#include <fun>

#define PLUGIN "lada cu munitie"
#define AUTHOR "apocalips"
#define VERSION "0.1"

new Enable
new munitieModel[] = "models/munitie.mdl"
new aimVector[3]


public 
plugin_precache()
{
    
precache_model(munitieModel)
}



public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("munitie","lada_munitie",ADMIN_SLAY,"")
    
register_clcmd("remove","delet_munitie",ADMIN_SLAY,"")
    
register_forward(FM_Touch,"fw_touch");
    
register_menucmd(register_menuid("\yweapons:"), 1023"menu_command" );
    
Enable register_cvar("touch_enable""1");
    
set_task(3.0"touch_begin",_,_,_,"b");
    
    
}



public 
lada_munitie(id,level,cid)
{
    if (!
cmd_access(id,level,cid,1)) 
        return 
PLUGIN_HANDLED 
    
    
    
new munitieEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"func_wall"));
    
    
    
set_pev(munitieEntpev_classname"munitie");
    
get_user_origin(idaimVector3//where the player is aiming
    
    
new Float:fOrigin[3];
    
IVecFVec(aimVectorfOrigin); //covert aim origin(int) to float.
    
    
set_pev(munitieEntpev_originfOrigin);
    
    
engfunc(EngFunc_SetModelmunitieEntmunitieModel);
    
    
set_pev(munitieEnt,pev_solid,SOLID_BBOX);
    
engfunc(EngFunc_SetSizemunitieEntFloat:{-16.0, -16.0, -16.0}, Float:{16.016.016.0} )
    
    
    
    return 
PLUGIN_HANDLED
}


public 
fw_touch(ent,id)
{
    
    if(
get_pcvar_num(Enable) == 0)
        return 
FMRES_IGNORED;
    
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED;
    
    new 
classname[32]
    
pev(ent,pev_classname,classname,31)
    
    if(!
equal(classname"munitie"))  // check for kit 
        
return FMRES_IGNORED;
    
    
    new 
weapon get_user_weapon(id)
    
    
    switch(
weapon)
    {
        case 
CSW_M4A1,CSW_SG552,CSW_FAMAS,CSW_GALIL,CSW_SG550,CSW_AUGgive_item(id"ammo_556nato"); 
            case 
CSW_XM1014,CSW_M3give_item(id"ammo_buckshot");
            case 
CSW_MAC10,CSW_UMP45give_item(id"ammo_45acp");
            case 
CSW_MP5NAVY,CSW_TMPgive_item(id"ammo_9mm");
            case 
CSW_P90give_item(id"ammo_57mm");
            case 
CSW_AWPgive_item(id"ammo_338magnum");
            case 
CSW_M249give_item(id"ammo_556natobox");
            case 
CSW_G3SG1,CSW_AK47give_item(id"ammo_762nato");
            
        
        
        
        default:
    {
        
        if(
weapon == CSW_DEAGLE,CSW_FIVESEVEN,CSW_KNIFE,CSW_GLOCK18,CSW_ELITE,CSW_P228,CSW_USP
        {
            
            
            switch(
weapon)
            {
                case 
CSW_DEAGLEgive_item(id"ammo_50ae");
                    case 
CSW_P228give_item(id"ammo_357sig");
                        case 
CSW_ELITE,CSW_GLOCK18give_item(id"ammo_9mm");
                        case 
CSW_FIVESEVENgive_item(id"ammo_57mm");
                        case 
CSW_USPgive_item(id"ammo_45acp");
                        
                }
                
                
                
                
                new 
szMenuBody[256];
                new 
keys;
                
                new 
nLen formatszMenuBody255"\yweapons:^n" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w1. xm1014" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w2. aug" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w3. awp" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w4. m249" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w5. m3" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w6. m4a1" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w7. g3sg1" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w8. ak47" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n\w9. p90" );
                
nLen += formatszMenuBody[nLen], 255-nLen"^n^n\w0. Exit" );
                
                
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
                
                
show_menuidkeysszMenuBody, -);
                
server_cmd("touch_enable 0")
            }                   
        }
    }
    return 
FMRES_IGNORED;
    
}

public 
menu_command(id,key)
{
    switch( 
key )
    {
        case 
0: { 
            
give_item(id"weapon_xm1014")
            
server_cmd("touch_enable 1")      
        }
        case 
1: { 
            
give_item(id"weapon_aug")
            
server_cmd("touch_enable 1")      
        }
        case 
2: {
            
give_item(id"weapon_awp"
            
server_cmd("touch_enable 1")      
        }       
        case 
3: {
            
give_item(id"weapon_m249"
            
server_cmd("touch_enable 1")     
        }
        case 
4: {
            
give_item(id"weapon_m3")  
            
server_cmd("touch_enable 1")     
        }
        case 
5: {
            
give_item(id"weapon_m4a1"
            
server_cmd("touch_enable 1")      
        }
        case 
6: {
            
give_item(id"weapon_g3sg1"
            
server_cmd("touch_enable 1")     
        }
        case 
7: { 
            
give_item(id"weapon_ak47"
            
server_cmd("touch_enable 1")     
        }
        case 
8: {
            
give_item(id"weapon_p90")
            
server_cmd("touch_enable 1")     
        }
        
    }
}



public 
touch_begin()
{
    
    if(
get_pcvar_num(Enable) ==0)
    {
        
server_cmd("touch_enable 1")
    }
    return 
PLUGIN_HANDLED;
}


public 
delet_munitie(id,level,cid)
{    
    if (!
cmd_access(id,level,cid,1)) 
        return 
PLUGIN_HANDLED 
    
    
new ammo = -1;
    while ((
ammo fm_find_ent_by_class(ammo"munitie")))
        
engfunc(EngFunc_RemoveEntityammo);
    
    return 
FMRES_IGNORED;
    

BOYSplayCS is offline