Raised This Month: $ Target: $400
 0% 

Menu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-29-2012 , 08:31   Re: Menu
Reply With Quote #7

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.

Last edited by Backstabnoob; 04-30-2012 at 02:29.
Backstabnoob 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 07:45.


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