AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu (https://forums.alliedmods.net/showthread.php?t=183967)

Artifact 04-29-2012 04:47

Menu
 
I have file mape.txt wher I write maps that I want... And how to include all this maps in amxx menu?

fysiks 04-29-2012 06:12

Re: Menu
 
What do you mean? If you want them in the maps menu then put the in the mapcyclefile. If you don't want them in the mapcyclefile then use a mapchooser that has the capability to separate maps in the cycle and maps in the menu. That's the way to do it without a new custom plugin at least.

Artifact 04-29-2012 06:42

Re: Menu
 
No, no, no, I want something else...
I have eg. maps.txt file, and i in that file I have:
Code:

de_dust2
de_nuke
de_aztec
...

and I want when head admin type eg amx_getmapefile to show menu with this map, and when head choose 1 eg to server change level to de_dust2

Backstabnoob 04-29-2012 07:51

Re: Menu
 
Read the file and add each line to the menu?

Artifact 04-29-2012 07:59

Re: Menu
 
Example?

Enomine 04-29-2012 08:08

Re: Menu
 
Use 'maps *' in server console, that will show a list of all maps in maps folder, you just must to remove the .bsp at the end of each map.

If you're ussing galileo, you just need to put * in the following cvars...

Code:

gal_nom_mapfile
gal_vote_mapfile
gal_emptyserver_mapfile

Example 'gal_nom_mapfile *'

Backstabnoob 04-29-2012 08:31

Re: Menu
 
PHP Code:


#include <amxmodx>

new Array: Maps
new const file[] = "file.txt"

new g_NumElements

public plugin_init() 
{
    
    
Maps ArrayCreate64 )
    
register_plugin"LOLOLOL""ROFLROFLROFL""LOLOLOL" )
    
    new 
File fopenfile"rt" ), Temp64 ]
    
    if( !
File 
        goto 
End
        
    
while( !feofFile ) )
    {
        
fgetsFileTempcharsmaxTemp ) )
        
        if( !
Temp] || Temp] == ';' )
            continue
        
        
ArrayPushStringMapsTemp )
    }
    
    
fcloseFile )
    
    
End:    

    
g_NumElements ArraySizeMaps )
    
register_clcmd"say /maps""_c_SayMaps" )
    
}

public 
_c_SayMapsid )
{
    
    if( !
g_NumElements )
    {
        
client_printidprint_chat"No maps were added or the file was not present" )
        return 
PLUGIN_HANDLED
    
}

    new 
Menu menu_create"Maps""_m_MapsHandler" ), Temp64 ]
    
    
// please correct me if this does not work as I'm not sure
    
    
for( new CountCount g_NumElementsCount++ )
    {
        
ArrayGetStringMapsCountTempcharsmaxTemp ) )
        
menu_additemMenuTempTemp )
    }
    
    
menu_displayidMenu )
    
    return 
PLUGIN_HANDLED
}

public 
_m_MapsHandleridmenuitem )
{
    new 
TrashData64 ]
    
menu_item_getinfomenuitemTrashDataTrash__Trash )
    
    
server_cmd"changelevel %s"Data )
    
    
menu_destroymenu )

    return 
PLUGIN_HANDLED


Could be probably done with caching the whole menu in plugin_init() instead of the array though.

fysiks 04-29-2012 15:36

Re: Menu
 
Quote:

Originally Posted by Artifact (Post 1698583)
No, no, no, I want something else...

I know exactly what you want.

Quote:

Originally Posted by Artifact (Post 1698614)
Example?

All you really need to do is learn how to make menus and read files. Then you can make what you want. Read the file, make the menu with the text in the file, then change to that map when you select an option.

Quote:

Originally Posted by Enomine (Post 1698621)
Use 'maps *' in server console, that will show a list of all maps in maps folder, you just must to remove the .bsp at the end of each map.

"maps *" is a client-side command and will only show the maps in YOUR maps folder on your computer.

Artifact 04-29-2012 17:16

Re: Menu
 
fysiks I know to make simple menu, but I dont know how to include read_file in menu... :/ This is scripting help right? I need help.. :p

Backstabnoob 04-29-2012 17:29

Re: Menu
 
I wrote a clear example a while ago in case you didn't notice it.


All times are GMT -4. The time now is 07:45.

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