Raised This Month: $ Target: $400
 0% 

How to create a slash commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mikaeel123
Senior Member
Join Date: Oct 2018
Old 03-04-2019 , 13:52   How to create a slash commands
Reply With Quote #1

Hi all . i want create a slash command little . i want admins say /w = amx_weaponmenu in console
its for easy to work . how do this ???
Mikaeel123 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-04-2019 , 14:03   Re: How to create a slash commands
Reply With Quote #2

Edit the weaponmenu plugin and add the say command there with register_clcmd calling the same function as the menu.
__________________
<VeCo> is offline
Mikaeel123
Senior Member
Join Date: Oct 2018
Old 03-04-2019 , 14:12   Re: How to create a slash commands
Reply With Quote #3

Where and use what code ??
PHP Code:
/* AMX Mod script.
*
* Weapon Menu
*  by Mattcook & xeroblood
*
* Description: Gives clients weapons via a menu.
*
* Command:
* amx_weaponmenu
*  or
* weaponmenu
*
* Example:
* 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.
*
* Credit:
* 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)
*
*/

#include <amxmodx>
#include <amxmisc>

// This is ONLY Required to Compile for AMX Mod X v1.0
// Comment or Remove to compile for AMX 0.9.9
#include <fun>


// Max Values for Building Menus
#define MAX_PLAYERS     32
#define MAX_WEAPONS     24
#define MAX_AMMO        11
#define MAX_ITEMS        8
#define MAX_DISPLAY      8

// Menu Type Indexes
#define MT_PISTOL        0
#define MT_SHOTGUN       1
#define MT_SMG           2
#define MT_RIFLE         3
#define MT_MACHINE       4
#define MT_PAMMO         5
#define MT_SAMMO         6
#define MT_EQUIP         7
#define MT_EXTRA         8

// Array Index Offsets for Pin-pointing correct weapon
#define OFFSET_SHOTGUN   6
#define OFFSET_SMG       8
#define OFFSET_RIFLE    13
#define OFFSET_MACHINE  23

// Max Menu Options for Each Menu
// (Machine Gun Menu is Only 1 Option, so no array needed for it)
#define MO_MAX_MAIN      9
#define MO_MAX_PISTOL    6
#define MO_MAX_SHOTGUN   2
#define MO_MAX_SMG       5
#define MO_MAX_RIFLE    10
#define MO_MAX_EQUIP     8
#define MO_MAX_EXTRA    14


// Main Menu Text
new g_szMainMenuTxt[MO_MAX_MAIN][] = {
"Pistols",
"Shotguns",
"SMGs",
"Rifles",
"Machine Guns",
"Primary Ammo",
"Secondary Ammo",
"Equipment",
"Extras Menu"
}

// Pistols Menu Text
new g_szPistolMenuTxt[MO_MAX_PISTOL][] = {
"USP",
"Glock",
"Deagle",
"228 Compact",
"Dual Elites",
"Five-Seven"
}

//Shotguns Section
new g_szShotgunMenuTxt[MO_MAX_SHOTGUN][] = {
"Pump Shotgun",
"Auto Shotgun"
}

//SMG Section
new g_szSmgMenuTxt[MO_MAX_SMG][] = {
"MP5",
"TMP",
"C90",
"Mac10",
"UMP"
}

//Rifles Section
new g_szRifleMenuTxt[MO_MAX_RIFLE][] = {
"Clarion",
"Krieg SG552",
"AK47",
"M4A1",
"Bullpup",
"Scout",
"AWP",
"CT AutoSniper",
"T AutoSniper",
"Galil"
}

//Machine Guns Section
new g_szMachineMenuTxt[] = "M249 (Para)"

//Equipment Section
new g_szEquipMenuTxt[MO_MAX_EQUIP][] = {
"Kevlar",
"Kevlar + Helmet",
"Flashbang Grenade",
"HE Grenade",
"Smoke Grenade",
"Defusal Kit",
"Nighvision Goggles",
"Shield"
}

//Extras Section
new g_szExtraMenuTxt[MO_MAX_EXTRA][] = {
"All Weapons",
"M3 Set",
"MP5 Navy Set",
"Clarion Set",
"Galil Set",
"M4A1 Set",
"AK47 Set",
"Krieg SG552 Set",
"Bullpup Set",
"M249 Set",
"Scout Set",
"AutoSniper Set",
"AWP Set",
"Nades Set"
}

// 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_g3sg1""weapon_sg550""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_308""ammo_556natobox"
}

new 
g_nWeaponData[MAX_WEAPONS][2] = {
  { 
0}, { 1}, { 2}, { 3}, { 1},
  { 
4}, { 5}, { 5}, { 1}, { 1},
  { 
4}, { 0}, { 0}, { 6}, { 6},
  { 
7}, { 6}, { 6}, { 7}, { 8},
  { 
7}, { 6}, { 9}, { 10}
}

// 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]


public 
plugin_init()
{
    
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" // Give Smoke Nades?  (1 = Yes, 0 = No)
    
register_cvar"sv_weaponmenu_state""1" // Weapon Menu Return State
                                                // 0 = Exit Menu After Give-Item
                                                // 1 = Return to Players Menu
                                                // 2 = Return to Weapons Menu

    
register_menucmdregister_menuid("Weapons Menu:"),      1023"MainMenuCmd" )
    
register_menucmdregister_menuid("Pistols Menu:"),      1023"RegularMenuCmd" )
    
register_menucmdregister_menuid("Shotguns Menu:"),     1023"RegularMenuCmd" )
    
register_menucmdregister_menuid("SMGs Menu:"),         1023"RegularMenuCmd" )
    
register_menucmdregister_menuid("Rifles Menu:"),       1023"RifleMenuCmd" )
    
register_menucmdregister_menuid("Machine Guns Menu:"), 1023"RegularMenuCmd" )
    
register_menucmdregister_menuid("Equipment Menu:"),    1023"RegularMenuCmd" )
    
register_menucmdregister_menuid("Extras Menu:"),       1023"ExtraMenuCmd" )
    
register_menucmdregister_menuid("Players Menu:"),      1023"PlayerMenuCmd" )

    return 
PLUGIN_CONTINUE
}

public 
ShowWeaponMenuidlvlcid )
{
    if( 
cmd_accessidlvlcid) )
    {
        
g_nMenuPosition[id-1] = 0
        ShowMainMenu
id )
    }
    return 
PLUGIN_HANDLED
}

///////////////////////////////////////////////////////////////////////////////////////////
//
//      Menu Handling Code Below
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Handles Menu Menu
public MainMenuCmdidkey )
{
    
// Track which Menu Type was chosen
    
g_nMenuType[id-1] = key

    
switch( key )
    {
        case 
0ShowPistolMenuid )
        case 
1ShowShotgunMenuid )
        case 
2ShowSmgMenuid )
        case 
3ShowRifleMenuidg_nMenuPosition[id-1] = )
        case 
4ShowMachineMenuid )
        case 
5ShowPlayerMenuidg_nMenuPosition[id-1] = )
        case 
6ShowPlayerMenuidg_nMenuPosition[id-1] = )
        case 
7ShowEquipMenuid )
        case 
8ShowExtraMenuidg_nMenuPosition[id-1] = )
        default: { 
/* Do Nothing Here (Exit Option) */ }
    }
    return 
PLUGIN_HANDLED
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Handles all Weapon Menus Except Multi-Page ones like Rifles Menu
public RegularMenuCmdidkey )
{
    
// Track which Option was chosen
    
g_nMenuOption[id-1] = key

    
switch( key )
    {
        case 
9:
        {
            
// User Chose to go Back to Previous Menu
            
ShowMainMenuid )
        }
        default: 
ShowPlayerMenuidg_nMenuPosition[id-1] = )
    }
    return 
PLUGIN_HANDLED
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Handles Multi-Page Rifles Menu
public RifleMenuCmdidkey )
{
    
// Track which Option was chosen
    
g_nMenuOption[id-1] = g_nMenuPosition[id-1] * MAX_DISPLAY key

    
switch( key )
    {
        case 
8:
        {
            
// User Selected "More..." Option
            
ShowRifleMenuid, ++g_nMenuPosition[id-1] )
        }
        case 
9:
        {
            
// User Chose to go Back to Previous Menu
            
if( g_nMenuPosition[id-1] )
            {
                
ShowRifleMenuid, --g_nMenuPosition[id-1] )
            }else
            {
                
ShowMainMenuid )
            }
        }
        default: 
ShowPlayerMenuidg_nMenuPosition[id-1] = )
    }
    return 
PLUGIN_HANDLED
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Handles Multi-Page Players Menu
public PlayerMenuCmdidkey )
{
    switch( 
key )
    {
        case 
8:
        {
            
// User Selected "More..." Option
            
ShowPlayerMenuid, ++g_nMenuPosition[id-1] )
        }
        case 
9:
        {
            
// User Chose to go Back to Previous Menu
            
if( g_nMenuPosition[id-1] )
            {
                
ShowPlayerMenuid, --g_nMenuPosition[id-1] )
            }else
            {
                
ShowMainMenuid )
            }
        }
        default:
        {
            
// Find which Player was chosen
            
new nPlayerID g_nMenuPlayers[id-1][g_nMenuPosition[id-1] * MAX_DISPLAY key]

            
// Give Player Selected Item
            
GiveMenuItemidnPlayerID )

            
// Check which Menu to Re-Open (if any)
            
switch( clamp(get_cvar_num("sv_weaponmenu_state"), 02) )
            {
                case 
1ShowPlayerMenuidg_nMenuPosition[id-1] ) // Players Menu (At Last Position)
                
case 2ShowMainMenuid // Weapons Menu
            
}
        }
    }
    return 
PLUGIN_HANDLED
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Handles Multi-Page Extras Menu
public ExtraMenuCmdidkey )
{
    
// Track which Option was chosen
    
g_nMenuOption[id-1] = g_nMenuPosition[id-1] * MAX_DISPLAY key

    
switch( key )
    {
        case 
8:
        {
            
// User Selected "More..." Option
            
ShowExtraMenuid, ++g_nMenuPosition[id-1] )
        }
        case 
9:
        {
            
// User Chose to go Back to Previous Menu
            
if( g_nMenuPosition[id-1] )
            {
                
ShowExtraMenuid, --g_nMenuPosition[id-1] )
            }else
            {
                
ShowMainMenuid )
            }
        }
        default: 
ShowPlayerMenuidg_nMenuPosition[id-1] = )
    }
    return 
PLUGIN_HANDLED
}
//
///////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////
//
//      Menu Building Code Below
//
///////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////
// Build Main Menu Section
public ShowMainMenuid )
{
    new 
inLennKeys = (1<<9)
    new 
szMenuBody[256]

    
nLen formatszMenuBody255"\yWeapons Menu:\w^n" )
    for( 
0MO_MAX_MAINi++ )
    {
        
nKeys |= (1<<i)
        
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szMainMenuTxt[i] )
    }
    
formatszMenuBody[nLen], (255-nLen), "^n0. Exit" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Pistol Menu Section
public ShowPistolMenuid )
{
    new 
inLennKeys = (1<<9)
    new 
szMenuBody[256]

    
nLen formatszMenuBody255"\yPistols Menu:\w^n" )
    for( 
0MO_MAX_PISTOLi++ )
    {
        
nKeys |= (1<<i)
        
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szPistolMenuTxt[i] )
    }
    
formatszMenuBody[nLen], (255-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Shotgun Menu Section
public ShowShotgunMenuid )
{
    new 
inLennKeys = (1<<9)
    new 
szMenuBody[256]

    
nLen formatszMenuBody255"\yShotguns Menu:\w^n" )
    for( 
0MO_MAX_SHOTGUNi++ )
    {
        
nKeys |= (1<<i)
        
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szShotgunMenuTxt[i] )
    }
    
formatszMenuBody[nLen], (255-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build SMG Menu Section
public ShowSmgMenuid )
{
    new 
inLennKeys = (1<<9)
    new 
szMenuBody[2256]

    
nLen formatszMenuBody255"\ySMGs Menu:\w^n" )
    for( 
0MO_MAX_SMGi++ )
    {
        
nKeys |= (1<<i)
        
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szSmgMenuTxt[i] )
    }
    
formatszMenuBody[nLen], (255-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Rifle Menu Section
public ShowRifleMenuidpos )
{
    if( 
pos ) return

    new 
i0nStartnEndnLennKeys = (1<<9)
    new 
szMenuBody[512]

    
nStart pos MAX_DISPLAY

    
if( nStart >= MO_MAX_RIFLE )
        
nStart pos g_nMenuPosition[id-1] = 0

    nLen 
formatszMenuBody511"\yRifles Menu:\R%d/2^n\w^n"pos )

    
nEnd nStart MAX_DISPLAY
    
if( nEnd MO_MAX_RIFLE nEnd MO_MAX_RIFLE

    
for( nStartnEndi++ )
    {
        
nKeys |= (1<<j++)
        
nLen += formatszMenuBody[nLen], (511-nLen), "%d. %s^n"jg_szRifleMenuTxt[i] )
    }

    if( 
nEnd != MO_MAX_RIFLE )
    {
        
formatszMenuBody[nLen], (511-nLen), "^n9. More...^n0. Back" )
        
nKeys |= (1<<8)
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Machine Gun Menu Section
public ShowMachineMenuid )
{
    new 
nLennKeys = (1<<0|1<<9)
    new 
szMenuBody[256]

    
nLen formatszMenuBody255"\yMachine Guns Menu:\w^n" )
    
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n"1g_szMachineMenuTxt )
    
formatszMenuBody[nLen], (255-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Equipment Menu Section
public ShowEquipMenuid )
{
    new 
inLennKeys = (1<<9)
    new 
szMenuBody[256]

    
nLen formatszMenuBody255"\yEquipment Menu:\w^n" )
    for( 
0MO_MAX_EQUIPi++ )
    {
        
nKeys |= (1<<i)
        
nLen += formatszMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szEquipMenuTxt[i] )
    }
    
formatszMenuBody[nLen], (255-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Extras Menu Section
/*
public ShowExtraMenu( id )
{
    new i, nLen, nKeys = (1<<9)
    new szMenuBody[256]

    nLen = format( szMenuBody, 255, "\yExtras Menu:\w^n" )
    for( i = 0; i < MO_MAX_EXTRA; i++ )
    {
        nKeys |= (1<<i)
        nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", (i+1), g_szExtraMenuTxt[i] )
    }
    format( szMenuBody[nLen], (255-nLen), "^n0. Back" )

    show_menu( id, nKeys, szMenuBody, -1 )
    return
}*/

public ShowExtraMenuidpos )
{
    if( 
pos ) return

    new 
i0nStartnEndnLennKeys = (1<<9)
    new 
szMenuBody[512]

    
nStart pos MAX_DISPLAY

    
if( nStart >= MO_MAX_EXTRA )
        
nStart pos g_nMenuPosition[id-1] = 0

    nLen 
formatszMenuBody511"\yExtras Menu:\R%d/2^n\w^n"pos )

    
nEnd nStart MAX_DISPLAY
    
if( nEnd MO_MAX_EXTRA nEnd MO_MAX_EXTRA

    
for( nStartnEndi++ )
    {
        
nKeys |= (1<<j++)
        
nLen += formatszMenuBody[nLen], (511-nLen), "%d. %s^n"jg_szExtraMenuTxt[i] )
    }

    if( 
nEnd != MO_MAX_EXTRA )
    {
        
formatszMenuBody[nLen], (511-nLen), "^n9. More...^n0. Back" )
        
nKeys |= (1<<8)
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody, -)
    return
}

//
///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// Build Player Menu Section
public ShowPlayerMenuidpos )
{
    if( 
pos ) return

    
get_playersg_nMenuPlayers[id-1], g_nMenuPlayersNum[id-1] )

    new 
i0idx
    
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 formatszMenuBody511"\yPlayers Menu:\R%d/%d^n\w^n", (pos+1), (g_nMenuPlayersNum[id-1] / MAX_DISPLAY + ((g_nMenuPlayersNum[id-1] % MAX_DISPLAY) ? )) )
    new 
nEnd nStart MAX_DISPLAY
    
new nKeys = (1<<9)

    if( 
nEnd g_nMenuPlayersNum[id-1] )
        
nEnd g_nMenuPlayersNum[id-1]

    for( 
nStartnEndi++ )
    {
        
idx g_nMenuPlayers[id-1][i]
        
get_user_nameidxszUserName31 )

        
nKeys |= (1<<j++)
        
nLen += formatszMenuBody[nLen], (511-nLen), "%d. %s^n"jszUserName )
    }

    if( 
nEnd != g_nMenuPlayersNum[id-1] )
    {
        
nKeys |= (1<<8)
        
formatszMenuBody[nLen], (511-nLen), "^n9. More...^n0. Back" )
    }
    else 
formatszMenuBody[nLen], (511-nLen), "^n0. Back" )

    
show_menuidnKeysszMenuBody )
    return
}
//
///////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////
//
//      Weapon Giving Code Below
//
///////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////
//  Following Functions Actually Give The Items
//
stock GiveMenuItemidp_nPlayerID )
{
    new 
szUserName[32]
    
get_user_namep_nPlayerIDszUserName31 )

    switch( 
g_nMenuType[id-1] )
    {
        case 
MT_PISTOL:  GivePlayerWeaponp_nPlayerIDg_nMenuOption[id-1] )
        case 
MT_SHOTGUNGivePlayerWeaponp_nPlayerID, (OFFSET_SHOTGUN g_nMenuOption[id-1]) )
        case 
MT_SMG:     GivePlayerWeaponp_nPlayerID, (OFFSET_SMG g_nMenuOption[id-1]) )
        case 
MT_RIFLE:   GivePlayerWeaponp_nPlayerID, (OFFSET_RIFLE g_nMenuOption[id-1]) )
        case 
MT_MACHINEGivePlayerWeaponp_nPlayerID, (OFFSET_MACHINE g_nMenuOption[id-1]) )
        case 
MT_PAMMO:   GivePrimaryAmmop_nPlayerID )
        case 
MT_SAMMO:   GiveSecondaryAmmop_nPlayerID )
        case 
MT_EQUIP:   GivePlayerItemp_nPlayerIDg_nMenuOption[id-1] )
        case 
MT_EXTRA:   GivePlayerExtrap_nPlayerIDg_nMenuOption[id-1] )
    }
    return
}


stock GivePlayerWeaponidnWeaponIdx )
{
    if( !
is_user_alive(id) || (nWeaponIdx 0) || (nWeaponIdx >= MAX_WEAPONS) )
        return 
// Invalid User or Weapon

    
give_itemidg_szWeaponList[nWeaponIdx] )
    for( new 
0g_nWeaponData[nWeaponIdx][1]; i++ )
        
give_itemidg_szAmmoList[g_nWeaponData[nWeaponIdx][0]] )

    return
}

stock GivePlayerExtraidnExtraIdx )
{
    if( !
is_user_alive(id) || (nExtraIdx 0) || (nExtraIdx >= MO_MAX_EXTRA) )
        return

    new 
ij
    
switch( nExtraIdx )
    {
        case 
0:   // Give Player All Weapons (+Ammo)
        
{
            for( 
0MAX_WEAPONSi++ )
            {
                
give_itemidg_szWeaponList[i] )
                for( 
0g_nWeaponData[i][1]; j++ )
                    
give_itemidg_szAmmoList[g_nWeaponData[i][0]] )
            }
        }
        case 
1:   // Give Player M3 Set
        
{
            
GivePlayerWeaponid)   // [6] = M3
            
GivePlayerWeaponid)   // [2] = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
2:   // Give Player MP5 Navy Set
        
{
            
GivePlayerWeaponid)   // [8] = MP5 Navy
            
GivePlayerWeaponid)   // [2] = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
3:   // Give Player Clarion Set
        
{
            
GivePlayerWeaponid13 )  // [13] = Clarion (Famas)
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
4:   // Give Player Galil Set
        
{
            
GivePlayerWeaponid22 )  // [22] = Galil
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
5:   // Give Player M4A1 Set
        
{
            
GivePlayerWeaponid16 )  // [16] = M4A1
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
6:   // Give Player AK47 Set
        
{
            
GivePlayerWeaponid15 )  // [15] = AK47
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
7:   // Give Player Krieg SG552 Set
        
{
            
GivePlayerWeaponid14 )  // [14] = Krieg SG552
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
8:   // Give Player Bullpup Set
        
{
            
GivePlayerWeaponid17 )  // [17] = Bullpup
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
9:   // Give Player M249 Set
        
{
            
GivePlayerWeaponid23 )  // [23] = M249
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
10:   // Give Player Scout Set
        
{
            
GivePlayerWeaponid16 )  // [18] = Scout
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
11:   // Give Player AutoSniper Set
        
{
            
GivePlayerWeaponid20 )    // [20] = CT AutoSniper (G3SG1)
            //GivePlayerWeapon( id, 21 )  // [21] = T AutoSniper (SG550)
            
GivePlayerWeaponid)     // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
12:   // Give Player AWP Set
        
{
            
GivePlayerWeaponid19 )  // [19] = AWP
            
GivePlayerWeaponid)   // [2]  = Deagle
            
for( 16i++ )
                
GivePlayerItemid// Kevlar, Flash/HE/Smoke Grenade, Defuse Kit
        
}
        case 
13:   // Give Player Nades Set
        
{
            for( 
25i++ )
                
GivePlayerItemid// Flash/HE/Smoke Grenades
        
}
    }
    return
}

stock GivePlayerItemidnItemIdx )
{
    if( !
is_user_alive(id) || (nItemIdx 0) || (nItemIdx >= MAX_ITEMS) )
        return 
// Invalid User or Item

    
if( (nItemIdx == 4) && (get_cvar_num("sv_weaponmenu_smoke") < 1) )
        return 
// Smoke Nades Restricted

    
if( nItemIdx == // If item is Flashbang, give it twice
        
give_itemidg_szItemsList[nItemIdx] )
    
give_itemidg_szItemsList[nItemIdx] )

    return
}

stock GivePrimaryAmmoid )
{
    new 
nWeapons[32], nNumijk
    
new szWeaponName[32]

    
// Only give Primary Ammo for Guns Carried
    
get_user_weaponsidnWeaponsnNum )
    for( 
0nNumi++ )
    {
        
get_weaponnamenWeapons[i], szWeaponName31 )
        for( 
OFFSET_SHOTGUNMAX_WEAPONSj++ )
        {
            if( 
equaliszWeaponNameg_szWeaponList[j] ) )
            {
                for( 
0g_nWeaponData[j][1]; k++ )
                    
give_itemidg_szAmmoList[g_nWeaponData[j][0]] )
            }
        }
    }
    return
}

stock GiveSecondaryAmmoid )
{
    new 
nWeapons[32], nNumijk
    
new szWeaponName[32]

    
// Only give Secondary Ammo for Pistols Carried
    
get_user_weaponsidnWeaponsnNum )
    for( 
0nNumi++ )
    {
        
get_weaponnamenWeapons[i], szWeaponName31 )
        for( 
0OFFSET_SHOTGUNj++ )
        {
            if( 
equaliszWeaponNameg_szWeaponList[j] ) )
            {
                for( 
0g_nWeaponData[j][1]; k++ )
                    
give_itemidg_szAmmoList[g_nWeaponData[j][0]] )
            }
        }
    }
    return
}
//
//
/////////////////////////////////////////////////////////////////////////////////////////// 
Mikaeel123 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-04-2019 , 14:14   Re: How to create a slash commands
Reply With Quote #4

If you want a chat command, just register new clcmd with "say /w" calling the "ShowWeaponMenu" function just like the other commands (you can do the same with "say_team /w" if you want it to work in team chat as well).
__________________

Last edited by <VeCo>; 03-04-2019 at 14:15.
<VeCo> is offline
Mikaeel123
Senior Member
Join Date: Oct 2018
Old 03-04-2019 , 14:26   Re: How to create a slash commands
Reply With Quote #5

I understood the location, but not the code
Mikaeel123 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-04-2019 , 15:16   Re: How to create a slash commands
Reply With Quote #6

You already have clcmd for the console commands. It's the same, just use "say /w" as the command.
__________________
<VeCo> is offline
thEsp
BANNED
Join Date: Aug 2017
Old 03-04-2019 , 16:24   Re: How to create a slash commands
Reply With Quote #7

Quote:
Originally Posted by Mikaeel123 View Post
I understood the location, but not the code
Ctrl + F, find the line of code. Edit it. Save and compile. Isn't this easy?
thEsp is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-04-2019 , 23:36   Re: How to create a slash commands
Reply With Quote #8

Duplicate one of the register_clcmd() lines and then replace the first string with "say /w".
__________________
fysiks is offline
thEsp
BANNED
Join Date: Aug 2017
Old 03-05-2019 , 15:05   Re: How to create a slash commands
Reply With Quote #9

You're probably trying to short the command ?
If so, it should be like this:
PHP Code:
    register_clcmd("say /w","cmdSay")
}
public 
cmdSay(id)
{
    
client_cmd(id,"amx_whatever"//command

Or if not, extend the description..
thEsp is offline
Mikaeel123
Senior Member
Join Date: Oct 2018
Old 03-06-2019 , 05:17   Re: How to create a slash commands
Reply With Quote #10

Thanks all . i understand .
Mikaeel123 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 01:30.


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