
 ////////////////////////////////////////////////
 //     ___      _                         _   //
 //    / _ \___ | | _____  /\/\   ___   __| |  //
 //   / /_)/ _ \| |/ / _ \/    \ / _ \ / _` |  //
 //  / ___/ (_) |   <  __/ /\/\ \ (_) | (_| |  //
 // /_/    \___/|_|\_\___\/    \/\___/ \__,_|  //
 //          by Raky2                          //
 ////////////////////////////////////////////////
 //                                            //
 //      Welcome to The World of Pokemon.      //
 //                                            //
 ////////////////////////////////////////////////
 
 /*
 //--ChangeLog--//
 *	v1.2.3 RC - 05/27/08
 *							- Dropped skill forwards
 *							- Converted skill system to prepare for 1.3.0
 *							- Seperated skills into more files
 *							- Added maxarmor capabilities
 *							- Updated pokemod.inc
 *							- Converted some file natives to new file natives
 *							- Adjusted pokemon skills to damage based on skill type instead of pokemon type
 *							- Added functionality to change how skills are activated
 *							- Fixed potential bug when exiting Bill's PC
 *							- Every skill should be able to be global with new system
 *							- Added some more important debug messages
 *							- Changed the items.cfg file a little bit
 *							- Fixed small bug in pokemart that would show all categories
 *							- Renamed Bill's PC to Emp`s PC
 *							- Fixed bug where safari file would stay open
 *							- Can now change starting pokemon
 *							- Dropped support for other plugins with speed (got too complicated)
 *							- Added functions for skill damage for more universal use
 *							- Changed how delays after pokeskills work
 *							- Minor code improvements
 *							- Fixed being able to manually activate non-bind skills
 *							- Converted sprite system to match sounds and models
 *							- Added random player round saving
 *							- Fixed not being able to do command 'pokemod debug off'
 *							- Renamed config.inl to files.inl
 *							- Made find_free_spawn function more efficient
 *							- When doing 'pokemod' in console and the server is missing files, it will now list the files
 *							- Fixed define POKEBALL_SPECIAL
 *							- Redid pokedex
 *							- Made help menu smarter
 *							- Made pokedex smarter
 *							- Redid pokeitem help
 *							- Fixed problem where last pokemon's name would not be picked up
 *							- Changed NightShade to not go below MIN_INVIS
 *							- Finished all default pokemon
 *							- Fixed problem with round start being called at the wrong time with freezetime
 *							- Fixed problem when admins erased all experience
 *							- Burn will now catch all players on fire (not just teammates)
 *							- Added smarter item searching
 *							- Fixed problem with paralysis
 *							- Can no longer release or give away your active pokemon
 *							- Fixed bug where you would try to catch pokemon with items that can't catch
 *							- Fixed problem with many fake natives
 *							- Fixed problem with picking up the first registered item
 *							- Added flexibility to interact with EAM
 *							- Fixed Start Menu not working if you were assigned a pokemon
 *							- Redid menu code
 *	v1.2.2 - 02/01/08
 *							- Dropped hamsandwich module and added back fun module
 *							- Fixed and cleaned AoEdamage and Linedamage
 *							- Fixed speed issue that was occuring
 *	v1.2.1 - 01/26/08
 *							- Fixed fire status
 *							- Fixed harden skill
 *							- Fixed menus not working occasionally
 *							- Fixed mist and sky attack not displaying in correct position
 *							- Redid type system to prepare for 1.3.0
 *							- Added status effects for normal pokedamage function
 *							- Redid how status effects are calculated in pokedamage
 *							- Added type None
 *							- Added prefix TYPE_ to the type defines/enum
 *							- Redid admin commands
 *							- Fixed weird damages with AoE and Line damage
 *							- Dropped engine module, now uses fakemeta_util
 *							- Dropped fun module, now uses fakemeta and hamsandwich
 *							- Removed time include
 *							- Now requires Hamsandwich module
 *							- Fixed rock slide skill
 *							- Bots now release pokemon randomly
 *							- Fixed global skills being able to be done twice
 *							- Fixed dodrio
 *
 *	v1.2.0 - 12/24/07
 *							- Seperated into smaller files
 *							- Added xp and lvls
 *							- Added more pokemon
 *							- And a lot more (for full list, check PokeMod forums)
 *							- Now requires AMXX 1.8 or greater
 *
 *	v1.1.1 - 07/06/06
 *							- Fixed some things
 *							- Added some cvars
 *							- Cleaned code
 *							- Made a little bit ready for when lvls and xp are added
 *
 *	v1.1.0 - 06/29/06
 *							- Redid menus
 *							- Added more pokemon (33 in total)
 *							- Cleaned code
 *							- Changed cvars to pcvars
 *							- Now requires AMXX 1.71 or greater
 *
 *	v1.0.1 - Never Released
 *							- Fixed some stuff
 *							- Cleaned code
 *							- Added more cvars
 *
 *	v1.0.0 - 01/15/06
 *							- Released to the public
 *
 //--Credits--//
 *	- RockThrow				- modified sprites and sounds code from yang's Veronika hero
 *	- Teleport				- used PassAimTest code from sharky / JTP10181 's Batgirl hero
 *	- Flamethrower			- modified Cheap_Suit's flamethrower
 *							- KoST - for the get_distance_to_line stock
 *							- VEN - for his fm_is_ent_visible stock
 *	- PsyBeam				- based on vittu's SSJ Gohan hero
 *	- SmokeScreen			- made by Om3gA
 *
 *	- Config files			- based on superheromod's
 *	- XP Save key			- based on superheromod's
 *	- Sounds				- used some sounds from FFX mod
 *	- Models				- used Prof. Oak model from old abandoned Pokemon Mod for Half-Life
 *							- original pokeball made by Emp`, fixed by Om3gA
 *							- bone model made by coca-cola
 *	- PokeLoop				- used loop code from {HOJ} Batman/JTP10181 's Captain America hero
 *	- NPCs					- used Twilight Suzuka's NPC guide
 *	- MYSQL Saving			- Superhero Mod
 *	- SQLx Saving			- Teame06
 *	- Dynamic Natives		- help from Hawk552
 *	- Other					- modified mole code from WC3FT mod
 *							- is_user_outside stock from timer16 by Twilight Suzuka
 *
 *		- Anything not listed here was most likely done by Emp`
 *
 //--To Do--//
 *	- Personal colored huds
 *	- PP points
 *	- Read files rather than having defines
 *	- Personal Pokemon Names
 *	- Pokemon skill selection
 *	- Dynamic skill properties
 *	- Dynamic statuses
 *	- More fake natives
 */





	////////////////////////////////////////////////////
	//        DO NOT CHANGE ANYTHING IN HERE!         //
	//      Things for customizing your server        //
	//            have been moved to the              //
	//       custom.inl and skill_defines.inl         //
	////////////////////////////////////////////////////





 #if defined _pokemod_plugin_included
	#endinput
 #endif
 #define _pokemod_plugin_included

 //Lets increase the memory
 #pragma dynamic 32768

 //Change the stupid escape character to the normal one
 #pragma ctrlchar '\'

 //Lets load some libraries
 #include <amxmisc>
 #include <fakemeta_util>
 #include <fun>
 #include <xs>

 #if AMXX_VERSION_NUM < 180
	#assert _____\
			PokeMod requires AMXX 1.8 or higher and must be compiled locally!\
			_____
 #endif

 //PokeMod includes
 #tryinclude "pokemon/custom.inl"	//gotta include these first because its used in the other files
 #tryinclude "pokemon/defines.inl"

 #if !defined _pokemod_custom_included || !defined _pokemod_defines_included
	#assert _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \
			_ _ _ _ _ _ _ _ _ _ _ PokeMod must be compiled locally! _ _ _ _ _ _ _ _ _ _ _ \
			_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 #endif

 #if MOD==CS
	#include <cstrike>
 #endif
 #if MOD==DOD
	#include <dodfun>
	#include <dodx>
 #endif
 #if MOD==NS
	#include <ns>
 #endif

 #if SAVE==SAVE_MYSQL
	#include <dbi>
 #endif
 #if SAVE==SAVE_SQLX
	#include <sqlx>
 #endif
 #if SAVE==SAVE_NVAULT
	#include <nvault>
 #endif
 
 #include "pokemon/skill_defines.inl"
 #include "pokemon/globals.inl"
 #include "pokemon/other.inl"

 #include "pokemon/admin.inl"
 #include "pokemon/bot.inl"
 #include "pokemon/items.inl"
 #include "pokemon/checks.inl"
 #include "pokemon/eam.inl"
 #include "pokemon/evolution.inl"
 #include "pokemon/files.inl"
 #include "pokemon/helps.inl"
 #include "pokemon/menus.inl"
 #include "pokemon/mod_specific.inl"
 #include "pokemon/natives.inl"
 #include "pokemon/oak.inl"
 #include "pokemon/pokedamage.inl"
 #include "pokemon/pokerank.inl"
 #include "pokemon/publics.inl"
 #include "pokemon/registers.inl"
 #include "pokemon/skills.inl"
 #include "pokemon/status.inl"
 #include "pokemon/stocks.inl"
 #include "pokemon/xp.inl"
 

 /////////////////////
 //  Starts plugin  //
 /////////////////////
 public plugin_init()
 {
	plugin_id = register_plugin(PLUGNAME, VERSION, AUTHOR);

	//lets register the most important things first (incase pokemod was disabled)

	set_pcvar_string( register_cvar("PokeMod_Version",VERSION,FCVAR_SERVER|FCVAR_SPONLY), VERSION );

	register_concmd("pokemod","Console_Pokemod",ADMIN_ALL, "- information about PokeMod");
	register_concmd("pm","Console_Pokemod");

	//Client Say Commands
	register_clcmd("say","HandleSay");

	//if pokemod was disabled, we don't need to waste server resources
	if(PM_disabled==1)
		return;

	cvar_registry();

	//Events
	#if MOD==CS
		register_event("Damage", "pokemon_damage", "b", "2!0");
		register_event("HLTV", "round_start", "a", "1=0", "2=0");
		register_logevent("poke_round_end", 2, "1=Round_End");
		register_logevent("poke_round_end", 2, "1&Restart_Round_");
		register_event("StatusText", "pokemon_statustext", "b");
		register_event("ResetHUD", "pokemon_spawn", "b");
		register_event("Money", "pokemon_money", "b");
	#else
		#if MOD==DOD
			register_event("RoundState", "poke_round_end", "a", "1=3", "1=4");
		#endif
		#if MOD==NS
			register_event("Damage", "pokemon_damage", "b", "2!0");
		#endif
		register_event("ResetHUD", "team_ready", "b");
	#endif
	register_event("DeathMsg", "pokemon_death", "a");
	register_event("CurWeapon", "WeaponChange", "be", "1=1");
	register_forward(FM_Touch, "touches");

	#if CHANGE_GAME_NAME==1
	register_forward(FM_GetGameDescription,"GameDesc");
	#endif
	register_forward(FM_AlertMessage, "log_block");

	//Loop every second
	set_task(1.0, "pokemon_loop", 0, "", 0, "b");

	debugMessage( 0,7,"done registering events" );

	//Client Console Commands
	register_clcmd("+pokeskill","pokeskill_down", _, "- uses pokemon bind skill");
	register_clcmd("-pokeskill","pokeskill_up");

	new command[32];
	for(new i=1; i <= MAX_SKILLS; i++){
		formatex(command, 31, "+pokeskill%d", i);
		register_clcmd(command,"pokeskill_down");
		formatex(command, 31, "-pokeskill%d", i);
		register_clcmd(command,"pokeskill_up");
	}

	register_clcmd("+pokeitem","pokeitem_down", _, "- brings up Item Menu");
	register_clcmd("-pokeitem","pokeitem_up");
	register_clcmd("pokeskill","updatecommands");		//this just tells them to rebind with a +
	register_clcmd("pokemart","Console_Pokemart");
	register_clcmd("fullupdate","fullupdate");			//this just blocks the fullupdate abuse

	//All Console Commands
	register_concmd("playerspokemon","Console_PlayersPokemon", _, "- shows everyones pokemon");	//views players pokemon
	register_concmd("playerspokes","Console_PlayersPokemon");											//views players pokemon
	register_concmd("playersitems","Console_PlayersItems", _, "- shows everyones items");		//views players items
	register_concmd("pokedex","Console_Pokedex", _, "- shows pokemon information");				//views pokedex
	register_concmd("pokeitem","Console_Pokeitem", _, "- shows pokeitem information");				//views pokeitem help

	#if POKERANK_SYSTEM==1
	//PokeRank Commands
	register_concmd("pokerank","Console_PlayersRanks", _, "- shows players PokeRanks");	//views players ranks
	#endif

	//Admin Console Commands
	register_pokeadmincmd("givepoke","admin_givepoke",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon name> <level> - gives players a pokemon");
	register_pokeadmincmd("setpoke","admin_setpoke",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon name> - temporarily gives players pokemon power");
	register_pokeadmincmd("takepoke","admin_takepoke",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon | @ALL | @# | @C> - takes a pokemon away from players");
	register_pokeadmincmd("morph","admin_morph",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon | @ALL | @# | @C> <new pokemon> - morphes a pokemon into a new one");

	register_pokeadmincmd("givexp","admin_givexp",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon | @ALL | @# | @C> <amount> - gives xp to players pokemon");
	register_pokeadmincmd("setxp","admin_setxp",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon | @ALL | @# | @C> <amount> - sets xp on players pokemon");

	#if POKERANK_SYSTEM==1
	register_pokeadmincmd("addrank","admin_rank",ADMIN_ALL,"<nick | @TEAM | @ALL> <amount> - gives rank points to player");
	register_pokeadmincmd("setrank","admin_rank",ADMIN_ALL,"<nick | @TEAM | @ALL> <amount> - sets rank points on player");
	#endif

	register_pokeadmincmd("setlevel","admin_setlvl",ADMIN_ALL);
	register_pokeadmincmd("setlvl","admin_setlvl",ADMIN_ALL,"<nick | @TEAM | @ALL> <pokemon | @ALL | @# | @C> <level> - sets level on players pokemon");

	register_pokeadmincmd("giveitem","admin_giveitem",ADMIN_ALL,"<nick | @TEAM | @ALL> <item name> <amount> - gives players an item");

	register_pokeadmincmd("debugger","admin_debugger",ADMIN_ALL,"<nick | 0> - changes who recieves the debug messages");

	#if PM_ADMIN_COMMANDS==1
	register_pokeadmincmd("help","admin_help",ADMIN_ALL," - shows admin command help");
	#endif
	#if PM_ADMIN_COMMANDS==1 && PM_CVAR_PREFIX==1
	register_pokeadmincmd("cvar","admin_cvar",ADMIN_ALL," - saves changes to pokemod cvars");
	#endif

	register_pokeadmincmd("enable","admin_enable",ADMIN_ALL,"<pokemon | @ALL> - enables the use of a pokemon");
	register_pokeadmincmd("tempenable","admin_enable",ADMIN_ALL,"<pokemon | @ALL> - temporarily enables the use of a pokemon");
	register_pokeadmincmd("disable","admin_disable",ADMIN_ALL,"<pokemon | @ALL> - disables the use of a pokemon");
	register_pokeadmincmd("tempdisable","admin_disable",ADMIN_ALL,"<pokemon | @ALL> - temporarily disables the use of a pokemon");

	register_pokeadmincmd("pokemart","admin_pokemart",ADMIN_ALL,"<pokemon name | item name> <price> - changes items in Pokemart");
	register_pokeadmincmd("safari","admin_safari",ADMIN_ALL,"<pokemon name> <level> - changes pokemon in Safari");
	register_pokeadmincmd("reset","admin_reset",ADMIN_RCON," - resets pokemod files");
	register_pokeadmincmd("loadconfig","admin_loadconfig",ADMIN_BAN," - loads pokemod config files");
	register_pokeadmincmd("erasexp","admin_erasexp",ADMIN_RCON," - erases all xp");

	debugMessage( 0,7,"done registering commands" );

	//Global Messages
	#if MOD==CS
	gmsgMoney		= get_user_msgid("Money");
	#endif
	gmsgScreenFade	= get_user_msgid("ScreenFade");
	gmsgScreenShake = get_user_msgid("ScreenShake");
	gmsgDeathMsg	= get_user_msgid("DeathMsg");
	gmsgScoreInfo	= get_user_msgid("ScoreInfo");
	gmsgDamage		= get_user_msgid("Damage");

	//MultiForwards - thanks to posts by vittu && teame06
	PokePayForward = CreateMultiForward("poke_pay", ET_STOP, FP_CELL, FP_CELL);				//stop on return value, id, amount
	PokeBuyForward = CreateMultiForward("poke_buy", ET_STOP, FP_CELL, FP_CELL, FP_CELL);	//stop on return value, id, item, amount
	PokeBuyPokeForward = CreateMultiForward("poke_buypoke", ET_STOP, FP_CELL, FP_CELL);		//stop on return value, id, poke

	PokeEventForward = CreateMultiForward("poke_player_event", ET_STOP, FP_CELL, FP_CELL);		//stop on return value, id, props

	PokeItemForward = CreateMultiForward("poke_item_use", ET_STOP, FP_CELL, FP_CELL);					//stop on return value, id, item
	RegisterItemForward = CreateMultiForward("poke_register_item", ET_STOP);							//stop on return value

	debugMessage( 0,7,"done making forwards" );

	HUDSYNC = CreateHudSyncObj();
	g_coloredMenus = colored_menus();

	set_task(1.0, "StartPokeMod", 1);
 }

 #if CHANGE_GAME_NAME==1
 public GameDesc()
 {
	forward_return(FMV_STRING,GAME_NAME);
	return FMRES_SUPERCEDE;
 }
 #endif

 public StartPokeMod(initial)
 {
	debugMessage( 0,7,"Starting PokeMod. Initial Start=%d", initial );
	if(initial){
		#if ALLOW_WILD==1
			set_task(180.0, "WildMessage", 0, "", 0, "b");
		#endif

		#if SAVE==SAVE_MYSQL || SAVE==SAVE_SQLX || SAVE==SAVE_NVAULT
			saving_init();
		#endif

		#if POKERANK_SYSTEM==1
			LoadRanks();
		#endif

		set_task(1.0, "poke_round_end");
		set_task(2.0, "round_start");
	}

	LoadConfig();

	set_task(1.0, "ReadXPs");
	set_task(2.0, "SetSafariLevels");
	set_task(2.5, "ReadSkills");
	set_task(3.0, "ReadItems", 0);
	set_task(3.5, "ReadPokemon", 0);
	set_task(4.0, "ReadItems", 1);
	set_task(4.5, "ReadPokemon", 1);
	set_task(5.0, "PokeModLoaded");
 }
 public PokeModLoaded()
 {
	PM_Loaded = true;
	debugMessage( 0,7,"PokeMod has been Started." );
 }
 ///////////////////////
 //--Precached Items--//
 ///////////////////////
 public plugin_precache()
 {
	//register the debug cvars for debug messages
	register_pokecvar( pm_debug, cvar_default[pm_debug] );
	register_pokecvar( pm_debug_key, cvar_default[pm_debug_key] );

	SetupConfig();

	new i = 0;

	new PokeFile[128];
	Poke_FileName( F_PokeMaps, PokeFile);

	if( file_exists(PokeFile) ){
		new Data[124], len;
		new mapname[32];
   		new line = 0;
		new bool:finding_map = true;

		get_mapname(mapname, 31);

		while( (line = read_file(PokeFile , line , Data , 123 , len) ) != 0 ){

			if( !ValidData( Data ) )
				continue;

			//Check the map
			if( equal(Data, LEFT_BRACKET, 1) ){
				replace(Data, 123, LEFT_BRACKET, EMPTY);
				replace(Data, 123, RIGHT_BRACKET, EMPTY);

				if( containi(Data,STAR)!=-1 ){
					replace_all(Data, 123, STAR, EMPTY)
					if(containi(mapname, Data)!=-1){	//deal with this map
						finding_map = false;
						continue;
					}
				}
				else if(equali(mapname, Data)){
					finding_map = false;
					continue;
				}
				else
					finding_map = true;
			}
			else if(!finding_map){	//do the commands
				if(equali(Data,"-disabled")){
					poke_error("%s PokeMod has been disabled.",PREFIX);
					PM_disabled = 1;
					break;
				}
				else if(equali(Data,"-skills_off")){
					poke_error("%s PokeMod skills have been disabled.",PREFIX);
					PM_disabled = -1;
					break;
				}
				else{
					set_task(5.0, "delay_cmd",0,Data,strlen(Data));
				}
			}

		}
	}
	else ResetMapsConfig();

	debugMessage( 0,7,"Map File Loaded/Reset." );

	if( !PM_disabled ){
		debugMessage( 0,7,"Starting Precaching." );

		for(i=0; i<MAX_SND; i++)
			poke_precache_sound( i );
		for(i=0; i<MAX_SPR; i++)
			poke_precache_sprite( i );
		for(i=0; i<MAX_MDL; i++)
			poke_precache_model( i );
		for(i=0; i<MAX_T_MDL; i++)
			poke_precache_model_t( i );

		new missing = poke_missing_files();
		if( missing ){
			if( missing == 1 )
				poke_error("One file required for PokeMod not found. Pausing PokeMod." );
			else
				poke_error("%d files required for PokeMod not found. Pausing PokeMod.", missing );
			PM_disabled = 1;
		}

		debugMessage( 0,7,"Precaching Done." );
	}
 }
 public delay_cmd(Data[])
	server_cmd(Data);
 poke_precache_model(const i)
 {
	if(file_exists(MODELS[i]) || contain(MODELS[i],"pokemon")==-1){
		precache_model(MODELS[i]);
		return (FoundModel[i] = true);
	}
	return false;
 }
 poke_precache_model_t(const i)
 {
	if(file_exists(MODELS_T[i]) || contain(MODELS_T[i],"pokemon")==-1){
		precache_model(MODELS_T[i]);
		return (FoundModelT[i] = true);
	}
	return false;
 }
 poke_precache_sprite(const i)
 {
	if(file_exists(SPRITES[i]) || contain(SPRITES[i],"pokemon")==-1){
		SPRITE_INDEX[i] = precache_model(SPRITES[i]);
		return (FoundSprite[i] = true);
	}
	return false;
 }
 poke_precache_sound(const i)
 {
	new sound_location[151];
	formatex(sound_location, 150, "%s%s", sound_directory, SOUNDS[i]);
	if(file_exists(sound_location) || contain(SOUNDS[i],"pokemon")==-1){
		precache_sound(SOUNDS[i]);
		return (FoundSound[i] = true);
	}
	return false;
 }
 poke_missing_files()
 {
	new i, files_missing = 0;
	for(i=0; i<MAX_SND; i++){
		if( !FoundSound[i] ){
			poke_error( "File %s%s Not Found In Server", sound_directory, SOUNDS[i] );
			files_missing++;
		}
	}
	for(i=0; i<MAX_SPR; i++){
		if( !FoundSprite[i] ){
			poke_error( "File %s Not Found In Server", SPRITES[i] );
			files_missing++;
		}
	}
	for(i=0; i<MAX_MDL; i++){
		if( !FoundModel[i] ){
			poke_error( "File %s Not Found In Server", MODELS[i] );
			files_missing++;
		}
	}
	for(i=0; i<MAX_T_MDL; i++){
		if( !FoundModelT[i] ){
			poke_error( "File %s Not Found In Server", MODELS_T[i] );
			files_missing++;
		}
	}
	return files_missing;
 }
 poke_error(const error[], any:...)
 {
	new output[256];
	vformat(output, 255, error, 2);
	log_amx(output);
 }
 public plugin_end()
 {
	if(PM_disabled==1)
		return;

	// SAVE EVERYTHING...
	debugMessage( 0,3,"%s Making final saves before plugin unloads", PREFIX );
	save_all();

	#if SAVE==SAVE_MYSQL || SAVE==SAVE_SQLX
		//Final cleanup in the saving include
		saving_end();
	#endif

	cleanXP();
 }
 cvar_registry()
 {
	//CVARS used, but lets create them just incase ;)
	mp_freezetime = register_cvar("mp_freezetime","0");
	amx_show_activity = register_cvar("amx_show_activity","0");

	//These Cvars should be in the game already
	sv_lan = get_cvar_pointer("sv_lan");
	mp_friendlyfire = get_cvar_pointer("mp_friendlyfire");
	mp_logdetail = get_cvar_pointer("mp_logdetail");

	//PokeMod Cvars
	for(new i=0; i<MAX_CVARS; i++)
		register_pokecvar(i,cvar_default[i]);

	debugMessage( 0,7,"done registering cvars" );
 }

 debugMessage(id=0, level=0, const msg[], any:... )
 {
	if( PM_disabled==1 )
		return;

	static debugMode;
	debugMode = get_ppcvar_num( pm_debug );

	if( debugMode < level && level )
		return;		//there is a level, but we arent looking that high

	if( id && debugger && id != debugger )
		return;		//its about someone, but its not the debugger

	static output[256];
	vformat( output, 255, msg, 4 );

	static debug_key[51];
	get_ppcvar_string( pm_debug_key, debug_key, 50 );
	if( debug_key[0] != '\0' && containi(output,debug_key) == -1 )
		return;		//it didn't have the debug key in it

	if( id > 0 && id <= MAX_PLAYERS ){
		static lastid;
		static name[32],authid[32], userid;

		if( lastid != id ){
			lastid = id;
			get_user_name( id, name, 31 );
			get_user_authid( id, authid, 31 );
			userid = get_user_userid( id );
		}
		if( userid > 0 )
			format( output, 255, "\"%s<%d><%s><%s>\" %s", name,userid,authid,PokeToName(Pokemon[id]), output );
	}

	if( output[0] == '\0' )
		return;

	if( debugMode )
		format( output, 255, "DEBUG: %s", output );

	switch(debugMode)
	{
		case 0: log_amx( output );				//no matter what, were going to log it
		case 1: log_amx( output );				//log it completely

		case 2..9: console_print( 0, output );	//higher the number, more it outputs

		case 10: log_amx( output );				//log everything (this is extremely crazy!)
	}
	if( debugger )
		console_print( debugger, output );		//put it in console of debugger
 }

