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

View of /listmaps.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Tue Oct 30 09:08:11 2007 UTC (16 years, 5 months ago) by ian
File size: 2553 byte(s)
/*
*===============================================================================
*	Listmaps+ v0.1
*	Created by Don Juan-jello
*	http://www.jello-net.com
*	5/21/2005 4:22:27 AM
*===============================================================================
*/

/*
*	To Do:
*		Pagination of expr results
*			Cache total count for possible next page view
*			Scan entire maplist, cache line numbers of hits
*			Clear caches by timeout or new expr
*		listmap in say shows results in browser
*
*		listmaps de_						done
*		listmaps es_ #5					done
*
*		listmaps -20 +20
*		listmaps cs_ -10 +10
*		listmaps #2
*/

/*
*		Displaying maps 1-20 (cs_)
*		Displaying maps 1-20 of 400 (all)
*	 	Displaying maps 14-28 of 33 (de_)
*/

#include <amxmodx>
#include <amxmisc>

#define DISPMAX 20

public flistmaps(id){
	new mapsfile[51],map[31],arg[21],expr[21]="All Maps"
	new fsize,txtlen
	new line,page=1,pages,count=0

	//Find map cycle file
	get_configsdir(mapsfile,50)
	format(mapsfile,50,"%s%s",mapsfile,"/maps.ini")
	if(!file_exists(mapsfile)){
		mapsfile="mapcycle.txt"
		if(!file_exists(mapsfile)){
			//Return if no map cycle file found
			client_print(id,print_console,"*[AMXX] No map cycle file found.")
			return PLUGIN_HANDLED
		}
	}

	//Parse arguments
	for(new i=1;i<read_argc();i++){
		read_argv(i,arg,20)
		if(equal(arg,"#",1))page=str_to_num(arg[1])
		else expr=arg
	}

	// Display results
	fsize=file_size(mapsfile,1)-file_size(mapsfile,2)
	pages=fsize/DISPMAX
	if((fsize%DISPMAX))pages++
	page=clamp(page,1,pages)
	line=(page-1)*DISPMAX
	
	while(count<DISPMAX){
		line=read_file(mapsfile,line,map,30,txtlen)
		if(!line)break
		if(equal(expr,"All Maps") || (containi(map,expr)!=-1)){
			if(!count){
				client_print(id,print_console,"Total of %d maps in the map cycle.",fsize)
				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)
				else client_print(id,print_console,"Page %d (%s)",page,expr)
			}
			client_print(id,print_console,"%d: %s",count+1+(page-1)*DISPMAX,map)
			count++
		}
	}
	
	if(!count){
		if(page>1)client_print(id,print_console,"*[AMXX] No page that high for given expression : %s",expr)
		else client_print(id,print_console,"*[AMXX] No maps matched expression : %s",expr)
	}
	return PLUGIN_HANDLED
}

public plugin_init(){
	register_plugin("Listmaps+","0.1.2","Don Juan-jello")
	register_concmd("listmaps","flistmaps")

	return PLUGIN_CONTINUE
}

Contact
ViewVC Help
Powered by ViewVC 1.0.4