Thread: [Solved] [REQ] Plugin /maps
View Single Post
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 07-17-2022 , 17:46   Re: [REQ] Plugin /maps
Reply With Quote #6

Try this my dude
HTML Code:
#include <amxmodx>
#include <amxmisc>

new Array:g_aMaps;

public plugin_init()
{
    register_plugin("/maps", "1.0", "AMXX Community");

    g_aMaps = ArrayCreate(64);
    import_maps();

    register_clcmd("say /maps", "mapsHandle");
    register_clcmd("say_team /maps", "mapsHandle");
}

public plugin_end()
{
    ArrayDestroy(g_aMaps);
}

import_maps()
{
    new szConfigsDir[64], szFile[128];
    get_configsdir(szConfigsDir, charsmax(szConfigsDir));

    formatex(szFile, charsmax(szFile), "%s/maps.ini", szConfigsDir);

    if(file_exists(szFile))
    {
        new iFile = fopen(szFile, "r");
        new szMaps[64];

        while(fgets(iFile, szMaps, charsmax(szMaps)))
        {
            ArrayPushString(g_aMaps, szMaps);
        }

        fclose(iFile);
    }
}

public mapsHandle(id)
{
    if(is_user_connected(id))
    {
        new iSize = ArraySize(g_aMaps);

        if(iSize > 0)
        {
            new szMap[64], szTitle[64];
            formatex(szTitle, charsmax(szTitle), "Maps available on server \r[%i]", iSize)
            new iMenu = menu_create(szTitle, "menu_handler");

            for(new i; i<iSize; i++)
            {
                ArrayGetString(g_aMaps, i, szMap, charsmax(szMap));
                menu_additem(iMenu, szMap)
            }

            menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
            if(is_user_connected(id))
            menu_display(id, iMenu, 0);

        } else client_print(id, print_chat, "There are no available maps in the list")
    }
} 

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

    mapsHandle(id);

    return PLUGIN_CONTINUE;
}
__________________
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap