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

How to get map names and add menu ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 05-14-2019 , 16:24   How to get map names and add menu ?
Reply With Quote #1

Actually the question in the title of the topic.
How can I add to the menu the entire list of maps that is available?
It can be an example without the menu itself, just through menu.additem
Hennesy is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 05-14-2019 , 16:57   Re: How to get map names and add menu ?
Reply With Quote #3

Quote:
Originally Posted by asherkin View Post
in fact, it gives me nothing. An example of how to work with this please?

Last edited by Hennesy; 05-14-2019 at 16:57.
Hennesy is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-15-2019 , 09:14   Re: How to get map names and add menu ?
Reply With Quote #4

PHP Code:
void CreateMapMenu(int client)
{
    
ArrayList array = new ArrayList(ByteCountToCells(64));
    
ReadMapList(array);
    
int length = array.Length;
    if (!
length)
    {
        
delete array;
        return;
    }

    
Menu menu = new Menu(Menu_Handler);
    
menu.SetTitle("Map Menu\n ");

    
char map[64], displayName[64];
    for (
int i 0lengthi++)
    {
        array.
GetString(imapsizeof(map));
        
GetMapDisplayName(mapdisplayNamesizeof(displayName));
        
menu.AddItem(displayNamedisplayName);
    }

    
delete array;

    
menu.Display(clientMENU_TIME_FOREVER);
}

public 
int Menu_Handler(Menu menuMenuAction actionint clientint param2)
{
    if (
action == MenuAction_Select)
    {
        
// Do stuff
    
} else if (action == MenuAction_End) {
        
delete menu;
    }

    return 
0;


Last edited by ThatKidWhoGames; 05-16-2019 at 11:42.
ThatKidWhoGames is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-15-2019 , 15:26   Re: How to get map names and add menu ?
Reply With Quote #5

Might want to change

Code:
ArrayList array = new ArrayList(64);
to
Code:
ArrayList array = new ArrayList(ByteCountToCells(64));
Also, the function GetMapDisplayName exists to resolve Workshop map names for TF2 and CS:GO for the display part of the menu. In theory, it works on other games that support workshop maps as well. If a map isn't a workshop map, it just returns the name unchanged.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-15-2019 at 15:28.
Powerlord is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-16-2019 , 11:38   Re: How to get map names and add menu ?
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
Might want to change

Code:
ArrayList array = new ArrayList(64);
to
Code:
ArrayList array = new ArrayList(ByteCountToCells(64));
Also, the function GetMapDisplayName exists to resolve Workshop map names for TF2 and CS:GO for the display part of the menu. In theory, it works on other games that support workshop maps as well. If a map isn't a workshop map, it just returns the name unchanged.
Good catch, thanks! Updated my post to reflect Powerlord's proposed changes.

Last edited by ThatKidWhoGames; 05-16-2019 at 11:42.
ThatKidWhoGames is offline
Reply


Thread Tools
Display Modes

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 02:06.


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