Raised This Month: $ Target: $400
 0% 

A little help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-15-2022 , 19:37   Re: A little help
Reply With Quote #5

Quote:
Originally Posted by lexzor View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define FILE_NAME "menuitems.ini"

//dynamic array method
new Array:g_aMenuItems;


//double array method
#define MAX_ITEMS 10 //items num
new g_szItemsMenu[MAX_ITEMS][64];

public 
plugin_init()
{
    
g_aMenuItems ArrayCreate(64);
    
readFile()
    
register_clcmd("openMenu""open_menu");
}

public 
plugin_end()
{
    
ArrayDestroy(g_aMenuItems);
}

readFile()
{
    new 
szFile[128], szConfigsDir[64], iFile;
    
get_configsdir(szConfigsDircharsmax(szConfigsDir))
    
formatex(szFilecharsmax(szFile), "%s/%s"szConfigsDirFILE_NAME);

    if((
iFile fopen(szFile"r")) && iFile)
    {
        new 
szFileData[128], i;
        while(
fgets(iFileszFileDatacharsmax(szFileData)))
        {
            
trim(szFileData);
            if(!
szFileData[0] || szFileData[0] == ';')
                continue;

            
//dynamic array method
            
ArrayPushString(g_aMenuItemsszFileData);

            
//double array method an (index of bounds error would be thrown if you would have more than MAX_ITEMS menu items in your menu);
            
copy(g_szItemsMenu[i], charsmax(g_szItemsMenu[]), szFileData);
            
i++
        }
    }
}

public 
open_menu(id)
{
    new 
iMenu menu_create("This is my focking menu""menu_handler"), szItem[64];

    
//dynamic array method
    
for(new 0ArraySize(g_aMenuItems); i++)
    {
        
ArrayGetString(g_aMenuItemsiszItemcharsmax(szItem));
        
menu_additem(iMenuszItem);
    }
    
//

    //double array method 
    
for(new 0MAX_ITEMSi++)
    {
        if(
g_szItemsMenu[i][0] != EOS)
            
menu_additem(iMenug_szItemsMenu[i]);
    }
    
//

    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    if(
is_user_connected(id))
        
menu_display(idiMenu0, -1);
}

public 
menu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    
client_print(idprint_chat"Wow! You pressed a button!")
    
open_menu(id);

    return 
PLUGIN_CONTINUE;

what a greatfull help thank you !!
QuickDroLLL is offline
 



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 15:37.


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