
   /* AMX Mod script.
   *
   * (c) Copyright 2003, OLO
   * This file is provided as is (no warranties).
   *
   *  This plugin list all the maps installed on the server, not just the
   maps in rotation
   */
   #include <amxmod>
   #include <amxmisc>
   #define HELP_LIST_AMOUNT 10
   new g_mapName[512][32]
   new g_mapNum
   public plugin_init()
   {
       register_plugin("Admin List Maps","0.9.3","default")
       register_concmd("amx_listmaps","cmdListMaps",ADMIN_MAP,"[page]   -
   lists maps on server")
       loadMapList()
       return PLUGIN_CONTINUE
   }
   loadMapList()
   {
       new iLen, pos    = 0
       while     (    g_mapNum    <    512    &&    read_dir("maps",pos++
   ,g_mapName[g_mapNum],31,iLen) )
       {
           iLen -= 4
           if (iLen > 0 && equali( g_mapName[g_mapNum][iLen] , ".bsp" ) )
           {
                   g_mapName[g_mapNum][iLen] = 0 // remove .bsp

                   if ( is_map_valid(g_mapName[g_mapNum]) )
                       g_mapNum++  //  and increase map counter if map is
   valid
           }
       }
   }
   public cmdListMaps(id,level,cid)
   {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new arg1[8]
       new start = read_argv(1,arg1,7) ? strtonum(arg1) : 1
       if (--start < 0) start = 0
       if (start >= g_mapNum) start = g_mapNum - 1
       console_print(id,"----- AMX Help: Maps -----")
       new end = start + HELP_LIST_AMOUNT
       if (end > g_mapNum) end = g_mapNum
       for (new i = start; i < end; i++)
           console_print(id,"%3d: %s",i+1,g_mapName[i])
       if (end < g_mapNum) {
               console_print(id,"-----    Entries   %i   -   %i   of   %i
   -----",start+1,end,g_mapNum)
              console_print(id,"-----  Use  'amx_listmaps  %i'  for  more
   -----",end+1)
       } else {
               console_print(id,"-----    Entries   %i   -   %i   of   %i
   -----",start+1,g_mapNum,g_mapNum)
              console_print(id,"-----  Use  'amx_listmaps  1'  for  begin
   -----")
       }
       return PLUGIN_HANDLED
   }
