Raised This Month: $51 Target: $400
 12% 

Help: open menu by pressing the M key in CS:GO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alsome
New Member
Join Date: Jul 2015
Old 07-29-2015 , 16:41   Help: open menu by pressing the M key in CS:GO
Reply With Quote #1

Hi, somebody can help me to change this plugins menu... I need that when press the M key open Menu.

Is for my server CS:GO

Thanks.

author link
https://forums.alliedmods.net/showthread.php?p=637467

PHP Code:
/*
 * In-game Help Menu
 * Written by chundo ([email protected])
 *
 * Licensed under the GPL version 2 or above
 */

#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "0.3"

enum ChatCommand {
    
String:command[32],
    
String:description[255]
}

enum HelpMenuType {
    
HelpMenuType_List,
    
HelpMenuType_Text
}

enum HelpMenu {
    
String:name[32],
    
String:title[128],
    
HelpMenuType:type,
    
Handle:items,
    
itemct
}

// CVars
new Handle:g_cvarWelcome INVALID_HANDLE;
new 
Handle:g_cvarAdmins INVALID_HANDLE;

// Help menus
new Handle:g_helpMenus INVALID_HANDLE;

// Map cache
new Handle:g_mapArray INVALID_HANDLE;
new 
g_mapSerial = -1;

// Config parsing
new g_configLevel = -1;

public 
Plugin:myinfo =
{
    
name "In-game Help Menu",
    
author "chundo",
    
description "Display a help menu to users",
    
version PLUGIN_VERSION,
    
url "http://www.mefightclub.com"
};

public 
OnPluginStart() {
    
CreateConVar("sm_helpmenu_version"PLUGIN_VERSION"Help menu version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_cvarWelcome CreateConVar("sm_helpmenu_welcome""1""Show welcome message to newly connected users."FCVAR_PLUGIN);
    
g_cvarAdmins CreateConVar("sm_helpmenu_admins""1""Show a list of online admins in the menu."FCVAR_PLUGIN);
    
RegConsoleCmd("sm_helpmenu"Command_HelpMenu"Display the help menu."FCVAR_PLUGIN);

    new 
String:hc[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMhcsizeof(hc), "configs/helpmenu.cfg");
    
g_mapArray CreateArray(32);
    
ParseConfigFile(hc);

    
AutoExecConfig(false);
}

public 
OnMapStart() {
    new 
String:hc[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMhcsizeof(hc), "configs/helpmenu.cfg");
    
ParseConfigFile(hc);
}

public 
OnClientPutInServer(client) {
    if (
GetConVarBool(g_cvarWelcome))
        
CreateTimer(30.0Timer_WelcomeMessageclient);
}

public 
Action:Timer_WelcomeMessage(Handle:timerany:client) {
    if (
GetConVarBool(g_cvarWelcome) && IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
        
PrintToChat(client"\x01[SM] For help, type \x04!helpmenu\x01 in chat");
}

bool:ParseConfigFile(const String:file[]) {
    if (
g_helpMenus != INVALID_HANDLE) {
        
ClearArray(g_helpMenus);
        
CloseHandle(g_helpMenus);
        
g_helpMenus INVALID_HANDLE;
    }

    new 
Handle:parser SMC_CreateParser();
    
SMC_SetReaders(parserConfig_NewSectionConfig_KeyValueConfig_EndSection);
    
SMC_SetParseEnd(parserConfig_End);

    new 
line 0;
    new 
col 0;
    new 
String:error[128];
    new 
SMCError:result SMC_ParseFile(parserfilelinecol);
    
CloseHandle(parser);

    if (
result != SMCError_Okay) {
        
SMC_GetErrorString(resulterrorsizeof(error));
        
LogError("%s on line %d, col %d of %s"errorlinecolfile);
    }

    return (
result == SMCError_Okay);
}

public 
SMCResult:Config_NewSection(Handle:parser, const String:section[], bool:quotes) {
    
g_configLevel++;
    if (
g_configLevel == 1) {
        new 
hmenu[HelpMenu];
        
strcopy(hmenu[name], sizeof(hmenu[name]), section);
        
hmenu[items] = CreateDataPack();
        
hmenu[itemct] = 0;
        if (
g_helpMenus == INVALID_HANDLE)
            
g_helpMenus CreateArray(sizeof(hmenu));
        
PushArrayArray(g_helpMenushmenu[0]);
    }
    return 
SMCParse_Continue;
}

public 
SMCResult:Config_KeyValue(Handle:parser, const String:key[], const String:value[], bool:key_quotesbool:value_quotes) {
    new 
msize GetArraySize(g_helpMenus);
    new 
hmenu[HelpMenu];
    
GetArrayArray(g_helpMenusmsize-1hmenu[0]);
    switch (
g_configLevel) {
        case 
1: {
            if(
strcmp(key"title"false) == 0)
                
strcopy(hmenu[title], sizeof(hmenu[title]), value);
            if(
strcmp(key"type"false) == 0) {
                if(
strcmp(value"text"false) == 0)
                    
hmenu[type] = HelpMenuType_Text;
                else
                    
hmenu[type] = HelpMenuType_List;
            }
        }
        case 
2: {
            
WritePackString(hmenu[items], key);
            
WritePackString(hmenu[items], value);
            
hmenu[itemct]++;
        }
    }
    
SetArrayArray(g_helpMenusmsize-1hmenu[0]);
    return 
SMCParse_Continue;
}
public 
SMCResult:Config_EndSection(Handle:parser) {
    
g_configLevel--;
    if (
g_configLevel == 1) {
        new 
hmenu[HelpMenu];
        new 
msize GetArraySize(g_helpMenus);
        
GetArrayArray(g_helpMenusmsize-1hmenu[0]);
        
ResetPack(hmenu[items]);
    }
    return 
SMCParse_Continue;
}

public 
Config_End(Handle:parserbool:haltedbool:failed) {
    if (
failed)
        
SetFailState("Plugin configuration error");
}

public 
Action:Command_HelpMenu(clientargs) {
    
Help_ShowMainMenu(client);
    return 
Plugin_Handled;
}

Help_ShowMainMenu(client) {
    new 
Handle:menu CreateMenu(Help_MainMenuHandler);
    
SetMenuExitBackButton(menufalse);
    
SetMenuTitle(menu"Help Menu\n ");
    new 
msize GetArraySize(g_helpMenus);
    new 
hmenu[HelpMenu];
    new 
String:menuid[10];
    for (new 
0msize; ++i) {
        
Format(menuidsizeof(menuid), "helpmenu_%d"i);
        
GetArrayArray(g_helpMenusihmenu[0]);
        
AddMenuItem(menumenuidhmenu[name]);
    }
    
AddMenuItem(menu"maplist""Map Rotation");
    if (
GetConVarBool(g_cvarAdmins))
        
AddMenuItem(menu"admins""List Online Admins");
    
DisplayMenu(menuclient30);
}

public 
Help_MainMenuHandler(Handle:menuMenuAction:actionparam1param2) {
    if (
action == MenuAction_End) {
        
CloseHandle(menu);
    } else if (
action == MenuAction_Select) {
        new 
String:buf[64];
        new 
msize GetArraySize(g_helpMenus);
        if (
param2 == msize) { // Maps
            
new Handle:mapMenu CreateMenu(Help_MenuHandler);
            
SetMenuExitBackButton(mapMenutrue);
            
ReadMapList(g_mapArrayg_mapSerial"default");
            
Format(bufsizeof(buf), "Current Rotation (%d maps)\n "GetArraySize(g_mapArray));
            
SetMenuTitle(mapMenubuf);
            if (
g_mapArray != INVALID_HANDLE) {
                new 
mapct GetArraySize(g_mapArray);
                new 
String:mapname[64];
                for (new 
0mapct; ++i) {
                    
GetArrayString(g_mapArrayimapnamesizeof(mapname));
                    
AddMenuItem(mapMenumapnamemapnameITEMDRAW_DISABLED);
                }
            }
            
DisplayMenu(mapMenuparam130);
        } else if (
param2 == msize+1) { // Admins
            
new Handle:adminMenu CreateMenu(Help_MenuHandler);
            
SetMenuExitBackButton(adminMenutrue);
            
SetMenuTitle(adminMenu"Online Admins\n ");
            new 
maxc GetMaxClients();
            new 
String:aname[64];
            for (new 
1maxc; ++i) {
                if (
IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i) && (GetUserFlagBits(i) & ADMFLAG_GENERIC) == ADMFLAG_GENERIC) {
                    
GetClientName(ianamesizeof(aname));
                    
AddMenuItem(adminMenuanameanameITEMDRAW_DISABLED);
                }
            }
            
DisplayMenu(adminMenuparam130);
        } else { 
// Menu from config file
            
if (param2 <= msize) {
                new 
hmenu[HelpMenu];
                
GetArrayArray(g_helpMenusparam2hmenu[0]);
                new 
String:mtitle[512];
                
Format(mtitlesizeof(mtitle), "%s\n "hmenu[title]);
                if (
hmenu[type] == HelpMenuType_Text) {
                    new 
Handle:cpanel CreatePanel();
                    
SetPanelTitle(cpanelmtitle);
                    new 
String:text[128];
                    new 
String:junk[128];
                    for (new 
0hmenu[itemct]; ++i) {
                        
ReadPackString(hmenu[items], junksizeof(junk));
                        
ReadPackString(hmenu[items], textsizeof(text));
                        
DrawPanelText(cpaneltext);
                    }
                    for (new 
07; ++j)
                        
DrawPanelItem(cpanel" "ITEMDRAW_NOTEXT);
                    
DrawPanelText(cpanel" ");
                    
DrawPanelItem(cpanel"Back"ITEMDRAW_CONTROL);
                    
DrawPanelItem(cpanel" "ITEMDRAW_NOTEXT);
                    
DrawPanelText(cpanel" ");
                    
DrawPanelItem(cpanel"Exit"ITEMDRAW_CONTROL);
                    
ResetPack(hmenu[items]);
                    
SendPanelToClient(cpanelparam1Help_MenuHandler30);
                    
CloseHandle(cpanel);
                } else {
                    new 
Handle:cmenu CreateMenu(Help_CustomMenuHandler);
                    
SetMenuExitBackButton(cmenutrue);
                    
SetMenuTitle(cmenumtitle);
                    new 
String:cmd[128];
                    new 
String:desc[128];
                    for (new 
0hmenu[itemct]; ++i) {
                        
ReadPackString(hmenu[items], cmdsizeof(cmd));
                        
ReadPackString(hmenu[items], descsizeof(desc));
                        new 
drawstyle ITEMDRAW_DEFAULT;
                        if (
strlen(cmd) == 0)
                            
drawstyle ITEMDRAW_DISABLED;
                        
AddMenuItem(cmenucmddescdrawstyle);
                    }
                    
ResetPack(hmenu[items]);
                    
DisplayMenu(cmenuparam130);
                }
            }
        }
    }
}

public 
Help_MenuHandler(Handle:menuMenuAction:actionparam1param2) {
    if (
action == MenuAction_End) {
        
CloseHandle(menu);
    } else if (
menu == INVALID_HANDLE && action == MenuAction_Select && param2 == 8) {
        
Help_ShowMainMenu(param1);
    } else if (
action == MenuAction_Cancel) {
        if (
param2 == MenuCancel_ExitBack)
            
Help_ShowMainMenu(param1);
    }
}

public 
Help_CustomMenuHandler(Handle:menuMenuAction:actionparam1param2) {
    if (
action == MenuAction_End) {
        
CloseHandle(menu);
    } else if (
action == MenuAction_Select) {
        new 
String:itemval[32];
        
GetMenuItem(menuparam2itemvalsizeof(itemval));
        if (
strlen(itemval) > 0)
            
FakeClientCommand(param1itemval);
    } else if (
action == MenuAction_Cancel) {
        if (
param2 == MenuCancel_ExitBack)
            
Help_ShowMainMenu(param1);
    }


Last edited by alsome; 07-29-2015 at 20:08.
alsome is offline
jonitaikaponi
Senior Member
Join Date: Nov 2014
Location: Finland
Old 07-30-2015 , 07:21   Re: Help: open menu by pressing the M key in CS:GO
Reply With Quote #2

SM can only detect these keys:

PHP Code:
// These defines are for client button presses.
#define IN_ATTACK        (1 << 0)
#define IN_JUMP            (1 << 1)
#define IN_DUCK            (1 << 2)
#define IN_FORWARD        (1 << 3)
#define IN_BACK            (1 << 4)
#define IN_USE            (1 << 5)
#define IN_CANCEL        (1 << 6)
#define IN_LEFT            (1 << 7)
#define IN_RIGHT        (1 << 8)
#define IN_MOVELEFT        (1 << 9)
#define IN_MOVERIGHT        (1 << 10)
#define IN_ATTACK2        (1 << 11)
#define IN_RUN            (1 << 12)
#define IN_RELOAD        (1 << 13)
#define IN_ALT1            (1 << 14)
#define IN_ALT2            (1 << 15)
#define IN_SCORE        (1 << 16)       /**< Used by client.dll for when scoreboard is held down */
#define IN_SPEED        (1 << 17)    /**< Player is holding the speed key */
#define IN_WALK            (1 << 18)    /**< Player holding walk key */
#define IN_ZOOM            (1 << 19)    /**< Zoom key for HUD zoom */
#define IN_WEAPON1        (1 << 20)    /**< weapon defines these bits */
#define IN_WEAPON2        (1 << 21)    /**< weapon defines these bits */
#define IN_BULLRUSH        (1 << 22)
#define IN_GRENADE1        (1 << 23)    /**< grenade 1 */
#define IN_GRENADE2        (1 << 24)    /**< grenade 2 */
#define IN_ATTACK3        (1 << 25) 
And you can't bind buttons for players at least in CSGO afaik.

So that can't be done, sorry.
jonitaikaponi is offline
alsome
New Member
Join Date: Jul 2015
Old 07-30-2015 , 19:25   Re: Help: open menu by pressing the M key in CS:GO
Reply With Quote #3

Quote:
Originally Posted by jonitaikaponi View Post
SM can only detect these keys:

PHP Code:
// These defines are for client button presses.
#define IN_ATTACK        (1 << 0)
#define IN_JUMP            (1 << 1)
#define IN_DUCK            (1 << 2)
#define IN_FORWARD        (1 << 3)
#define IN_BACK            (1 << 4)
#define IN_USE            (1 << 5)
#define IN_CANCEL        (1 << 6)
#define IN_LEFT            (1 << 7)
#define IN_RIGHT        (1 << 8)
#define IN_MOVELEFT        (1 << 9)
#define IN_MOVERIGHT        (1 << 10)
#define IN_ATTACK2        (1 << 11)
#define IN_RUN            (1 << 12)
#define IN_RELOAD        (1 << 13)
#define IN_ALT1            (1 << 14)
#define IN_ALT2            (1 << 15)
#define IN_SCORE        (1 << 16)       /**< Used by client.dll for when scoreboard is held down */
#define IN_SPEED        (1 << 17)    /**< Player is holding the speed key */
#define IN_WALK            (1 << 18)    /**< Player holding walk key */
#define IN_ZOOM            (1 << 19)    /**< Zoom key for HUD zoom */
#define IN_WEAPON1        (1 << 20)    /**< weapon defines these bits */
#define IN_WEAPON2        (1 << 21)    /**< weapon defines these bits */
#define IN_BULLRUSH        (1 << 22)
#define IN_GRENADE1        (1 << 23)    /**< grenade 1 */
#define IN_GRENADE2        (1 << 24)    /**< grenade 2 */
#define IN_ATTACK3        (1 << 25) 
And you can't bind buttons for players at least in CSGO afaik.

So that can't be done, sorry.
I do not want bindear the M key, which desire is that the menu by pressing the M will be used to Select team
alsome 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 19:59.


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