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

Solved [REQ] Plugin /maps


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JohnyS
Junior Member
Join Date: Feb 2019
Old 07-17-2022 , 11:45   [REQ] Plugin /maps
Reply With Quote #1

Hello
Can somebody help me with a plugin that imports all map names from maps.ini and display them in a menu on any user whe it writes /maps?

Last edited by JohnyS; 07-17-2022 at 19:52.
JohnyS is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-17-2022 , 13:32   Re: [REQ] Plugin /maps
Reply With Quote #2

PHP 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(szConfigsDircharsmax(szConfigsDir));

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

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

        while(
fgets(iFileszMapscharsmax(szMaps)))
        {
            
ArrayPushString(g_aMapsszMaps);
        }

        
fclose(iFile);
    }
}

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

        if(
iSize 0)
        {
            new 
szMap[64]
            
client_print(idprint_console"^n[-] Available maps [-]^n")
            for(new 
ii<iSizei++)
            {
                
ArrayGetString(g_aMapsiszMapcharsmax(szMap));
                
client_print(idprint_console"* %s"szMap);
            }

            
client_print(idprint_console"^n[-] Available maps [-]^n")
        } else 
client_print(idprint_console"^n[-] There are no available maps in the list [-]^n")

        
engclient_cmd(id"toggleconsole");
    }

lexzor is offline
JohnyS
Junior Member
Join Date: Feb 2019
Old 07-17-2022 , 15:08   Re: [REQ] Plugin /maps
Reply With Quote #3

Can you make the list into a hud menu instead of opening console? Some players clients dont accept commands sent from server and won't open the console
JohnyS is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-17-2022 , 15:36   Re: [REQ] Plugin /maps
Reply With Quote #4

PHP 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(szConfigsDircharsmax(szConfigsDir));

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

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

        while(
fgets(iFileszMapscharsmax(szMaps)))
        {
            
ArrayPushString(g_aMapsszMaps);
        }

        
fclose(iFile);
    }
}

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

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

            for(new 
ii<iSizei++)
            {
                
ArrayGetString(g_aMapsiszMapcharsmax(szMap));
                
menu_additem(iMenuszMap)
            }

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

        } else 
client_print(idprint_chat"There are no available maps in the list")
    }


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

    
mapsHandle(id);

    return 
PLUGIN_CONTINUE;

lexzor is offline
JohnyS
Junior Member
Join Date: Feb 2019
Old 07-17-2022 , 16:18   Re: [REQ] Plugin /maps
Reply With Quote #5

Got this error when i try to compile
HTML Code:
maplist.sma(63) : error 088: number of arguments does not match definition
JohnyS is offline
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
JohnyS
Junior Member
Join Date: Feb 2019
Old 07-17-2022 , 18:21   Re: [REQ] Plugin /maps
Reply With Quote #7

Now it works.
But one more question:
How to get rid of those spaces from the menu?
JohnyS is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-17-2022 , 19:26   Re: [REQ] Plugin /maps
Reply With Quote #8

PHP 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 /smaps""mapsHandle");
    
register_clcmd("say_team /smaps""mapsHandle");
    
register_clcmd("amx_maps""mapsHandle");
}

public 
plugin_end()
{
    
ArrayDestroy(g_aMaps);
}

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

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

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

        while(
fgets(iFileszMapscharsmax(szMaps)))
        {
            
ArrayPushString(g_aMapsszMaps);
        }

        
fclose(iFile);
    }
}

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

        if(
iSize 0)
        {
            new 
szMap[64], szTitle[64];
            
formatex(szTitlecharsmax(szTitle), "\yMaps\w available on server \r[%i]\w"iSize)
            new 
iMenu menu_create(szTitle"menu_handler");

            for(new 
iiSizei++)
            {
                
ArrayGetString(g_aMapsiszMapcharsmax(szMap));
                
trim(szMap);
                
menu_additem(iMenuszMap)
            }

            
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
            if(
is_user_connected(id))
                
menu_display(idiMenu0);

        } else 
client_print(idprint_chat"There are no available maps in the list")
    }


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

    
mapsHandle(id);

    return 
PLUGIN_CONTINUE;

lexzor is offline
JohnyS
Junior Member
Join Date: Feb 2019
Old 07-17-2022 , 19:51   Re: [REQ] Plugin /maps
Reply With Quote #9

It works.
Marking topic as closed.
JohnyS is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 07-18-2022 , 05:28   Re: [REQ] Plugin /maps
Reply With Quote #10

if you use map manager, when you type /maps it shows all the maps and you can choose one to nominate
tarsisd2 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 21:23.


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