What other menu options would you want besides buy?
Command
ua_buymenu - Display menu to buy unlimited ammo
CVars
ua_price - Price of unlimited ammo
ua_ammochange - Controls whether or not the HUD displays a change in ammo (from Max->1 then refill back to Max). Set to 0, the HUD will always show max ammo, set to 1 the ammo value will change.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
new const Version[] = "0.1";
const MaxPlayers = 32;
const m_pActiveItem = 373;
const NoAmmoWeapons = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_SMOKEGRENADE ) |( 1 << CSW_FLASHBANG ) | ( 1 << CSW_KNIFE ) | ( 1 << CSW_C4 ) );
new const g_MaxClipAmmo[] =
{
0,
13,
0,
10,
0,
7,
0,
30,
30,
0,
15,
20,
25,
30,
35,
25,
12,
20,
10,
30,
100,
8,
30,
30,
20,
0,
7,
30,
30,
0,
50
}
new const g_szAmmoSound[] = "items/9mmclip1.wav";
new bool:g_bUnlimitedAmmo[ MaxPlayers + 1 ];
new g_pPrice;
new g_pShowAmmoChange;
public plugin_init()
{
register_plugin( "Unlimited Ammo" , Version , "bugsy" );
register_concmd( "ua_buymenu" , "ShowMenu" );
g_pPrice = register_cvar( "ua_price" , "2000" );
g_pShowAmmoChange = register_cvar( "ua_ammochange" , "0" );
if ( get_pcvar_num( g_pShowAmmoChange ) )
register_event( "CurWeapon" , "Ev_CurWeapon" , "be" , "1=1" , "3=1" );
else
register_event( "CurWeapon" , "Ev_CurWeapon" , "be" , "1=1" );
}
public plugin_precache()
{
precache_sound( g_szAmmoSound );
}
public client_disconnect( id )
{
g_bUnlimitedAmmo[ id ] = false;
}
public ShowMenu( id )
{
new szMenuItem[ 20 ];
new iMenu = menu_create( "Unlimited Ammo" , "MenuHandler" );
formatex( szMenuItem , charsmax( szMenuItem ) , "Purchase ($%d)" , get_pcvar_num( g_pPrice ) );
menu_additem( iMenu , szMenuItem );
menu_display( id , iMenu );
return PLUGIN_HANDLED;
}
public MenuHandler( id , iMenu , iItem )
{
new iMoney , iPrice;
if ( iItem == 0 )
{
if ( g_bUnlimitedAmmo[ id ] == true )
{
client_print( id , print_center , "* You already have unlimited ammo!" );
}
else
{
iMoney = cs_get_user_money( id );
iPrice = get_pcvar_num( g_pPrice );
if ( iMoney >= iPrice )
{
emit_sound( id , CHAN_AUTO , g_szAmmoSound , 1.0 , ATTN_NORM , 0 , PITCH_NORM );
cs_set_user_money( id , iMoney - iPrice , 1 );
g_bUnlimitedAmmo[ id ] = true;
}
else
{
client_print( id , print_center , "* You do not have enough money!" );
}
}
}
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
public Ev_CurWeapon( id )
{
static iWeapon; iWeapon = read_data( 2 );
if( g_bUnlimitedAmmo[ id ] && !( NoAmmoWeapons & ( 1 << iWeapon ) ) )
cs_set_weapon_ammo( get_pdata_cbase( id , m_pActiveItem ) , g_MaxClipAmmo[ iWeapon ] + 1 );
}
__________________