* by Mattcook & xeroblood
* Description: Gives clients weapons via a menu.
* bind "f" "amx_weaponmenu"
* Info: Weapon Menu is a re-make of my plugin Admin Weapon which gives players in the server weapons for free.
* With Weapon Menu you can give any gun to any player in the server via a menu instead of the console commands.
* xeroblood (Thank You soo much for all the help you have given me with the menu, and the plugin in general)
* F1del1ty (Thanks for the great idea of this plugin)
// This is ONLY Required to Compile for AMX Mod X v1.0
// Comment or Remove to compile for AMX 0.9.9
// Раскометируйте, чтобы при выдаче оружия происходил дроп (выброс)
// Max Values for Building Menus
// Array Index Offsets for Pin-pointing correct weapon
// Max Menu Options for Each Menu
// (Machine Gun Menu is Only 1 Option, so no array needed for it)
new g_szMainMenuTxt[MO_MAX_MAIN][] = {
"Патроны к основному оружию",
"Патроны к запасному оружию",
new g_szPistolMenuTxt[MO_MAX_PISTOL][] = {
new g_szShotgunMenuTxt[MO_MAX_SHOTGUN][] = {
new g_szSmgMenuTxt[MO_MAX_SMG][] = {
new g_szRifleMenuTxt[MO_MAX_RIFLE][] = {
new g_szMachineMenuTxt[] = "M249 (Para)"
new g_szEquipMenuTxt[MO_MAX_EQUIP][] = {
new g_szExtraMenuTxt[MO_MAX_EXTRA][] = {
// Names of Weapons for give_item() native
new g_szWeaponList[MAX_WEAPONS][] = {
"weapon_usp", "weapon_glock18", "weapon_deagle", "weapon_p228", "weapon_elite",
"weapon_fiveseven", "weapon_m3", "weapon_xm1014", "weapon_mp5navy", "weapon_tmp",
"weapon_p90", "weapon_mac10", "weapon_ump45", "weapon_famas", "weapon_sg552",
"weapon_ak47", "weapon_m4a1", "weapon_aug", "weapon_scout", "weapon_awp",
"weapon_sg550", "weapon_g3sg1", "weapon_galil", "weapon_m249"
// Names of Equipment Items for give_item() native
new g_szItemsList[MAX_ITEMS][] = {
"item_kevlar", "item_assaultsuit", "weapon_flashbang", "weapon_hegrenade",
"weapon_smokegrenade", "item_thighpack", "item_nvgs", "weapon_shield"
// Names of Ammo Packs for give_item() native
new g_szAmmoList[MAX_AMMO][] = {
"ammo_45acp", "ammo_9mm", "ammo_50ae", "ammo_357sig",
"ammo_57mm", "ammo_buckshot", "ammo_556nato", "ammo_762nato",
"ammo_338magnum", "ammo_556natobox"
new g_nWeaponData[MAX_WEAPONS][2] = {
{ 0, 8 }, { 1, 8 }, { 2, 5 }, { 3, 6 }, { 1, 4 },
{ 4, 4 }, { 5, 4 }, { 5, 4 }, { 1, 4 }, { 1, 4 },
{ 4, 4 }, { 0, 6 }, { 0, 6 }, { 6, 3 }, { 6, 3 },
{ 7, 3 }, { 6, 3 }, { 6, 3 }, { 7, 3 }, { 8, 3 },
{ 6, 3 }, { 7, 3 }, { 6, 3 }, { 9, 7 }
// Tracks what page in menu you're on in Multi-Page Menus (Like Rifles and Players Menu)
// Multiple players may open menu at same time, so we keep an array of MAX_PLAYERS (32)
// to track each individual's menu page.
// Player IDs range from 1-32 but our Array ranges from 0-31 so we minus 1 from PlayerID
// when we use this array. Example: g_nMenuPosition[ id - 1 ]
new g_nMenuPosition[MAX_PLAYERS]
// We use this to track what menu the user is actually in so we can determine which menu
// to display next. Different Menu types are: Main, Pistols, Shotguns, SMGs, Rifles, etc..
new g_nMenuType[MAX_PLAYERS]
// Tracks which option in the menu was chosen
new g_nMenuOption[MAX_PLAYERS]
// The following are used for the Players Menu to Track Player Chosen
new g_nMenuPlayers[MAX_PLAYERS][MAX_PLAYERS]
new g_nMenuPlayersNum[MAX_PLAYERS]
register_plugin( "Weapon Menu", "1.0", "Mattcook & xeroblood" )
register_clcmd( "amx_weaponmenu", "ShowWeaponMenu", ADMIN_MENU, "Shows The Weapon Menu" )
register_clcmd( "weaponmenu", "ShowWeaponMenu", ADMIN_MENU, "Shows The Weapon Menu" )
register_cvar( "sv_weaponmenu_smoke", "1" ) // Выдавать дымовые гранаты? (1 = да, 0 = нет)
register_cvar( "sv_weaponmenu_state", "1" ) // Действие после выдачи оружия
// 1 = Возврат к выбору игрока
// 2 = Возврат к выбору оружия
register_menucmd( register_menuid("Выберите экипировку:"), 1023, "MainMenuCmd" )
register_menucmd( register_menuid("Пистолеты:"), 1023, "RegularMenuCmd" )
register_menucmd( register_menuid("Дробовики:"), 1023, "RegularMenuCmd" )
register_menucmd( register_menuid("Автоматы:"), 1023, "RegularMenuCmd" )
register_menucmd( register_menuid("Винтовки:"), 1023, "RifleMenuCmd" )
register_menucmd( register_menuid("Пулемёты:"), 1023, "RegularMenuCmd" )
register_menucmd( register_menuid("Снаряжение:"), 1023, "RegularMenuCmd" )
register_menucmd( register_menuid("Дополнительно:"), 1023, "ExtraMenuCmd" )
register_menucmd( register_menuid("Кому выдать:"), 1023, "PlayerMenuCmd" )
public ShowWeaponMenu( id, lvl, cid )
if( cmd_access( id, lvl, cid, 0 ) )
g_nMenuPosition[id-1] = 0
public MainMenuCmd( id, key )
// Track which Menu Type was chosen
case 0: ShowPistolMenu( id )
case 1: ShowShotgunMenu( id )
case 2: ShowSmgMenu( id )
case 3: ShowRifleMenu( id, g_nMenuPosition[id-1] = 0 )
case 4: ShowMachineMenu( id )
case 5: ShowPlayerMenu( id, g_nMenuPosition[id-1] = 0 )
case 6: ShowPlayerMenu( id, g_nMenuPosition[id-1] = 0 )
case 7: ShowEquipMenu( id )
case 8: ShowExtraMenu( id, g_nMenuPosition[id-1] = 0 )
default: { /* Do Nothing Here (Exit Option) */ }
public RegularMenuCmd( id, key )
// Track which Option was chosen
g_nMenuOption[id-1] = key
// User Chose to go Back to Previous Menu
default: ShowPlayerMenu( id, g_nMenuPosition[id-1] = 0 )
public RifleMenuCmd( id, key )
// Track which Option was chosen
g_nMenuOption[id-1] = g_nMenuPosition[id-1] * MAX_DISPLAY + key
// User Selected "More..." Option
ShowRifleMenu( id, ++g_nMenuPosition[id-1] )
// User Chose to go Back to Previous Menu
if( g_nMenuPosition[id-1] )
ShowRifleMenu( id, --g_nMenuPosition[id-1] )
default: ShowPlayerMenu( id, g_nMenuPosition[id-1] = 0 )
public PlayerMenuCmd( id, key )
// User Selected "More..." Option
ShowPlayerMenu( id, ++g_nMenuPosition[id-1] )
// User Chose to go Back to Previous Menu
if( g_nMenuPosition[id-1] )
ShowPlayerMenu( id, --g_nMenuPosition[id-1] )
// Find which Player was chosen
new nPlayerID = g_nMenuPlayers[id-1][g_nMenuPosition[id-1] * MAX_DISPLAY + key]
// Give Player Selected Item
GiveMenuItem( id, nPlayerID )
// Check which Menu to Re-Open (if any)
switch( clamp(get_cvar_num("sv_weaponmenu_state"), 0, 2) )
case 1: ShowPlayerMenu( id, g_nMenuPosition[id-1] ) // Players Menu (At Last Position)
case 2: ShowMainMenu( id ) // Weapons Menu
public ExtraMenuCmd( id, key )
// Track which Option was chosen
g_nMenuOption[id-1] = g_nMenuPosition[id-1] * MAX_DISPLAY + key
// User Selected "More..." Option
ShowExtraMenu( id, ++g_nMenuPosition[id-1] )
// User Chose to go Back to Previous Menu
if( g_nMenuPosition[id-1] )
ShowExtraMenu( id, --g_nMenuPosition[id-1] )
default: ShowPlayerMenu( id, g_nMenuPosition[id-1] = 0 )
public ShowMainMenu( id )
new i, nLen, nKeys = (1<<9)
nLen = format( szMenuBody, 511, "\rВыберите экипировку:\w^n" )
for( i = 0; i < MO_MAX_MAIN; i++ )
nLen += format( szMenuBody[nLen], (511-nLen), "%d. %s^n", (i+1), g_szMainMenuTxt[i] )
format( szMenuBody[nLen], (511-nLen), "^n0. Выход" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowPistolMenu( id )
new i, nLen, nKeys = (1<<9)
nLen = format( szMenuBody, 255, "\rПистолеты:\w^n" )
for( i = 0; i < MO_MAX_PISTOL; i++ )
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szPistolMenuTxt[i] )
format( szMenuBody[nLen], (255-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowShotgunMenu( id )
new i, nLen, nKeys = (1<<9)
nLen = format( szMenuBody, 255, "\rДробовики:\w^n" )
for( i = 0; i < MO_MAX_SHOTGUN; i++ )
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szShotgunMenuTxt[i] )
format( szMenuBody[nLen], (255-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
new i, nLen, nKeys = (1<<9)
nLen = format( szMenuBody, 255, "\rАвтоматы:\w^n" )
for( i = 0; i < MO_MAX_SMG; i++ )
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szSmgMenuTxt[i] )
format( szMenuBody[nLen], (255-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowRifleMenu( id, pos )
new i, j = 0, nStart, nEnd, nLen, nKeys = (1<<9)
nStart = pos * MAX_DISPLAY
if( nStart >= MO_MAX_RIFLE )
nStart = pos = g_nMenuPosition[id-1] = 0
nLen = format( szMenuBody, 511, "\rВинтовки:\R%d/2^n\w^n", pos + 1 )
nEnd = nStart + MAX_DISPLAY
if( nEnd > MO_MAX_RIFLE ) nEnd = MO_MAX_RIFLE
for( i = nStart; i < nEnd; i++ )
nLen += format( szMenuBody[nLen], (511-nLen), "%d. %s^n", j, g_szRifleMenuTxt[i] )
if( nEnd != MO_MAX_RIFLE )
format( szMenuBody[nLen], (511-nLen), "^n9. Далее^n0. Назад" )
else format( szMenuBody[nLen], (511-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowMachineMenu( id )
new nLen, nKeys = (1<<0|1<<9)
nLen = format( szMenuBody, 255, "\rПулемёты:\w^n" )
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", 1, g_szMachineMenuTxt )
format( szMenuBody[nLen], (255-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowEquipMenu( id )
new i, nLen, nKeys = (1<<9)
nLen = format( szMenuBody, 255, "\rСнаряжение:\w^n" )
for( i = 0; i < MO_MAX_EQUIP; i++ )
nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szEquipMenuTxt[i] )
format( szMenuBody[nLen], (255-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowExtraMenu( id, pos )
new i, j = 0, nStart, nEnd, nLen, nKeys = (1<<9)
nStart = pos * MAX_DISPLAY
if( nStart >= MO_MAX_EXTRA )
nStart = pos = g_nMenuPosition[id-1] = 0
nLen = format( szMenuBody, 511, "\rДополнительно:\R%d/2^n\w^n", pos + 1 )
nEnd = nStart + MAX_DISPLAY
if( nEnd > MO_MAX_EXTRA ) nEnd = MO_MAX_EXTRA
for( i = nStart; i < nEnd; i++ )
nLen += format( szMenuBody[nLen], (511-nLen), "%d. %s^n", j, g_szExtraMenuTxt[i] )
if( nEnd != MO_MAX_EXTRA )
format( szMenuBody[nLen], (511-nLen), "^n9. Далее^n0. Назад" )
else format( szMenuBody[nLen], (511-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody, -1 )
public ShowPlayerMenu( id, pos )
get_players( g_nMenuPlayers[id-1], g_nMenuPlayersNum[id-1] )
new szUserName[32], szMenuBody[512]
new nStart = pos * MAX_DISPLAY
if( nStart >= g_nMenuPlayersNum[id-1] )
nStart = pos = g_nMenuPosition[id-1] = 0
new nLen = format( szMenuBody, 511, "\rКому выдать:\R%d/%d^n\w^n", (pos+1), (g_nMenuPlayersNum[id-1] / MAX_DISPLAY + ((g_nMenuPlayersNum[id-1] % MAX_DISPLAY) ? 1 : 0 )) )
new nEnd = nStart + MAX_DISPLAY
if( nEnd > g_nMenuPlayersNum[id-1] )
nEnd = g_nMenuPlayersNum[id-1]
for( i = nStart; i < nEnd; i++ )
idx = g_nMenuPlayers[id-1][i]
get_user_name( idx, szUserName, 31 )
nLen += format( szMenuBody[nLen], (511-nLen), "%d. %s^n", j, szUserName )
if( nEnd != g_nMenuPlayersNum[id-1] )
format( szMenuBody[nLen], (511-nLen), "^n9. Далее^n0. Назад" )
else format( szMenuBody[nLen], (511-nLen), "^n0. Назад" )
show_menu( id, nKeys, szMenuBody )
stock GiveMenuItem( id, p_nPlayerID )
get_user_name( p_nPlayerID, szUserName, 31 )
switch( g_nMenuType[id-1] )
case MT_PISTOL: GiveSecondaryPlayerWeapon( p_nPlayerID, g_nMenuOption[id-1] )
case MT_SHOTGUN: GivePlayerWeapon( p_nPlayerID, (OFFSET_SHOTGUN + g_nMenuOption[id-1]) )
case MT_SMG: GivePlayerWeapon( p_nPlayerID, (OFFSET_SMG + g_nMenuOption[id-1]) )
case MT_RIFLE: GivePlayerWeapon( p_nPlayerID, (OFFSET_RIFLE + g_nMenuOption[id-1]) )
case MT_MACHINE: GivePlayerWeapon( p_nPlayerID, (OFFSET_MACHINE + g_nMenuOption[id-1]) )
case MT_PAMMO: GivePrimaryAmmo( p_nPlayerID )
case MT_SAMMO: GiveSecondaryAmmo( p_nPlayerID )
case MT_EQUIP: GivePlayerItem( p_nPlayerID, g_nMenuOption[id-1] )
case MT_EXTRA: GivePlayerExtra( p_nPlayerID, g_nMenuOption[id-1] )
stock GiveSecondaryPlayerWeapon( id, nWeaponIdx )
if( !is_user_alive(id) || (nWeaponIdx < 0) || (nWeaponIdx >= 6) )
give_item( id, g_szWeaponList[nWeaponIdx] )
for( new i = 0; i < g_nWeaponData[nWeaponIdx][1]; i++ )
give_item( id, g_szAmmoList[g_nWeaponData[nWeaponIdx][0]] )
stock GivePlayerWeapon( id, nWeaponIdx )
if( !is_user_alive(id) || (nWeaponIdx < 6) || (nWeaponIdx >= MAX_WEAPONS) )
give_item( id, g_szWeaponList[nWeaponIdx] )
for( new i = 0; i < g_nWeaponData[nWeaponIdx][1]; i++ )
give_item( id, g_szAmmoList[g_nWeaponData[nWeaponIdx][0]] )
stock GivePlayerExtra( id, nExtraIdx )
if( !is_user_alive(id) || (nExtraIdx < 0) || (nExtraIdx >= MO_MAX_EXTRA) )
case 0: // Give Player All Weapons (+Ammo)
for( i = 0; i < MAX_WEAPONS; i++ )
give_item( id, g_szWeaponList[i] )
for( j = 0; j < g_nWeaponData[i][1]; j++ )
give_item( id, g_szAmmoList[g_nWeaponData[i][0]] )
case 1: // Give Player M3 Set
GivePlayerWeapon( id, 6 ) // [6] = M3
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 2: // Give Player MP5 Navy Set
GivePlayerWeapon( id, 8 ) // [8] = MP5 Navy
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 3: // Give Player Clarion Set
GivePlayerWeapon( id, 13 ) // [13] = Clarion (Famas)
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 4: // Give Player Galil Set
GivePlayerWeapon( id, 22 ) // [22] = Galil
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 5: // Give Player M4A1 Set
GivePlayerWeapon( id, 16 ) // [16] = M4A1
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 6: // Give Player AK47 Set
GivePlayerWeapon( id, 15 ) // [15] = AK47
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 7: // Give Player Krieg SG552 Set
GivePlayerWeapon( id, 14 ) // [14] = Krieg SG552
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 8: // Give Player Bullpup Set
GivePlayerWeapon( id, 17 ) // [17] = Bullpup
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 9: // Give Player M249 Set
GivePlayerWeapon( id, 23 ) // [23] = M249
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 10: // Give Player Scout Set
GivePlayerWeapon( id, 18 ) // [18] = Scout
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 11: // Give Player AutoSniper Set
GivePlayerWeapon( id, 20 ) // [20] = CT AutoSniper (G3SG1)
//GivePlayerWeapon( id, 21 ) // [21] = T AutoSniper (SG550)
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 12: // Give Player AWP Set
GivePlayerWeapon( id, 19 ) // [19] = AWP
GiveSecondaryPlayerWeapon( id, 2 ) // [2] = Deagle
GivePlayerItem( id, i ) // Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
case 13: // Give Player Nades Set
GivePlayerItem( id, i ) // Flash/HE/Smoke Grenades
stock GivePlayerItem( id, nItemIdx )
if( !is_user_alive(id) || (nItemIdx < 0) || (nItemIdx >= MAX_ITEMS) )
return // Invalid User or Item
cs_set_user_nvg(id, true)
if( (nItemIdx == 4) && (get_cvar_num("sv_weaponmenu_smoke") < 1) )
return // Smoke Nades Restricted
if( nItemIdx == 2 ) // If item is Flashbang, give it twice
give_item( id, g_szItemsList[nItemIdx] )
give_item( id, g_szItemsList[nItemIdx] )
stock GivePrimaryAmmo( id )
new nWeapons[32], nNum, i, j, k
// Only give Primary Ammo for Guns Carried
get_user_weapons( id, nWeapons, nNum )
for( i = 0; i < nNum; i++ )
get_weaponname( nWeapons[i], szWeaponName, 31 )
for( j = OFFSET_SHOTGUN; j < MAX_WEAPONS; j++ )
if( equali( szWeaponName, g_szWeaponList[j] ) )
for( k = 0; k < g_nWeaponData[j][1]; k++ )
give_item( id, g_szAmmoList[g_nWeaponData[j][0]] )
stock GiveSecondaryAmmo( id )
new nWeapons[32], nNum, i, j, k
// Only give Secondary Ammo for Pistols Carried
get_user_weapons( id, nWeapons, nNum )
for( i = 0; i < nNum; i++ )
get_weaponname( nWeapons[i], szWeaponName, 31 )
for( j = 0; j < OFFSET_SHOTGUN; j++ )
if( equali( szWeaponName, g_szWeaponList[j] ) )
for( k = 0; k < g_nWeaponData[j][1]; k++ )
give_item( id, g_szAmmoList[g_nWeaponData[j][0]] )
get_user_weapons( id, weapons, num )
for ( new i = 0; i < num; i++ )
if( ( 1<<weapons[i] ) & ( (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|
(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|
(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|
(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90) ) )
get_weaponname( weapons[i], wname, sizeof wname - 1 )
engclient_cmd( id, "drop", wname )
get_user_weapons( id, weapons, num )
for ( new i = 0; i < num; i++ )
if( ( 1<<weapons[i] ) & ( (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|
(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) ) )
get_weaponname( weapons[i], wname, sizeof wname - 1 )
engclient_cmd( id, "drop", wname )