AlliedModders Donor
Join Date: Jan 2012
Location: Argentina
09-16-2020
, 09:17
Pijudo: new hud menu system
#1
Well this is a menu system per hud, I always wanted to make one when I was a teenager but I did not have the capacity to do it, so I share it with you. I publish it more as a contribution than as a plugin because the idea is that it is a guide and that they make the modifications that they believe necessary in terms of menu positions and elements.
The system uses 3 dhud: 1 for the title, X for the items and 1 for the Exit, Return, Next options.
Where X depends on the content of the elements, minimum 1 DHUD.
It has support for both static menus and dynamic menus.
Natives
Spoiler
PHP Code:
#if defined _hudmenu_included #endinput #endif #define _hudmenu_included #include <amxmisc> // DON'T TOUCH const KEYSMENU = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0 ; #define hud_menu_register(%0,%1) register_menu(%0, KEYSMENU, %1, 1) // GET MENU INDEX native hud_menu_get_menu_index (const iClient ); // CREATE MENU TITLE native hud_menu_create_title (const szText [], const iRed , const iGreen , const iBlue , const Float : fPosX = 0.0 , const Float : fPosY = 0.4 ); // DESTROY MENU native hud_menu_destroy (const iClient , const iStatic ); // GET MENU PAGE native hud_menu_get_page (const iClient ); // BACK PAGE native hud_menu_back_page (const iClient ); // NEXT PAGE native hud_menu_next_page (const iClient ); // GET ITEM INDEX native hud_menu_get_selected_option (const iClient , iKey ); // GET MAX MENU ITEMS native hud_menu_get_max_items (const iMenu ); // GET MAX MENU ITEMS PER PAGE native hud_menu_get_page_max_items () // GET ITEM NAME native hud_menu_get_item_name (const iMenu , const iItem , szItem [], const iItemLenght ); // ADD ITEM TO THE MENU native hud_menu_additem (const iMenu , const szText [], const szPos [], const iRed = 255 , const iGreen = 255 , const iBlue = 255 ); // DISPLAY MENU native hud_menu_display (const iClient , const iMenu , iPage );
Example
Spoiler
PHP Code:
#include <amxmodx> #include <hudmenu> #pragma semicolon 1 new g_iStaticHudMenu ; public plugin_init (){ register_plugin ( "Testing Hud Menues" , "1.0" , "Roccoxx" ); register_clcmd ( "say probando" , "clcmdTest" ); register_clcmd ( "say probando2" , "ShowMenuPlayers" ); CreateStaticHudMenu (); } CreateStaticHudMenu (){ g_iStaticHudMenu = hud_menu_create_title ( "Quien es el más pijudo?" , 0 , 255 , 0 ); hud_menu_register ( "Quien es el más pijudo?" , "hud_menu_test" ); hud_menu_additem ( g_iStaticHudMenu , "Roccoxx" , "-" , 255 , 0 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Metita" , "2" , 0 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Manu" , "3" , 255 , 255 , 255 ); hud_menu_additem ( g_iStaticHudMenu , "Federicomb" , "4" , 0 , 0 , 255 ); hud_menu_additem ( g_iStaticHudMenu , "Metalicross" , "5" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Skylar" , "6" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Hypnotize" , "7" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Totopizza" , "8" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Matias_Esf" , "9" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Hud" , "10" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Neeeeeeeeeeeeeeeeeel.-" , "11" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Flys" , "12" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "MarioAR" , "13" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "R0ma'" , "14" , 255 , 255 , 0 ); hud_menu_additem ( g_iStaticHudMenu , "Kikizon" , "15" , 255 , 255 , 0 ); } public clcmdTest (const iClient ){ hud_menu_display ( iClient , g_iStaticHudMenu , 0 ); } public hud_menu_test ( iClient , iKey ) { if(! is_user_connected ( iClient )){ hud_menu_destroy ( iClient , 1 ); return PLUGIN_HANDLED ; } if( iKey == 9 ){ hud_menu_destroy ( iClient , 1 ); return PLUGIN_HANDLED ; } if( iKey == 7 ){ hud_menu_back_page ( iClient ); return PLUGIN_HANDLED ; } if( iKey == 8 ){ hud_menu_next_page ( iClient ); return PLUGIN_HANDLED ; } new iMenu = hud_menu_get_menu_index ( iClient ); if( iKey >= MAX_ITEMS_PER_PAGE ){ hud_menu_display ( iClient , iMenu , hud_menu_get_page ( iClient )); return PLUGIN_HANDLED ; } new iOption = hud_menu_get_selected_option ( iClient , iKey ); if( iOption >= hud_menu_get_max_items ( iMenu )){ hud_menu_display ( iClient , iMenu , hud_menu_get_page ( iClient )); return PLUGIN_HANDLED ; } new szItem [ 100 ]; hud_menu_get_item_name ( iMenu , iOption , szItem , charsmax ( szItem )); new szName [ 32 ]; get_user_name ( iClient , szName , charsmax ( szName )); client_print ( 0 , print_chat , "%s Elegio la opcion #%d: %s" , szName , iOption , szItem ); hud_menu_destroy ( iClient , 1 ); return PLUGIN_HANDLED ; } public ShowMenuPlayers (const iClient ){ new iMenu = hud_menu_create_title ( "Menu de jugadores" , 255 , 0 , 255 ); hud_menu_register ( "Menu de jugadores" , "MenuPlayers" ); new szPos [ 4 ], szName [ 32 ]; for(new i = 1 ; i <= MAX_PLAYERS ; i ++){ if(! is_user_connected ( i )) continue; get_user_name ( i , szName , charsmax ( szName )); num_to_str ( i , szPos , charsmax ( szPos )); hud_menu_additem ( iMenu , szName , szPos , 0 , 255 , 255 ); } hud_menu_display ( iClient , iMenu , 0 ); } public MenuPlayers ( iClient , iKey ) { if(! is_user_connected ( iClient )){ hud_menu_destroy ( iClient , 0 ); return PLUGIN_HANDLED ; } if( iKey == 9 ){ hud_menu_destroy ( iClient , 0 ); return PLUGIN_HANDLED ; } if( iKey == 7 ){ hud_menu_back_page ( iClient ); return PLUGIN_HANDLED ; } if( iKey == 8 ){ hud_menu_next_page ( iClient ); return PLUGIN_HANDLED ; } new iMenu = hud_menu_get_menu_index ( iClient ); if( iKey >= MAX_ITEMS_PER_PAGE ){ hud_menu_display ( iClient , iMenu , hud_menu_get_page ( iClient )); return PLUGIN_HANDLED ; } new iOption = hud_menu_get_selected_option ( iClient , iKey ); if( iOption >= hud_menu_get_max_items ( iMenu )){ hud_menu_display ( iClient , iMenu , hud_menu_get_page ( iClient )); return PLUGIN_HANDLED ; } new szItem [ 100 ]; hud_menu_get_item_name ( iMenu , iOption , szItem , charsmax ( szItem )); new szName [ 32 ]; get_user_name ( iClient , szName , charsmax ( szName )); client_print ( 0 , print_chat , "%s Elegio al jugador: %s" , szName , szItem ); hud_menu_destroy ( iClient , 0 ); return PLUGIN_HANDLED ; }
Important: the title of hud_menu_register and hud_menu_create_title must match!
Credits:
Matias_Esf -> Testing
Metalicross -> For guiding me to the game sdk to investigate the dhud
r0ma' -> For the suggestions <3
Put HudMenu.amxx before your plugins that use the menu.
Some images
GITHUB
__________________
Tutorials here (Spanish)
Like as another Pijudo said: "Tired and retired"
Quote:
Originally Posted by
Jhob94
Attach the sma to the thread
Last edited by Roccoxx; 09-16-2020 at 12:53 .