/**************************************************************************************************
For use with Climbing Maps
http://www.kreedz.com/maps.html
And Other Climbing Maps

List Maps in climbing.ini

Original kz_multiplugin by AssKicR
Original amx_checkpoint_beta by DarkShadowST
Merged and updated by ouCh(fmsxuseR)

Say "/kzhelp" for instructions in-game

**** CVARS (FEATURES) ****
kz_autoheal    = AutoHeal
kz_autospawn   = AutoSpawn
kz_godmode     = AutoGodmode
kz_semiclip    = AutoSemiClip
kz_scout       = AutoScout
kz_nightvision = Free NVG
kz_nightmode   = Nightmode
kz_checkpoints = Checkpoints 
kz_timer       = IndividualTimer
cp_godmode     = Self-Godmode
cp_noclip      = Self-Noclip
cp_noclip_mode = Cheat-detect for Self-Noclip
cp_noclip_max  = Max allowed consecutive uses of /noclip before cheating

**** CVARS (CHECKPOINT SYSTEM) ****
kz_checkprice     = Price of a checkpoint
kz_checkpointdist = Distance from other people you can spawn
kz_checkeffects   = Some cool teleport effects
kz_limitedcp      = Limit each checkpoint to one use
kz_startmoney     = Instead of mp_startmoney

**** CVARS (OTHER) ****
kz_grabforce = Grabforce for JediGrab

**** ADMIN COMMANDS ****

ADMIN_LEVEL_A (flag="m")
Setting Noclip        = amx_noclip <authid, nick, @team, @all or #userid> <on/off>
Setting Godmode       = amx_godmode <authid, nick, @team, @all or #userid> <on/off>
Setting Semiclip      = amx_semiclip <authid, nick, @team, @all or #userid> <on/off>
Setting Glow	    = amx_glow <authid, nick, @team, @all or #userid> <red> <green> <blue> <alpha>
Setting Origin        = amx_teleport <authid, nick or #userid> <authid, nick or #userid>
Setting Gravity       = amx_gravity <authid, nick, @team, @all or #userid> <Gravity>
Setting Self-Noclip              = amx_selfnoclip <on/off>
Setting Self-Godmode             = amx_selfgodmode <on/off>
Setting Self-Noclip Cheat-detect = amx_selfnoclip_mode <on/off> - default is on
Setting Self-Noclip Max Uses     = amx_selfnoclip_max <2,3,4,...> - default is 3
Setting AutoHeal      = amx_autoheal <on/off>


ADMIN_LEVEL_B (flag="n")
Giving Longjump	    = amx_longjump <authid, nick, @team, @all or #userid>
Giving Scout	    = amx_scout <authid, nick, @team, @all or #userid>
Giving Money	    = amx_money <authid, nick, @team, @all or #userid> <Money>

ADMIN_LEVEL_C (flag="o")
Set Checkpoint      = amx_checkpoint <authid, nick or #userid>
Rem Checkpoint      = amx_remcheckpoint <authid, nick or #userid>

ADMIN_LEVEL_D (flag="p")
Jedi Force Grab by Spacedude (slightly modified)
Grabbing a person   = +grab
Releasing grabbed   = -grab
Toggle Command      = grab_toggle

ADMIN_LEVEL_E (flag="q")
Ninja Rope by Spacedude (slightly modified) & Hook thingy
Attaching Rope      = +rope
Deattaching Rope    = -rope
Attaching Hook      = +hook
Deattaching Hook    = -hook

**************************************************************************************************/
#include <amxmod.inc>
#include <amxmisc.inc>
#include <Vexd_Utilities>

#define TE_BEAMENTPOINT 1
#define TE_KILLBEAM 99
#define DELTA_T 0.1				// seconds
#define BEAMLIFE 100			// deciseconds
#define MOVEACCELERATION 150	// units per second^2
#define REELSPEED 300			// units per second

#define IN_JUMP			(1 << 1)
#define IN_DUCK			(1 << 2)
#define IN_FORWARD		(1 << 3)
#define IN_BACK			(1 << 4)
#define IN_MOVELEFT		(1 << 9)
#define IN_MOVERIGHT	(1 << 10)

#define	SOLID_NOT		0		/* no interaction with other objects */
#define	SOLID_BBOX		2		/* touch on edge, block */

/* Checkpoint Sys stuff by DarkShadowST (configured for L7 server by ouCh) */
new cp_pluginname[] = "L7 Checkpoints"

/* Stuff */
new NVGrun[33]
new Cvar[4] // mp_friendlyfire, mp_autoteambalance, mp_limitteams
new gMoney[33]
new gJoined[33]
new gStartMoney
new usedTNoclip[33] = 0		//do not change
new inCheatTimeTN[33] = 0	//do not change
new cheatTNCounter[33] = 0	//do not change
new cheatTNDetected[33] = 0	//do not change
new usedFirstRound = 0
new bool:canDistance[33] = false
new cpDistance[33]
new usedStuck[33] = 0

/* Checkpoint Stuff */
new bool:gCheckpoint[33]
new gCheckpointPos[33][3]
new gLastCheckpointPos[33][3]

/* Hook Stuff */
new gHookLocation[33][3]
new gHookLenght[33]
new bool:gIsHooked[33]
new Float:gBeamIsCreated[33]

new global_gravity
new beam

/* Timer Stuff */
new bool:gHasTimer[33],bool:gHasStoppedTimer[33]
new gSecs[33], gMins[33], gHuns[33], gChecks[33]

/************************************************************************************************************************/
public plugin_init() //Called on plugin start
{
	// Plugin Info
	register_plugin("KZ Multiplugin","1.17","AssKicR,DarkShadowST,ouCh")
	//CVARS
	register_cvar("kz_autoheal","0")
	register_cvar("kz_autospawn","0")
	register_cvar("kz_checkpoints","0")
	register_cvar("kz_checkprice","500")
	register_cvar("kz_checkpointdist","50")
	register_cvar("kz_checkeffects","0")
	register_cvar("kz_scout","0")
	register_cvar("kz_limitedcp","0")
	register_cvar("kz_nightvision","0")
	register_cvar("kz_grabforce","8")
	register_cvar("kz_godmode","0")
	register_cvar("kz_semiclip","0")
	register_cvar("kz_nightmode","0")
	register_cvar("kz_startmoney","16000")
	register_cvar("kz_timer","1")

	register_cvar("cp_godmode","0")					//Turns Allowing say /godmode On And Off
	register_cvar("cp_noclip","0")					//Turns Allowing say /noclip On And Off
	register_cvar("cp_noclip_mode","1")					//cheat detect and prevention for /noclip - default on
	register_cvar("cp_noclip_max","3")					//max allowed /noclip uses before cheat - default 3


	if(ClimbMap()) {
		gStartMoney=get_cvar_num("kz_startmoney")
		//EVENTS
		register_event("StatusValue","spec_event","be","1=2")
		register_event("DeathMsg", "DeathMsg", "a")
		register_event("Damage", "Damage", "b", "2!0")
		register_event("ResetHUD", "ResetHUD", "b")
		register_clcmd("drop", "gimmetime")
		register_event("TextMsg","RestartRound","a","2&#Game_C","2&#Game_w")
		//CLIENT CMDS
		register_clcmd("nightvision","NVGToggle")
		
		register_clcmd("checkpoint","Checkpoint")
		register_clcmd("say /checkpoint","Checkpoint")
/* Checkpoint Sys stuff */
		register_clcmd("say /check","Checkpoint")
		register_clcmd("say /cp","Checkpoint")

		register_clcmd("gocheck","GoCheckpoint")
		register_clcmd("say /gocheck","GoCheckpoint")
		register_clcmd("say /gc","GoCheckpoint")
/* Checkpoint Sys stuff */
		register_clcmd("say /teleport","GoCheckpoint")
		register_clcmd("say /tele","GoCheckpoint")
		register_clcmd("say /tp","GoCheckpoint")

/* Checkpoint Sys stuff */
		register_clcmd("say /godmode","cp_godmode",0)			//toggles godmode
		register_clcmd("say /godme","cp_godmode",0)			//toggles godmode
		register_clcmd("say /god","cp_godmode",0)				//toggles godmode
		register_clcmd("say /noclip","cp_noclip",0)			//toggles noclip
		register_clcmd("say /noclipme","cp_noclip",0)			//toggles noclip
		register_clcmd("say /clip","cp_noclip",0)				//toggles noclip

		
		register_clcmd("lastcheck","LastCheckpoint")
		register_clcmd("say /stuck","LastCheckpoint")
		register_clcmd("say /imstuck","LastCheckpoint")
		register_clcmd("say /unstuck","LastCheckpoint")
		register_clcmd("say /destuckme","LastCheckpoint")

		register_clcmd("say /kzhelp","kzhelp",0)  //displays instructions on chat

		register_clcmd("radio1","blocked")
		register_clcmd("radio2","blocked")
		register_clcmd("radio3","blocked")
		//ADMIN CMDS
		register_clcmd("+rope", "hook_on",ADMIN_LEVEL_E)
		register_clcmd("-rope", "hook_off",ADMIN_LEVEL_E)
		register_clcmd("+hook", "hook_on",ADMIN_LEVEL_E)
		register_clcmd("-hook", "hook_off",ADMIN_LEVEL_E)

		register_clcmd("grab_toggle","grab_toggle",ADMIN_LEVEL_D,"press once to grab and again to release")
		register_clcmd("+grab","grab",ADMIN_LEVEL_D,"bind a key to +grab")
		register_clcmd("-grab","release",ADMIN_LEVEL_D)

		register_concmd("amx_checkpoint","AdminSetCheck",ADMIN_LEVEL_C,"<authid, nick or #userid>")
		register_concmd("amx_remcheckpoint","AdminRemCheck",ADMIN_LEVEL_C,"<authid, nick or #userid>")

		register_concmd("amx_longjump","AdminLongjump",ADMIN_LEVEL_B,"<authid, nick, @team, @all or #userid>") 
		register_concmd("amx_scout","AdminScout",ADMIN_LEVEL_B,"<authid, nick, @team, @all or #userid>")
		register_concmd("amx_money","AdminSetMoney",ADMIN_LEVEL_B,"<authid, nick, @team, @all or #userid> <Money>")
		register_concmd("amx_gravity","AdminGravity",ADMIN_LEVEL_B,"<authid, nick, @team, @all or #userid> <Gravity>")

/* ouCh's stuff */
		register_concmd("amx_selfnoclip","AdminSetSelfNoclip",ADMIN_LEVEL_A,"<on/off>")
		register_concmd("amx_selfgodmode","AdminSetSelfGodMode",ADMIN_LEVEL_A,"<on/off>")
		register_concmd("amx_selfnoclip_mode","AdminSetTNMode",ADMIN_LEVEL_A,"<on/off> - default is on")
		register_concmd("amx_selfnoclip_max","AdminSetTNMax",ADMIN_LEVEL_A,"<2,3,4,...> - default is 3")
		register_concmd("amx_autoheal","AdminSetAutoHeal",ADMIN_LEVEL_A,"<on/off>")

		register_concmd("amx_noclip","AdminNoclip",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
		register_concmd("amx_godmode","AdminGodMode",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
		register_concmd("amx_semiclip","AdminSemiClip",ADMIN_LEVEL_A,"<authid, nick, @team, @all or #userid> <on/off>")
		register_concmd("amx_glow","AdminGlow",ADMIN_LEVEL_A,"<authid, nick, @team or #userid> <red> <green> <blue> <alpha>")	
		register_concmd("amx_teleport","AdminTele",ADMIN_LEVEL_A,"<authid, nick or #userid> [x] [y] [z]")

		register_logevent("enforce_cvars", 2, "1=Round_Start")

	}
	set_task(0.1,"gTimerTask",0,"",0,"b")
}
public enforce_cvars() {
	if(usedFirstRound == 0) {
		if(ClimbMap()) {
			//CVAR ENFORCING
			Cvar[0]=get_cvar_num("mp_friendlyfire")
			Cvar[1]=get_cvar_num("mp_autoteambalance")
			Cvar[2]=get_cvar_num("mp_limitteams")
			Cvar[3]=get_cvar_num("mp_flashlight")
			set_cvar_num("mp_friendlyfire",0)
			set_cvar_num("mp_autoteambalance",0)
			set_cvar_num("mp_limitteams",99)
			set_cvar_num("mp_flashlight",1)
			server_cmd("sv_restartround 1")
			server_cmd("say CVARs Enforced")
		}
		usedFirstRound = 1
	}
	return PLUGIN_CONTINUE
}
/************************************************************************************************************************/
public plugin_end() { //Called on plugin end
	if(ClimbMap()) {
		set_cvar_num("mp_friendlyfire",Cvar[0])
		set_cvar_num("mp_autoteambalance",Cvar[1])
		set_cvar_num("mp_limitteams",Cvar[2])
		set_cvar_num("mp_flashlight",Cvar[3])
		usedFirstRound = 0
	}
}
/************************************************************************************************************************/
public plugin_precache()
{
	precache_model("models/w_longjump.mdl")		//longjump
	precache_model("models/w_longjumpt.mdl")	//---"---
	precache_sound("items/nvg_on.wav") 
	precache_sound("items/nvg_off.wav")

	beam = precache_model("sprites/zbeam4.spr")
	precache_sound("weapons/xbow_hit2.wav")
}
/*************************************************************************************************************************/
/***************************************************** USP REMOVE ********************************************************/
/*************************************************************************************************************************/
public gimmetime(id) {
	set_task(0.2, "killevilusp", id+50, "", 0)
}

public killevilusp(Taskid)
{
	new model[32]
	new oid, tEnt, wEnt
	
	tEnt = FindEntity(-1, "weaponbox")
	while (tEnt > 0) {
		Entvars_Get_String(tEnt, EV_SZ_model, model, 32)
		if (equali(model,"models/w_usp.mdl")) {
			oid = Entvars_Get_Edict(tEnt, EV_ENT_owner)
			if (oid > 0 && oid < 33) {
				RemoveEntity(tEnt)
				wEnt = FindEntity(-1, "weapon_usp")
				while (wEnt > -1) {
					oid = Entvars_Get_Edict(wEnt, EV_ENT_owner)
					if (oid == tEnt) {
						RemoveEntity(wEnt)
					}
					wEnt = FindEntity(wEnt, "weapon_usp")
				}
			}
		}
		tEnt = FindEntity(tEnt, "weaponbox")
	}	
	set_task(0.2, "killevilscout", Taskid, "", 0)
}

public killevilscout(Taskid)
{
	new model[32]
	new oid, tEnt, wEnt
	
	tEnt = FindEntity(-1, "weaponbox")
	while (tEnt > 0) {
		Entvars_Get_String(tEnt, EV_SZ_model, model, 32)
		if (equali(model,"models/w_scout.mdl")) {
			oid = Entvars_Get_Edict(tEnt, EV_ENT_owner)
			if (oid > 0 && oid < 33) {
				RemoveEntity(tEnt)
				wEnt = FindEntity(-1, "weapon_scout")
				while (wEnt > -1) {
					oid = Entvars_Get_Edict(wEnt, EV_ENT_owner)
					if (oid == tEnt) {
						RemoveEntity(wEnt)
					}
					wEnt = FindEntity(wEnt, "weapon_scout")
				}
			}
		}
		tEnt = FindEntity(tEnt, "weaponbox")
	}	
}
/*************************************************************************************************************************/
/**************************************************** HOOKED EVENTS ******************************************************/
/*************************************************************************************************************************/
public DeathMsg() 
{ 
	new id = read_data(2) 
	// User died, do they need to respawn???
	if(get_cvar_num("kz_autospawn") == 0) {
		// No Need, remove his timer
		if (gHasTimer[id]) gHasTimer[id]=false
		return PLUGIN_CONTINUE 
	}
	// Yep, needs to respawn.  Postpone with set_task for 0.5...	
	NVGcmd(id,0)
	set_task(0.5,"respawn",id+123)
	gimmetime(id)
	return PLUGIN_CONTINUE 
} 
/************************************************************************************************************************/
public respawn(TaskID) 
{ 
	//Respawn user...
	new id = TaskID-123
	if(get_user_team(id) != 2 || is_user_alive(id)) return PLUGIN_CONTINUE 
	//Show a message to user that he is respawning
	client_print(id,print_chat,"[%s] Respawning!!!", cp_pluginname) 
	user_spawn(id)
	return PLUGIN_CONTINUE 
} 
/************************************************************************************************************************/
public advertiseOn(id) {
	client_print(id,print_chat,"[%s] mod is enabled. Say ^"/kzhelp^" to get these instructions again!",cp_pluginname)
	kzhelp(id)
}
public kzhelp(id) {
	client_print(id,print_chat,"[%s] Say ^"/checkpoint^" or ^"/cp^" to set your checkpoint",cp_pluginname)
	client_print(id,print_chat,"[%s] Say ^"/gocheck^" or ^"/tp^" to go to your current checkpoint",cp_pluginname)
	client_print(id,print_chat,"[%s] Other say commands include ^"/god^" ^"/stuck^" ^"/noclip^" and ^"/kzhelp^"",cp_pluginname)
	return PLUGIN_HANDLED
}
public advertiseOff(id) {
	client_print(id,print_chat,"* [%s] mod is disabled",cp_pluginname)
}

public ResetHUD(id) {
	//Check if Checkpoints are on...
	if (get_cvar_num("kz_checkpoints") != 0) {
		//Check if user has a Checkpoint
		if (gCheckpoint[id]) {
			//Yep he has one... Move him to it...
			if (CheckCheckpoint(id)) move_to_check(id)
			set_user_money(id,0)
			//Check if limited Checkpointuse is on
			if (get_cvar_num("kz_limitedcp") != 0) {
				//Yep.. It is on... Delete Checkpoint
				gCheckpoint[id]=false
				client_print(id,print_chat,"[%s] Checkpoint Used...",cp_pluginname) 
			}
		}else{
			if (gHasTimer[id]) ResetTimer(id,1)
		}
	}else{
		if (gHasTimer[id]) ResetTimer(id,1)
	}
	//Check if he just joined
	if (gJoined[id]) {
		get_user_origin(id,gLastCheckpointPos[id])
		gJoined[id]=false
		if (get_cvar_num("kz_checkpoints")==1) {
			set_task(30.0,"advertiseOn",id)
		}else{
			set_task(30.0,"advertiseOff",id)
		}
	}

	//Check if he gets godmode
	if (get_cvar_num("kz_godmode") != 0) {
		//Yep, it's on... Give it too him...
		set_user_godmode(id,1)
	}
	//Check if auto scout give is on...
	if (get_cvar_num("kz_scout") != 0) {
		//Yep, it's on... Give it too him...
		GiveScout(id)
	}
	//Check if he gets semiclip...
	if (get_cvar_num("kz_semiclip") != 0) {
		//Yep, it's on... Give it too him...
		Entvars_Set_Int(id, EV_INT_solid, SOLID_NOT)
	}else{
		//Nope, it's off... Make sure he has clip
		Entvars_Set_Int(id, EV_INT_solid, SOLID_BBOX)
	}

	//Check if nightmode is on...
	if (get_cvar_num("kz_nightmode") != 0) {
		//Yep, it's on...
		SetLights("a")
	}else{
		//Nope, it's off...
		SetLights("n")
	}
	//Check if he is hooked to something
	if (gIsHooked[id]) RopeRelease(id)

	set_user_money(id,gMoney[id])
}
/************************************************************************************************************************/
public Damage() {
	if(get_cvar_num("kz_autoheal") == 0) return PLUGIN_CONTINUE 

	new victim = read_data(0)
	set_user_health(victim, 100)

	return PLUGIN_CONTINUE
} 
/************************************************************************************************************************/
public RestartRound() {
	for (new id=1; id<33; id++) {
		if (is_user_connected(id)) {
			gCheckpoint[id]=false
			if (gHasTimer[id]) client_print(id,print_chat,"[%s] Timer Reset...",cp_pluginname)
			ResetTimer(id,0)
		}
	}
}
/************************************************************************************************************************/
public Checkpoint(id) {
	if (get_cvar_num("kz_checkpoints") != 1) {
		client_print(id,print_console,"[%s] Sry Server has diabled this command",cp_pluginname)
		client_print(id,print_chat,"[%s] Sry Server has diabled this command",cp_pluginname)
		return PLUGIN_CONTINUE
	}
	if (get_user_money(id)<get_cvar_num("kz_checkprice")) {
		client_print(id,print_console,"[%s] Sry, but a checkpoint costs %i$",cp_pluginname,get_cvar_num("kz_checkprice"))
		client_print(id,print_chat,"[%s] Sry, but a checkpoint costs %i$",cp_pluginname,get_cvar_num("kz_checkprice"))
		return PLUGIN_CONTINUE
	}
	if (get_user_button(id)&IN_DUCK) {
		client_print(id,print_console,"[%s] You cannot place a checkpoint while ducking",cp_pluginname)
		client_print(id,print_chat,"[%s] You cannot place a checkpoint while ducking",cp_pluginname)
		return PLUGIN_CONTINUE	
	}
	if (usedTNoclip[id] == 1) {
		client_print(id,print_console,"[%s] Not allowed! You recently used NoClip",cp_pluginname)
		client_print(id,print_chat,"[%s] Not allowed! You recently used NoClip",cp_pluginname)
		return PLUGIN_CONTINUE
	}

	set_user_money(id,get_user_money(id)-get_cvar_num("kz_checkprice"))
	gMoney[id]=get_user_money(id)
	if (gCheckpoint[id]) {
		gLastCheckpointPos[id][0]=gCheckpointPos[id][0]
		gLastCheckpointPos[id][1]=gCheckpointPos[id][1]
		gLastCheckpointPos[id][2]=gCheckpointPos[id][2]
		canDistance[id]=true
	}
	get_user_origin(id,gCheckpointPos[id])
	gCheckpointPos[id][2] += 4
	gCheckpoint[id]=true
	gChecks[id] += 1
	if (!canDistance[id]) cpDistance[id] = 0
	else cpDistance[id] = get_distance(gLastCheckpointPos[id],gCheckpointPos[id])

	client_print(id,print_console,"[%s] Saving Position... You are %i units from your last Checkpoint ",cp_pluginname,cpDistance[id])
	client_print(id,print_chat,"[%s] Saving Position... You are %i units from your last Checkpoint ",cp_pluginname,cpDistance[id]) 

	return PLUGIN_HANDLED
}

public LastCheckpoint(id) {
	if (get_cvar_num("kz_checkpoints") != 1) {
		client_print(id,print_console,"[%s] Sry Server has diabled this command",cp_pluginname)
		client_print(id,print_chat,"[AMX] Sry Server has diabled this command")
		return PLUGIN_CONTINUE
	}
	if (!gCheckpoint[id]) {
		client_print(id,print_console,"[%s] You don't have a checkpoint to revert to",cp_pluginname)
		client_print(id,print_chat,"[%s] You don't have a checkpoint to revert to",cp_pluginname)
		return PLUGIN_CONTINUE
	}
	client_print(id,print_console,"[%s] Reverting to last Checkpoint",cp_pluginname)
	client_print(id,print_console,"[%s] Say ^"/noclip^" for 2 seconds of NoClip if you're still stuck",cp_pluginname)
	client_print(id,print_chat,"[%s] Reverting to last Checkpoint",cp_pluginname)
	client_print(id,print_chat,"[%s] Say ^"/noclip^" for 2 seconds of NoClip if you're still stuck",cp_pluginname)
	if (usedStuck[id] == 0) {
		usedStuck[id] = 1
	}

	gCheckpointPos[id][0]=gLastCheckpointPos[id][0]
	gCheckpointPos[id][1]=gLastCheckpointPos[id][1]
	gCheckpointPos[id][2]=gLastCheckpointPos[id][2]
	gCheckpoint[id]=true

	if (CheckCheckpoint(id)) move_to_check(id)

	return PLUGIN_HANDLED
}

public GoCheckpoint(id) {
	if (get_cvar_num("kz_checkpoints") != 1) {
		client_print(id,print_console,"[%s] Sry Server has diabled this command",cp_pluginname)
		client_print(id,print_chat,"[%s] Sry Server has diabled this command",cp_pluginname)
		return PLUGIN_CONTINUE
	}
	if (!gCheckpoint[id]) {
		client_print(id,print_console,"[%s] You don't have a checkpoint",cp_pluginname)
		client_print(id,print_chat,"[%s] You don't have a checkpoint",cp_pluginname)
		return PLUGIN_CONTINUE
	}
	if (usedTNoclip[id] == 1) {
		client_print(id,print_console,"[%s] Not allowed! You recently used NoClip",cp_pluginname)
		client_print(id,print_chat,"[%s] Not allowed! You recently used NoClip",cp_pluginname)
		return PLUGIN_CONTINUE
	}
	if (CheckCheckpoint(id)) {
		move_to_check(id)
		client_print(id,print_chat,"[%s] Say ^"/stuck^" to be moved to your last checkpoint if you're stuck",cp_pluginname)
		client_print(id,print_console,"[%s] Say ^"/stuck^" to be moved to your last checkpoint if you're stuck",cp_pluginname)
	}
	return PLUGIN_HANDLED
}

public bool:CheckCheckpoint(id) {
	// Check if they can respawn
	new origin[33][3]
	new dist = 9999
	for(new a = 0; a < 33; a++) {
		if (is_user_connected(a)) {
			get_user_origin(a,origin[a])
			dist = get_distance(origin[a],gCheckpointPos[id])
			if (dist<=get_cvar_num("kz_checkpointdist")) {
				client_print(id,print_console,"[%s] You will respawn too close to another person.. plz wait...",cp_pluginname)
				client_print(id,print_chat,"[%s] You will respawn too close to another person.. plz wait...",cp_pluginname)
				return false			
			}
		}
	}
	return true
}

public blocked(id) {
	return PLUGIN_HANDLED
}
/*************************************************************************************************************************/
/**************************************************** STOCK COMMANDS *****************************************************/
/*************************************************************************************************************************/
stock bool:ClimbMap()
{
	if(file_exists("addons/amx/climbing.ini") == 1) { 
		new line, stxtsize 
		new data[192] 
		new cMap[32]
		get_mapname(cMap, 31)
		new MapName[32],aHeal[6]=0,aSpawn[6]=0,aGodmode[6]=0,aScout[6]=0,aSemiClip[6]=0,aNVG[6]=0,nMode[6]=0,cTimer[6]=0,cPoints[6]=0,cPrice[6]=0,cDist[6]=0,cEffects[6]=0,cLimited[6]=0,aSelfGod[6]=0,aSelfNC[6]=0,aSelfNCmode[6]=0,aSelfNCmax[6]=0
		while((line=read_file("addons/amx/climbing.ini",line,data,191,stxtsize))!=0)
		{ 
			if ( data[0] == ';' ) continue
			parse(data,MapName,31,aHeal,5,aSpawn,5,aGodmode,5,aScout,5,aSemiClip,5,aNVG,5,nMode,5,cTimer,5,cPoints,5,cPrice,5,cDist,5,cEffects,5,cLimited,5,aSelfGod,5,aSelfNC,5,aSelfNCmode,5,aSelfNCmax,5)
			if (equal(MapName,cMap)) {
				set_cvar_num("kz_autoheal",strtonum(aHeal))
				set_cvar_num("kz_autospawn",strtonum(aSpawn))
				set_cvar_num("kz_godmode",strtonum(aGodmode))
				set_cvar_num("kz_scout",strtonum(aScout))
				set_cvar_num("kz_semiclip",strtonum(aSemiClip))
				set_cvar_num("kz_nightvision",strtonum(aNVG))
				set_cvar_num("kz_nightmode",strtonum(nMode))
				set_cvar_num("kz_timer",strtonum(cTimer))
				set_cvar_num("kz_checkpoints",strtonum(cPoints))
				set_cvar_num("kz_checkprice",strtonum(cPrice))
				set_cvar_num("kz_checkpointdist",strtonum(cDist))
				set_cvar_num("kz_checkeffects",strtonum(cEffects))
				set_cvar_num("kz_limitedcp",strtonum(cLimited))
				set_cvar_num("cp_godmode",strtonum(aSelfGod))
				set_cvar_num("cp_noclip",strtonum(aSelfNC))
				set_cvar_num("cp_noclip_mode",strtonum(aSelfNCmode))
				set_cvar_num("cp_noclip_max",strtonum(aSelfNCmax))
				return true
			}
		}
		return false
	}else{
		server_cmd("echo [%s] Error!!! Failed To Load climbing.ini!!!",cp_pluginname)
		log_message("[%s] Error!!! Failed To Load climbing.ini!!!",cp_pluginname)
		return false
	}
	return false
}

stock set_user_velocity(id,vel[3]) {
	//Set Their Velocity to 0 so that they they fall straight down from
	new Float:Ivel[3]
	Ivel[0]=float(vel[0])
	Ivel[1]=float(vel[1])
	Ivel[2]=float(vel[2])
	Entvars_Set_Vector(id, EV_VEC_velocity, Ivel)
}

stock get_user_velocity(id,vel[3]) {
	//Set Their Velocity to 0 so that they they fall straight down from
	new Float:Ivel[3]

	Entvars_Get_Vector(id, EV_VEC_velocity, Ivel)
	vel[0]=floatround(Ivel[0])
	vel[1]=floatround(Ivel[1])
	vel[2]=floatround(Ivel[2])
}

stock get_user_button(id)
{
	new button = Entvars_Get_Int(id, EV_INT_button)
	return button
}

stock move_to_check(id) {
	new vel[3]={0,0,0}
	set_user_velocity(id,vel)
	//Check if Effects are enabled
	if (get_cvar_num("kz_checkeffects")==1) {
		//Yep They Are
		new CurOrig[3]
		get_user_origin(id,CurOrig)
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
		write_byte(11) 
		write_coord(CurOrig[0]) 
		write_coord(CurOrig[1]) 
		write_coord(CurOrig[2]) 
		message_end() 
		message_begin(MSG_BROADCAST,SVC_TEMPENTITY) 
		write_byte(11) 
		write_coord(gCheckpointPos[id][0]) 
		write_coord(gCheckpointPos[id][1]) 
		write_coord(gCheckpointPos[id][2]) 
		message_end() 
	}
	//Move To Checkpoint
	set_user_origin(id,gCheckpointPos[id])
}

stock GiveScout(id)
{
	// Check If They Already Have Scout
	new iwpn, iwpns[32] 
	new ownWeapon[32]
	new bool:HasScout
	get_user_weapons(id, iwpns,iwpn) 
	for(new a = 0; a < iwpn; a++) 
	{ 
		get_weaponname(iwpns[a],ownWeapon,31)
		if ( equali(ownWeapon, "weapon_scout") ) HasScout=true
	}
	// They Don't Got It
	if (!HasScout) give_item(id,"weapon_scout")
}

stock CheatDetect(id,cheat[]) {
	if (gHasTimer[id]) {
		client_print(id,print_chat,"[%s] %s Detected.. Timer Terminated",cp_pluginname,cheat)
		ResetTimer(id,0)
	}
}
/************************************************************************************************************************/
/**************************************************** ADMIN COMMANDS ****************************************************/
/************************************************************************************************************************/
public AdminLongjump(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,1) ) 
	  return PLUGIN_HANDLED 

	new arg1[32]
	read_argv(1,arg1,31) 

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++)
	  {
			give_item(plist[i],"item_longjump")
			CheatDetect(plist[i],"Longjump")
	  }

	  console_print(id,"[%s] Gave all players longjump",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
	  {
			give_item(plist[i],"item_longjump")
			CheatDetect(plist[i],"Longjump")

	  }
	  console_print(id,"[%s] Gave all %ss longjump",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  give_item(player,"item_longjump") 
	  CheatDetect(player,"Longjump")

	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Gave ^"%s^" longjump",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
} 

public AdminScout(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,1) ) 
	  return PLUGIN_HANDLED 

	new arg1[32]
	read_argv(1,arg1,31) 

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
		  GiveScout(plist[i]) 

	  console_print(id,"[%s] Gave all players scout",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			GiveScout(plist[i]) 
	  console_print(id,"[%s] Gave all %ss scouts",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  GiveScout(player) 
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Gave ^"%s^" scout",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
}

public AdminGravity(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,3) ) 
	  return PLUGIN_HANDLED 

	new arg1[32],arg2[32]
	read_argv(1,arg1,31)
	read_argv(2,arg2,31)
	new Float:gravalue = floatstr(arg2) / 100.0

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++)
	  {
			set_user_gravity(plist[i],gravalue) 
			CheatDetect(plist[i],"GravityChange")
	  }

	  console_print(id,"[%s] Set everyones gravity to %f",cp_pluginname,gravalue) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++)
	  {
			set_user_gravity(plist[i],gravalue)
			CheatDetect(plist[i],"GravityChange")
	  }
	  console_print(id,"[%s] Set all %ss gravity to %f ",cp_pluginname,arg1[1],gravalue) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  set_user_gravity(player,gravalue) 
	  CheatDetect(player,"GravityChange")
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set ^"%s^" gravity to %f",cp_pluginname,pName,gravalue) 
	} 

	return PLUGIN_HANDLED 
}

public AdminSetCheck(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,1) ) 
	  return PLUGIN_HANDLED 

	new arg1[32]
	read_argv(1,arg1,31)

	new pName[32] 
	new player = cmd_target(id,arg1,6) 
	if (!player) return PLUGIN_HANDLED 
	get_user_origin(id,gCheckpointPos[player])
	gCheckpointPos[player][2] += 20
	gCheckpoint[player]=true
	gChecks[player]+=1
	CheatDetect(id,"Admin Checkpoint Change")
	get_user_name(player,pName,31)
	console_print(id,"[%s] Set ^"%s^" checkpoint",cp_pluginname,pName) 
	return PLUGIN_HANDLED 
}

public AdminRemCheck(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,1) ) 
	  return PLUGIN_HANDLED 

	new arg1[32]
	read_argv(1,arg1,31)

	new pName[32] 
	new player = cmd_target(id,arg1,6) 
	if (!player) return PLUGIN_HANDLED 
	gCheckpoint[player]=false
	gChecks[player]=0
//	CheatDetect(id,"Admin Checkpoint Removal")
	get_user_name(player,pName,31)
	console_print(id,"[%s] Removed ^"%s^" checkpoint",cp_pluginname,pName) 
	return PLUGIN_HANDLED 
}

public AdminSetMoney(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,3) ) 
	  return PLUGIN_HANDLED 

	new arg1[32],arg2[32]
	read_argv(1,arg1,31)
	read_argv(2,arg2,31)
	new money = strtonum(arg2)

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			set_user_money(plist[i],money) 

	  console_print(id,"[%s] Set everyones money to %d",cp_pluginname,money) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			set_user_money(plist[i],money)
	  console_print(id,"[%s] Set all %ss money to %d ",cp_pluginname,arg1[1],money) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  set_user_money(player,money)
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set ^"%s^" money to %d",cp_pluginname,pName,money) 
	  gMoney[player]=money
	} 

	return PLUGIN_HANDLED 
}

/* Checkpoint Sys stuff */

public cp_godmode(id) {

    if(get_cvar_num("cp_godmode") == 0) {
        client_print(id,print_chat,"[%s] /god has been disabled for this map",cp_pluginname)
        return PLUGIN_CONTINUE
    }
    if(is_user_alive(id) == 0) {
        client_print(id,print_chat,"[%s] You must be alive to do this",cp_pluginname)
        return PLUGIN_HANDLED
    }
    new name[33]
    get_user_name(id,name,32)
    if(get_user_godmode(id) == 0) {
        set_user_godmode(id,1)
        client_print(id,print_center,"[%s] You now have Godmode set",cp_pluginname)
        client_print(0,print_chat,"[%s] %s now has Godmode on",cp_pluginname,name)
        return PLUGIN_HANDLED
    }
    if(get_user_godmode(id) == 1) {
        set_user_godmode(id,0)
        client_print(id,print_center,"[%s] You no longer have Godmode set",cp_pluginname)
        client_print(0,print_chat,"[%s] %s now has Godmode off",cp_pluginname,name)
        return PLUGIN_HANDLED
    }
    client_print(0,print_chat,"[%s] Error...Godmode Wasn't On Or Off??? Inaccurate Statement",cp_pluginname)
    return PLUGIN_HANDLED
}
public stopTNoclip(id) {
    new name[33]
    get_user_name(id,name,32)
    set_user_noclip(id,0)
    client_print(id,print_center,"[%s] You no longer have NoClip on",cp_pluginname)
    client_print(0,print_chat,"[%s] %s Now has NoClip off",cp_pluginname,name)
    set_task(10.0,"setUsedTNoclipOff",id)
    return PLUGIN_CONTINUE
}
public setUsedTNoclipOff(id) {
    usedTNoclip[id] = 0
    return PLUGIN_CONTINUE
}
public setInCheatTimeTNOff(id) {
    inCheatTimeTN[id] = 0
    return PLUGIN_CONTINUE
}
public resetCTNAll(id) {
    cheatTNCounter[id] = 0
    cheatTNDetected[id] = 0
    inCheatTimeTN[id] = 0
    return PLUGIN_CONTINUE
}
public cp_noclip(id) {

    if(get_cvar_num("cp_noclip") == 0) {
        client_print(id,print_chat,"[%s] /noclip has been disabled for this map",cp_pluginname)
        return PLUGIN_CONTINUE
    }
    if(is_user_alive(id) == 0) {
        client_print(id,print_chat,"[%s] You must be alive to do this",cp_pluginname)
        return PLUGIN_HANDLED
    }
    new Float:cheatTime = get_cvar_num("cp_noclip_max") * 30.0
    new Float:wTime = floatround((cheatTime/60.0)*10, floatround_round)/10.0
    new tempWhole = floatround(wTime, floatround_floor)
    new tempDecimal = floatround((wTime - tempWhole)*10, floatround_round)

    new name[33]
    get_user_name(id,name,32)
    if(get_cvar_num("cp_noclip_mode") == 1) {
        if(cheatTNCounter[id] >= get_cvar_num("cp_noclip_max")-1) {
            if(cheatTNDetected[id] == 1) {
                if(tempWhole == 1 && tempDecimal == 0) {
                    client_print(id,print_center,"[%s] Cheater! You must wait 1 minute before using NoClip again",cp_pluginname)
                    client_print(id,print_chat,"[%s] Cheater! You must wait 1 minute before using NoClip again",cp_pluginname)
                } else {
                    client_print(id,print_center,"[%s] Cheater! You must wait %i.%i minutes before using NoClip again",cp_pluginname,tempWhole,tempDecimal)
                    client_print(id,print_chat,"[%s] Cheater! You must wait %i.%i minutes before using NoClip again",cp_pluginname,tempWhole,tempDecimal)
                }
                return PLUGIN_HANDLED
            }
            cheatTNDetected[id] = 1
            CheatDetect(id,"NoClip")
            if(tempWhole == 1 && tempDecimal == 0) {
                client_print(id,print_center,"[%s] Cheater! You must wait 1 minute before using NoClip again",cp_pluginname)
                client_print(id,print_chat,"[%s] Cheater! You must wait 1 minute before using NoClip again",cp_pluginname)
            } else {
                client_print(id,print_center,"[%s] Cheater! You must wait %i.%i minutes before using NoClip again",cp_pluginname,tempWhole,tempDecimal)
                client_print(id,print_chat,"[%s] Cheater! You must wait %i.%i minutes before using NoClip again",cp_pluginname,tempWhole,tempDecimal)
            }
            set_task(cheatTime,"resetCTNAll",id)
            return PLUGIN_HANDLED
        }
    }
    if(usedTNoclip[id] == 1) {
        client_print(id,print_center,"[%s] You must wait 10 seconds before using NoClip again",cp_pluginname)
        client_print(id,print_chat,"[%s] You must wait 10 seconds before using NoClip again",cp_pluginname)
        return PLUGIN_HANDLED
    }
    if(get_user_noclip(id) == 0) {
        set_user_noclip(id,1)
        client_print(id,print_center,"[%s] You now have NoClip on for 2 seconds",cp_pluginname)
        client_print(0,print_chat,"[%s] %s Now has NoClip on for 2 seconds",cp_pluginname,name)
        usedTNoclip[id] = 1
        if (usedStuck[id] == 0) {
            CheatDetect(id,"NoClip")
        }
        if (usedStuck[id] == 1) {
            usedStuck[id] = 0
        }
        if(get_cvar_num("cp_noclip_mode") == 1) {
            if(inCheatTimeTN[id] == 1) {
                cheatTNCounter[id] += 1
                if(cheatTNCounter[id] == get_cvar_num("cp_noclip_max")-1) {
                    client_print(id,print_chat,"[%s] Careful... If you try to quickly use NoClip again soon, you'll be considered cheating!",cp_pluginname)
                }
            }
            if(inCheatTimeTN[id] == 0) {
                cheatTNCounter[id] = 0
                inCheatTimeTN[id] = 1
                set_task(cheatTime,"setInCheatTimeTNOff",id)
            }
        }
        set_task(2.0,"stopTNoclip",id)
        return PLUGIN_HANDLED
    }
    if(get_user_noclip(id) == 1) {
        set_user_noclip(id,0)
        client_print(id,print_center,"[%s] You no longer have NoClip on",cp_pluginname)
        client_print(0,print_chat,"[%s] %s Now has NoClip off",cp_pluginname,name)
        return PLUGIN_HANDLED
    }
    client_print(0,print_chat,"[%s] Error...NoClip Wasn't On Or Off??? Inaccurate Statement",cp_pluginname)
    return PLUGIN_HANDLED
}

/* other stuff */

public AdminSetAutoHeal(id,level,cid)
{
	if ( !cmd_access(id,level,cid,2) ) 
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}

	new arg1[32]
	read_argv(1,arg1,31)
	strtolower(arg1)
	if ( equali(arg1,"off") || equali(arg1,"0") ) {
	  set_cvar_num("kz_autoheal",0)
	  client_print(id,print_console,"[%s] AutoHeal Disabled",cp_pluginname)
	}else{
	  set_cvar_num("kz_autoheal",1)
	  client_print(id,print_console,"[%s] AutoHeal Enabled",cp_pluginname)
	}
	
	return PLUGIN_HANDLED
}

public AdminSetTNMode(id,level,cid)
{
	if ( !cmd_access(id,level,cid,2) ) 
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}

	new arg1[32]
	read_argv(1,arg1,31)
	strtolower(arg1)
	if ( equali(arg1,"off") || equali(arg1,"0") ) {
	  set_cvar_num("cp_noclip_mode",0)
	  client_print(id,print_console,"[%s] Self-Noclip cheat-detection Disabled",cp_pluginname)
	}else{
	  set_cvar_num("cp_noclip_mode",1)
	  client_print(id,print_console,"[%s] Self-Noclip cheat-detection Enabled",cp_pluginname)
	}
	
	return PLUGIN_HANDLED
}

public AdminSetTNMax(id,level,cid)
{
	if ( !cmd_access(id,level,cid,2) ) 
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}

	new arg1[32]
	read_argv(1,arg1,31)
	if(strtonum(arg1) <= 0) {
		set_cvar_num("cp_noclip_mode",0)
		set_cvar_num("cp_noclip_max",3)
		client_print(id,print_console,"[%s] Self-Noclip mode set to off and max reset to 3",cp_pluginname)
	}
	set_cvar_num("cp_noclip_max",strtonum(arg1))
	client_print(id,print_console,"[%s] Self-Noclip max set to %i",cp_pluginname,strtonum(arg1))
		
	return PLUGIN_HANDLED
}

public AdminSetSelfNoclip(id,level,cid)
{
	if ( !cmd_access(id,level,cid,2) ) 
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}

	new arg1[32]
	read_argv(1,arg1,31)
	strtolower(arg1)
	if ( equali(arg1,"on") || equali(arg1,"1") ) {
	  set_cvar_num("cp_noclip",1)
	  client_print(id,print_console,"[%s] Self-Noclip ability Enabled",cp_pluginname)
	}else{
	  set_cvar_num("cp_noclip",0)
	  client_print(id,print_console,"[%s] Self-Noclip ability Disabled",cp_pluginname)
	}
	
	return PLUGIN_HANDLED
}

public AdminSetSelfGodMode(id,level,cid)
{
	if ( !cmd_access(id,level,cid,2) ) 
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}

	new arg1[32]
	read_argv(1,arg1,31)
	strtolower(arg1)
	if ( equali(arg1,"on") || equali(arg1,"1") ) {
	  set_cvar_num("cp_godmode",1)
	  client_print(id,print_console,"[%s] Self-Godmode ability Enabled",cp_pluginname)
	}else{
	  set_cvar_num("cp_godmode",0)
	  client_print(id,print_console,"[%s] Self-Godmode ability Disabled",cp_pluginname)
	}
	
	return PLUGIN_HANDLED
}

/* end */

public AdminNoclip(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,3) ) 
	  return PLUGIN_HANDLED 

	new arg1[32],arg2[32]
	read_argv(1,arg1,31)
	read_argv(2,arg2,31)
	new onoff = strtonum(arg2)

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
	  {
			set_user_noclip(plist[i],onoff)
			CheatDetect(plist[i],"NoClip")
	  }

	  console_print(id,"[%s] Set NoClip on everyone",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
	  {
			set_user_noclip(plist[i],onoff)
			CheatDetect(plist[i],"NoClip")
	  }
	  console_print(id,"[%s] Set NoClip on all %ss",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  set_user_noclip(player,onoff)
	  CheatDetect(player,"NoClip")
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set NoClip on ^"%s^"",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
}

public AdminSemiClip(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,3) ) 
	  return PLUGIN_HANDLED 

	new arg1[32],arg2[32]
	read_argv(1,arg1,31)
	read_argv(2,arg2,31)
	new onoff = strtonum(arg2)

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			Entvars_Set_Int(plist[i], EV_INT_solid, onoff ? 0:2)

	  console_print(id,"[%s] Set SemiClip on everyone",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			Entvars_Set_Int(plist[i], EV_INT_solid, onoff ? 0:2)
	  console_print(id,"[%s] Set Semiclip on all %ss",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  Entvars_Set_Int(player, EV_INT_solid, onoff ? 0:2)
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set Semiclip on ^"%s^"",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
}

public AdminGodMode(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,3) ) 
	  return PLUGIN_HANDLED 

	new arg1[32],arg2[32]
	read_argv(1,arg1,31)
	read_argv(2,arg2,31)
	new onoff = strtonum(arg2)

	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			set_user_godmode(plist[i],onoff)

	  console_print(id,"[%s] Set Godmode on everyone",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			set_user_godmode(plist[i],onoff)
	  console_print(id,"[%s] Set Godmode on all %ss",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  set_user_godmode(player,onoff)
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set Godmode on ^"%s^"",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
}

public AdminGlow(id,level,cid) 
{ 
	if ( !cmd_access(id,level,cid,5) ) 
	  return PLUGIN_HANDLED 

	new arg1[32], sred[8], sgreen[8], sblue[8], salpha[8], name2[32] 
	get_user_name(id,name2,31) 
	read_argv(1,arg1,31) 
	read_argv(2,sred,7) 
	read_argv(3,sgreen,7)	
	read_argv(4,sblue,7)	
	read_argv(5,salpha,7)	
	new ired = strtonum(sred) 
	new igreen = strtonum(sgreen) 
	new iblue = strtonum(sblue) 
	new ialpha = strtonum(salpha)  
	if ( equali(arg1,"@all") ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"a") 
	  if (pnum==0) 
	  { 
		 console_print(id,"[%s] There are no clients",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
			set_user_rendering(plist[i],kRenderFxGlowShell,ired,igreen,iblue,kRenderTransAlpha,ialpha) 

	  console_print(id,"[%s] Set Glow on everyone",cp_pluginname) 
	} 
	else if ( arg1[0]=='@' ) 
	{ 
	  new plist[32],pnum 
	  get_players(plist,pnum,"ae",arg1[1]) 
	  if ( pnum==0 ) 
	  { 
		 console_print(id,"[%s] No clients in such team",cp_pluginname) 
		 return PLUGIN_HANDLED 
	  } 
	  for (new i=0; i<pnum; i++) 
	  set_user_rendering(plist[i],kRenderFxGlowShell,ired,igreen,iblue,kRenderTransAlpha,ialpha)
	  console_print(id,"[%s] Set Glow on all %ss",cp_pluginname,arg1[1]) 
	} 
	else 
	{ 
	  new pName[32] 
	  new player = cmd_target(id,arg1,6) 
	  if (!player) return PLUGIN_HANDLED 
	  set_user_rendering(player,kRenderFxGlowShell,ired,igreen,iblue,kRenderTransAlpha,ialpha)
	  get_user_name(player,pName,31) 
	  console_print(id,"[%s] Set Glow on ^"%s^"",cp_pluginname,pName) 
	} 

	return PLUGIN_HANDLED 
}

public AdminTele(id,level,cid) {

	if ( !cmd_access(id,level,cid,2) ) 
	  return PLUGIN_HANDLED 

	new arg[32],TeleOrigin[3]
	
	read_argv(1,arg,31) 
	new TelePlayer = cmd_target(id,arg,6) 
	if (!TelePlayer) return PLUGIN_HANDLED 

	new argc = read_argc() 
	if (argc == 3) {
	  new arg2[32]
	  read_argv(2,arg2,31) 
	  new OrigPlayer = cmd_target(id,arg2,6) 
	  if (!OrigPlayer) return PLUGIN_HANDLED 
	  get_user_origin(OrigPlayer,TeleOrigin)
	  TeleOrigin[2]+=65
	}else{
	  new sx[8], sy[8], sz[8]
	  read_argv(2,sx,7) 
	  read_argv(3,sy,7)	
	  read_argv(4,sz,7)
	  TeleOrigin[0] = strtonum(sx) 
	  TeleOrigin[1] = strtonum(sy) 
	  TeleOrigin[2] = strtonum(sz) 
	}
	set_user_origin(TelePlayer, TeleOrigin)
	
	new pName[32]
	get_user_name(TelePlayer,pName,31) 
	CheatDetect(TelePlayer,"Teleport")
	console_print(id,"[%s] Teleported ^"%s^" to x:%i y:%i z%i",cp_pluginname,pName,TeleOrigin[0],TeleOrigin[1],TeleOrigin[2]) 
	return PLUGIN_HANDLED  
} 

/************************************************************************************************************************/
/***************************************************** NVG CONTROL ******************************************************/
/************************************************************************************************************************/

public NVGToggle(id) {
	if (get_cvar_num("kz_nightvision")==0) return PLUGIN_CONTINUE

	if (NVGrun[id]==1) NVGcmd(id,0) 
	else NVGcmd(id,1)
	return PLUGIN_HANDLED
}
/************************************************************************************************************************/
public NVGcmd(id,state) {
	message_begin(MSG_ONE, get_user_msgid("NVGToggle"), {0,0,0}, id) 
	write_byte( state ) 
	message_end()
	NVGrun[id]=state
	emit_sound(id,CHAN_ITEM, NVGrun[id]?"items/nvg_on.wav":"items/nvg_off.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
/************************************************************************************************************************/
/******************************************************* JEDIGRAB *******************************************************/
/************************************************************************************************************************/
new grabbed[33]
new grablength[33]
new bool:grabmodeon[33]
new velocity_multiplier

public grabtask(parm[])
{
	new id = parm[0]
	new targetid, body
	if (!grabbed[id])
	{
		get_user_aiming(id, targetid, body)
		if (targetid)
		{
			set_grabbed(id, targetid)
		}
	}
	if (grabbed[id])
	{
		new origin[3], look[3], direction[3], moveto[3], grabbedorigin[3], velocity[3], length

		if (!is_user_alive(grabbed[id]))
		{
			release(id)
			return
		}

		get_user_origin(id, origin, 1)
		get_user_origin(id, look, 3)
		get_user_origin(grabbed[id], grabbedorigin)

		direction[0]=look[0]-origin[0]
		direction[1]=look[1]-origin[1]
		direction[2]=look[2]-origin[2]
		length = get_distance(look,origin)
		if (!length) length=1				// avoid division by 0

		moveto[0]=origin[0]+direction[0]*grablength[id]/length
		moveto[1]=origin[1]+direction[1]*grablength[id]/length
		moveto[2]=origin[2]+direction[2]*grablength[id]/length

		velocity[0]=(moveto[0]-grabbedorigin[0])*velocity_multiplier
		velocity[1]=(moveto[1]-grabbedorigin[1])*velocity_multiplier
		velocity[2]=(moveto[2]-grabbedorigin[2])*velocity_multiplier

		set_user_velocity(grabbed[id], velocity)
	}
}

public grab_toggle(id)
{
	if (grabmodeon[id])
		release(id)
	else
		grab(id)
	return PLUGIN_HANDLED
}

public grab(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_D))
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}
	if (!grabmodeon[id])
	{
		new targetid, body
		new parm[1]
		parm[0] = id
		velocity_multiplier = get_cvar_num("kz_grabforce")
		grabmodeon[id]=true
		set_task(0.1, "grabtask", 100+id, parm, 1, "b")
		get_user_aiming(id, targetid, body)
		if (targetid)
		{
			set_grabbed(id, targetid)
		}
		else
		{
			client_print(id,print_chat,"[%s] Searching for a target",cp_pluginname)
		}
	}
	return PLUGIN_HANDLED
}

public release(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_D))
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}
	if (grabmodeon[id])
	{
		grabmodeon[id]=false
		if (grabbed[id])
		{
			new targname[32]
			set_user_gravity(grabbed[id])
			set_user_rendering(grabbed[id])
			get_user_name(grabbed[id],targname,31)
			client_print(id,print_chat,"[%s] You have released %s", cp_pluginname, targname)
		}
		else
		{
			client_print(id,print_chat,"[%s] No target found",cp_pluginname)
		}
		grabbed[id]=0
		remove_task(100+id)
	}
	return PLUGIN_HANDLED
}

public spec_event(id)
{
	new targetid = read_data(2)

	if (targetid < 1 || targetid > 32)
		return PLUGIN_CONTINUE

	if (grabmodeon[id] && !grabbed[id])
	{
		set_grabbed(id, targetid)
	}
	return PLUGIN_CONTINUE
}

public set_grabbed(id, targetid)
{
	new origin1[3], origin2[3], targname[32]
	get_user_origin(id, origin1)
	get_user_origin(targetid, origin2)
	grabbed[id]=targetid
	grablength[id]=get_distance(origin1,origin2)
	set_user_gravity(targetid,0.001)
	set_user_rendering(targetid,kRenderFxGlowShell,50,0,0, kRenderNormal, 16)
	get_user_name(targetid,targname,31)
	client_print(id,print_chat,"[%s] You have grabbed onto %s", cp_pluginname, targname)
}

/************************************************************************************************************************/
/****************************************************** NINJAROPE *******************************************************/
/************************************************************************************************************************/

public ropetask(parm[])
{
	new id = parm[0]
	new user_origin[3], user_look[3], user_direction[3], move_direction[3]
	new A[3], D[3], buttonadjust[3]
	new acceleration, velocity_towards_A, desired_velocity_towards_A
	new velocity[3], null[3]

	if (!is_user_alive(id))
	{
		RopeRelease(id)
		return
	}

	if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
	{
		beamentpoint(id)
	}

	null[0] = 0
	null[1] = 0
	null[2] = 0

	get_user_origin(id, user_origin)
	get_user_origin(id, user_look,2)
	get_user_velocity(id, velocity)

	buttonadjust[0]=0
	buttonadjust[1]=0

	if (get_user_button(id)&IN_FORWARD)		buttonadjust[0]+=1
	if (get_user_button(id)&IN_BACK)		buttonadjust[0]-=1
	if (get_user_button(id)&IN_MOVERIGHT)	buttonadjust[1]+=1
	if (get_user_button(id)&IN_MOVELEFT)	buttonadjust[1]-=1
	if (get_user_button(id)&IN_JUMP)		buttonadjust[2]+=1
	if (get_user_button(id)&IN_DUCK)		buttonadjust[2]-=1

	if (buttonadjust[0] || buttonadjust[1])
	{
		user_direction[0] = user_look[0] - user_origin[0]
		user_direction[1] = user_look[1] - user_origin[1]

		move_direction[0] = buttonadjust[0]*user_direction[0] + user_direction[1]*buttonadjust[1]
		move_direction[1] = buttonadjust[0]*user_direction[1] - user_direction[0]*buttonadjust[1]
		move_direction[2] = 0

		velocity[0] += floatround(move_direction[0] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
		velocity[1] += floatround(move_direction[1] * MOVEACCELERATION * DELTA_T / get_distance(null,move_direction))
	}

	if (buttonadjust[2])	gHookLenght[id] -= floatround(buttonadjust[2] * REELSPEED * DELTA_T)
	if (gHookLenght[id] < 100) gHookLenght[id] = 100

	A[0] = gHookLocation[id][0] - user_origin[0]
	A[1] = gHookLocation[id][1] - user_origin[1]
	A[2] = gHookLocation[id][2] - user_origin[2]

	D[0] = A[0]*A[2] / get_distance(null,A)
	D[1] = A[1]*A[2] / get_distance(null,A)
	D[2] = -(A[1]*A[1] + A[0]*A[0]) / get_distance(null,A)

	acceleration = - global_gravity * D[2] / get_distance(null,D)

	velocity_towards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance(null,A)
	desired_velocity_towards_A = (get_distance(user_origin,gHookLocation[id]) - gHookLenght[id] /*- 10*/) * 4

	if (get_distance(null,D)>10)
	{
		velocity[0] += floatround((acceleration * DELTA_T * D[0]) / get_distance(null,D))
		velocity[1] += floatround((acceleration * DELTA_T * D[1]) / get_distance(null,D))
		velocity[2] += floatround((acceleration * DELTA_T * D[2]) / get_distance(null,D))
	}

	velocity[0] += ((desired_velocity_towards_A - velocity_towards_A) * A[0]) / get_distance(null,A)
	velocity[1] += ((desired_velocity_towards_A - velocity_towards_A) * A[1]) / get_distance(null,A)
	velocity[2] += ((desired_velocity_towards_A - velocity_towards_A) * A[2]) / get_distance(null,A)

	set_user_velocity(id, velocity)
}

public hooktask(parm[])
{ 
	new id = parm[0]
	new velocity[3]

	if ( !gIsHooked[id] ) return 
	
	new user_origin[3],oldvelocity[3]
	parm[0] = id

	if (!is_user_alive(id))
	{
		RopeRelease(id)
		return
	}

	if (gBeamIsCreated[id] + BEAMLIFE/10 <= get_gametime())
	{
		beamentpoint(id)
	}

	get_user_origin(id, user_origin) 
	get_user_velocity(id, oldvelocity) 
	new distance=get_distance( gHookLocation[id], user_origin )
	if ( distance > 10 ) 
	{ 
		velocity[0] = floatround( (gHookLocation[id][0] - user_origin[0]) * ( 2.0 * REELSPEED / distance ) )
		velocity[1] = floatround( (gHookLocation[id][1] - user_origin[1]) * ( 2.0 * REELSPEED / distance ) )
		velocity[2] = floatround( (gHookLocation[id][2] - user_origin[2]) * ( 2.0 * REELSPEED / distance ) )
	} 
	else
	{
		velocity[0]=0
		velocity[1]=0
		velocity[2]=0
	}

	set_user_velocity(id, velocity) 
	
} 

public hook_on(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_E))
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}
	if (!gIsHooked[id] && is_user_alive(id))
	{
		new cmd[32]
		read_argv(0,cmd,31)
		if(equal(cmd,"+rope")) RopeAttach(id,0)
		if(equal(cmd,"+hook")) RopeAttach(id,1)
	}
	return PLUGIN_HANDLED
}

public hook_off(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_E))
	{
		client_print(id,print_chat,"[%s] You have no access to that command",cp_pluginname)
		return PLUGIN_HANDLED
	}
	if (gIsHooked[id])
	{
		RopeRelease(id)
	}
	return PLUGIN_HANDLED
}

public RopeAttach(id,hook)
{
	CheatDetect(id,"Hook/Rope")
	new parm[1], user_origin[3]
	parm[0] = id
	gIsHooked[id] = true
	get_user_origin(id,user_origin)
	get_user_origin(id,gHookLocation[id], 3)
	gHookLenght[id] = get_distance(gHookLocation[id],user_origin)
	global_gravity = get_cvar_num("sv_gravity")
	set_user_gravity(id,0.001)
	beamentpoint(id)
	emit_sound(id, CHAN_STATIC, "weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	if (hook) set_task(DELTA_T, "hooktask", 200+id, parm, 1, "b")
	else set_task(DELTA_T, "ropetask", 200+id, parm, 1, "b")
}

public RopeRelease(id)
{
	gIsHooked[id] = false
	killbeam(id)
	set_user_gravity(id)
	remove_task(200+id)
}

public beamentpoint(id)
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
	write_byte( TE_BEAMENTPOINT )
	write_short( id )
	write_coord( gHookLocation[id][0] )
	write_coord( gHookLocation[id][1] )
	write_coord( gHookLocation[id][2] )
	write_short( beam )	// sprite index
	write_byte( 0 )		// start frame
	write_byte( 0 )		// framerate
	write_byte( BEAMLIFE )	// life
	write_byte( 10 )	// width
	write_byte( 0 )		// noise
	if (get_user_team(id)==1)		// Terrorist
	{
		write_byte( 255 )	// r, g, b
		write_byte( 0 )	// r, g, b
		write_byte( 0 )	// r, g, b
	}
	else							// Counter-Terrorist
	{
		write_byte( 0 )	// r, g, b
		write_byte( 0 )	// r, g, b
		write_byte( 255 )	// r, g, b
	}
	write_byte( 150 )	// brightness
	write_byte( 0 )		// speed
	message_end( )
	gBeamIsCreated[id] = get_gametime()
}

public killbeam(id)
{
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
	write_byte( TE_KILLBEAM )
	write_short( id )
	message_end()
}

/************************************************************************************************************************/
/******************************************************* FORWARDS *******************************************************/
/************************************************************************************************************************/

public client_disconnect(id) {
	gCheckpoint[id]=false
	gJoined[id]=false
	ResetTimer(id,0)
}

/*#if defined NO_STEAM() {*/
public client_putinserver(id) {
/*#else
public client_authorized(id) {
#endif*/
	gJoined[id]=true
	gCheckpoint[id]=false
	gMoney[id]=gStartMoney
	ResetTimer(id,0)
}


public vexd_pfntouch(pToucher, pTouched)
{
	new pTouchername[32], pTouchedname[32],pToucherTarget[32],pToucherTargetname[32]
	Entvars_Get_String(pToucher, EV_SZ_classname, pTouchername, 31)
	Entvars_Get_String(pTouched, EV_SZ_classname, pTouchedname, 31)
	Entvars_Get_String(pToucher, EV_SZ_targetname, pToucherTargetname, 31)
	Entvars_Get_String(pToucher, EV_SZ_target, pToucherTarget, 31)

	if(pToucher == 0 || pTouched == 0) return // note this is only a quick fix!

	if(equal(pTouchername, "func_button") && equal(pTouchedname, "player"))
	{
		if (get_cvar_num("kz_timer")==1) {
			if (equal(pToucherTarget, "counter_start") && !gHasTimer[pTouched] || equal(pToucherTargetname, "clockstartbutton") && !gHasTimer[pTouched]) {
				gHasTimer[pTouched]=true
				client_print(pTouched,print_chat,"[%s] Timer Started",cp_pluginname)
				gCheckpoint[pTouched]=false
			}
			if (equal(pToucherTarget, "counter_off") && gHasTimer[pTouched] && !gHasStoppedTimer[pTouched] || equal(pToucherTargetname, "clockstopbutton") && gHasTimer[pTouched] && !gHasStoppedTimer[pTouched] ) {
				new gName[33]
				gHasStoppedTimer[pTouched]=true
				gHasTimer[pTouched]=false
				get_user_name(pTouched,gName,32)
				client_print(pTouched,print_chat,"[%s] Timer Stopped",cp_pluginname)
				if (get_cvar_num("kz_checkpoints") == 1) client_print(0,print_chat,"[%s] %s just beat the map in %d:%d:%d (Used %d Checkpoints)",cp_pluginname,gName,gMins[pTouched],gSecs[pTouched],gHuns[pTouched],gChecks[pTouched])
				else client_print(0,print_chat,"[%s] %s just beat the map in %d:%d:%d",cp_pluginname,gName,gMins[pTouched],gSecs[pTouched],gHuns[pTouched])
			}
		}
	}

}
/************************************************************************************************************************/
/**************************************************** TIMER & TOP-10 ****************************************************/
/************************************************************************************************************************/

public gTimerTask() {
	for (new id=1;id<33;id++) {
		if(gHasTimer[id]) {
			gHuns[id]+=10
			if (gHuns[id] == 100) {
				gHuns[id]  = 00
				gSecs[id] += 1
			}
			if (gSecs[id] == 60) {
				gSecs[id]  = 00
				gMins[id] += 1
			}
			if (gMins[id] == 120) {
				gMins[id]  = 00
				ResetTimer(id,1)
				if (is_user_connected(id)) client_print(id,print_center,"Sorry You Used Too Long Time")
			}
			new sMins[33][2],sSecs[33][2],sHuns[33][2]
			if (gHuns[id]==0) {
				format(sHuns[id],2,"00",gHuns[id])
			} else {
				format(sHuns[id],2,"%d",gHuns[id])
			}
			if (gSecs[id]<10) {
				format(sSecs[id],2,"0%d",gSecs[id])
			} else {
				format(sSecs[id],2,"%d",gSecs[id])
			}
			if (gMins[id]<10) {
				format(sMins[id],2,"0%d",gMins[id])
			} else {
				format(sMins[id],2,"%d",gMins[id])
			}
			if (is_user_connected(id)) client_print(id,print_center,"%s:%s:%s",sMins[id],sSecs[id],sHuns[id])
		}
	}
}

public ResetTimer(id,msg) 
{
	if (msg==1) client_print(id,print_chat,"[%s] Timer Reset...",cp_pluginname)
	gHasTimer[id]=false
	gHasStoppedTimer[id]=false
	gSecs[id]=0
	gMins[id]=0
	gHuns[id]=0
	gChecks[id]=0
}