[Half-Life AMXX] / listmaps.sma Repository:
ViewVC logotype

Annotation of /listmaps.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /*
2 :     *===============================================================================
3 :     * Listmaps+ v0.1
4 :     * Created by Don Juan-jello
5 :     * http://www.jello-net.com
6 :     * 5/21/2005 4:22:27 AM
7 :     *===============================================================================
8 :     */
9 :    
10 :     /*
11 :     * To Do:
12 :     * Pagination of expr results
13 :     * Cache total count for possible next page view
14 :     * Scan entire maplist, cache line numbers of hits
15 :     * Clear caches by timeout or new expr
16 :     * listmap in say shows results in browser
17 :     *
18 :     * listmaps de_ done
19 :     * listmaps es_ #5 done
20 :     *
21 :     * listmaps -20 +20
22 :     * listmaps cs_ -10 +10
23 :     * listmaps #2
24 :     */
25 :    
26 :     /*
27 :     * Displaying maps 1-20 (cs_)
28 :     * Displaying maps 1-20 of 400 (all)
29 :     * Displaying maps 14-28 of 33 (de_)
30 :     */
31 :    
32 :     #include <amxmodx>
33 :     #include <amxmisc>
34 :    
35 :     #define DISPMAX 20
36 :    
37 :     public flistmaps(id){
38 :     new mapsfile[51],map[31],arg[21],expr[21]="All Maps"
39 :     new fsize,txtlen
40 :     new line,page=1,pages,count=0
41 :    
42 :     //Find map cycle file
43 :     get_configsdir(mapsfile,50)
44 :     format(mapsfile,50,"%s%s",mapsfile,"/maps.ini")
45 :     if(!file_exists(mapsfile)){
46 :     mapsfile="mapcycle.txt"
47 :     if(!file_exists(mapsfile)){
48 :     //Return if no map cycle file found
49 :     client_print(id,print_console,"*[AMXX] No map cycle file found.")
50 :     return PLUGIN_HANDLED
51 :     }
52 :     }
53 :    
54 :     //Parse arguments
55 :     for(new i=1;i<read_argc();i++){
56 :     read_argv(i,arg,20)
57 :     if(equal(arg,"#",1))page=str_to_num(arg[1])
58 :     else expr=arg
59 :     }
60 :    
61 :     // Display results
62 :     fsize=file_size(mapsfile,1)-file_size(mapsfile,2)
63 :     pages=fsize/DISPMAX
64 :     if((fsize%DISPMAX))pages++
65 :     page=clamp(page,1,pages)
66 :     line=(page-1)*DISPMAX
67 :    
68 :     while(count<DISPMAX){
69 :     line=read_file(mapsfile,line,map,30,txtlen)
70 :     if(!line)break
71 :     if(equal(expr,"All Maps") || (containi(map,expr)!=-1)){
72 :     if(!count){
73 :     client_print(id,print_console,"Total of %d maps in the map cycle.",fsize)
74 :     if(equal(expr,"All Maps"))client_print(id,print_console,"Page %d of %d: maps %d-%d (%s)",page,pages,line,min(line+DISPMAX-1,fsize),expr)
75 :     else client_print(id,print_console,"Page %d (%s)",page,expr)
76 :     }
77 :     client_print(id,print_console,"%d: %s",count+1+(page-1)*DISPMAX,map)
78 :     count++
79 :     }
80 :     }
81 :    
82 :     if(!count){
83 :     if(page>1)client_print(id,print_console,"*[AMXX] No page that high for given expression : %s",expr)
84 :     else client_print(id,print_console,"*[AMXX] No maps matched expression : %s",expr)
85 :     }
86 :     return PLUGIN_HANDLED
87 :     }
88 :    
89 :     public plugin_init(){
90 :     register_plugin("Listmaps+","0.1.2","Don Juan-jello")
91 :     register_concmd("listmaps","flistmaps")
92 :    
93 :     return PLUGIN_CONTINUE
94 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4