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(PLUGIN, VERSION, AUTHOR)
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_CreateNamedEntity, engfunc(EngFunc_AllocString,"func_wall"));
set_pev(munitieEnt, pev_classname, "munitie");
get_user_origin(id, aimVector, 3) //where the player is aiming
new Float:fOrigin[3];
IVecFVec(aimVector, fOrigin); //covert aim origin(int) to float.
set_pev(munitieEnt, pev_origin, fOrigin);
engfunc(EngFunc_SetModel, munitieEnt, munitieModel);
set_pev(munitieEnt,pev_solid,SOLID_BBOX);
engfunc(EngFunc_SetSize, munitieEnt, Float:{-16.0, -16.0, -16.0}, Float:{16.0, 16.0, 16.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_AUG: give_item(id, "ammo_556nato");
case CSW_XM1014,CSW_M3: give_item(id, "ammo_buckshot");
case CSW_MAC10,CSW_UMP45: give_item(id, "ammo_45acp");
case CSW_MP5NAVY,CSW_TMP: give_item(id, "ammo_9mm");
case CSW_P90: give_item(id, "ammo_57mm");
case CSW_AWP: give_item(id, "ammo_338magnum");
case CSW_M249: give_item(id, "ammo_556natobox");
case CSW_G3SG1,CSW_AK47: give_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_DEAGLE: give_item(id, "ammo_50ae");
case CSW_P228: give_item(id, "ammo_357sig");
case CSW_ELITE,CSW_GLOCK18: give_item(id, "ammo_9mm");
case CSW_FIVESEVEN: give_item(id, "ammo_57mm");
case CSW_USP: give_item(id, "ammo_45acp");
}
new szMenuBody[256];
new keys;
new nLen = format( szMenuBody, 255, "\yweapons:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. xm1014" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. aug" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w3. awp" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w4. m249" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. m3" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. m4a1" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. g3sg1" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. ak47" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. p90" );
nLen += format( szMenuBody[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_menu( id, keys, szMenuBody, -1 );
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_RemoveEntity, ammo);
return FMRES_IGNORED;
}