/****************************** AMX Mod script. ****************************************
*
*  >Stalkermode<
*   **  *    *   *    *  *  **** ***  **   **  ****  ****   ****
*  *   ***  * *  *    * *   *    *  * * * * * *    * *   *  *
*   *   *   ***  *    **    ***  ***  *  *  * *    * *   ** ***
*    *  *  *   * *    * *   *    * *  *     * *    * *   *  *
*  **   ** *   * **** *  *  **** *  * *     *  ****  ****   ****
*
*  by Scarzzurs/The_Unbound
*  email: Scarzzurs@hotmail.com
*  MSN: Scarzzurs@hotmail.com
*  ICQ#: 84124020
*
*  version:2.05
*
*****************************************************************************************/

#include <amxmod>
#include <amxmisc>
#include <xtrafun>
#include <Vexd_Utilities>

new const HEGRENADE_MODEL[] = "models/w_hegrenade.mdl"

new StalkerMenu
new gmsgFade
new Float:sv_stalkerchangetimer = 0.0
new Float:stalker_gravity = 0.55
new Float:vampiric = 0.25
new Float:oldspeed[33]
new xp[33]
new slevel[33]
new bool:lastroundended
new bool:freezetime_ended = true
new bool:hasgrenade[33]
new bool:firstround[33]
new bool:usingmenu[33]
new bool:newplayer[33]
new bool:stalkeron[33]
new bool:used_fog[33]
new player_origin1[33][3]
new disappearrender = 3
new corpsehp = 25
new shockwave
new smoke

public givexp(id){
	if (get_cvar_num("sv_stalkerxp")==1){
		xp[id] = (xp[id] + 20)
		new plevel = slevel[id]
		slevel[id] = (xp[id] / 100)
		if (plevel != slevel[id])
			if (get_cvar_num("sv_stalkershow")==1){
				new sname[32]
				get_user_name(id,sname,32)
				set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
				show_hudmessage(0,"%s is now level %i",sname,slevel[id])
			}
		}
}

//Took this from a plugin made by Spacedude and added/changed stuff
public death(){
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_CONTINUE
	new killer_id = read_data(1)
	new victim_id = read_data(2)
	if (stalkeron[victim_id]){
		new victim_origin[3]
		get_user_origin(victim_id,victim_origin)

		message_begin( MSG_BROADCAST,SVC_TEMPENTITY,victim_origin )
		write_byte( 14 )
		write_coord(victim_origin[0])
		write_coord(victim_origin[1])
		write_coord(victim_origin[2])
		write_byte( 100 )
		write_byte( 20 )
		write_byte( 5 )
		message_end()

		message_begin( MSG_BROADCAST,SVC_TEMPENTITY,victim_origin )
		write_byte( 5 )
		write_coord(victim_origin[0])
		write_coord(victim_origin[1])
		write_coord(victim_origin[2])
		write_short( smoke )
		write_byte( 25 )
		write_byte( 10 )
		message_end()

		message_begin( MSG_PAS, SVC_TEMPENTITY, victim_origin )
		write_byte( 21 )
		write_coord( victim_origin[0])
		write_coord( victim_origin[1])
		write_coord( victim_origin[2] - 16)
		write_coord( victim_origin[0])
		write_coord( victim_origin[1])
		write_coord( victim_origin[2] + 16 - 250)
		write_short( shockwave )
		write_byte( 0 )
		write_byte( 0 )
		write_byte( 6 )
		write_byte( 16 )
		write_byte( 0 )
		write_byte( 188 )
		write_byte( 220 )
		write_byte( 255 )
		write_byte( 255 )
		write_byte( 0 )
		message_end()

		message_begin( MSG_PAS, SVC_TEMPENTITY, victim_origin )
		write_byte( 21 )
		write_coord( victim_origin[0])
		write_coord( victim_origin[1])
		write_coord( victim_origin[2] - 16)
		write_coord( victim_origin[0])
		write_coord( victim_origin[1])
		write_coord( victim_origin[2] + 16 - ( 250 / 2 ))
		write_short( shockwave )
		write_byte( 0 )
		write_byte( 0 )
		write_byte( 6 )
		write_byte( 16 )
		write_byte( 0 )
		write_byte( 188 )
		write_byte( 220 )
		write_byte( 255 )
		write_byte( 255 )
		write_byte( 0 )
		message_end()

		victim_origin[2] = victim_origin[2]-30
		set_user_origin(victim_id,victim_origin)
		set_user_rendering(victim_id,kRenderFxNone, 0,0,0, kRenderTransTexture,disappearrender)
	}
	if (stalkeron[killer_id]){
		if (killer_id != victim_id){
			set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
			show_hudmessage(victim_id,"you have been killed by a stalker!")
			givexp(killer_id)
		}
		set_user_health(killer_id, get_user_health(killer_id) + corpsehp)
		if (get_user_health(killer_id) > (get_cvar_num("sv_stalkerhealth")))
			set_user_health(killer_id, (get_cvar_num("sv_stalkerhealth")))
	}
	return PLUGIN_CONTINUE
}

//Took some of this from a plugin made by Spacedude and added/changed stuff
public damage_event(id){
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_CONTINUE
	new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)
	new damage
	damage = read_data(2)
	new glowdamage = damage +20
	if (glowdamage >= 95)
		glowdamage = 95
	if (attacker==id && weapon==0)
		return PLUGIN_CONTINUE
	else if (attacker==0)
		return PLUGIN_CONTINUE
	if (stalkeron[attacker]){
		message_begin(MSG_ONE, gmsgFade, {0,0,0}, attacker)
		write_short( 1<<10 )
		write_short( 1<<10 )
		write_short( 1<<12 )
		write_byte( 255 )
		write_byte( 0 )
		write_byte( 0 )
		write_byte( glowdamage )
		message_end()

		new Float:special = 0.0
		if (weapon == 4){
			if (damage < get_user_health(id)){
				new damage3
				damage3 = floatround(float(damage) * 1.5)
				if (get_user_health(id) < damage3){
					new money = get_user_money(attacker)
					set_user_money(attacker,money + 300,1)
					new frags = get_user_frags(attacker)
					set_user_frags(attacker, frags + 1)
					user_kill(id,1)
					givexp(attacker)
				}
				else	set_user_health(id, get_user_health(id) - damage3)
				special = 1.5
			}
		}
		else if (damage < 50){
			if (damage < get_user_health(id)){
				new damage4
				damage4 = floatround(float(damage) * 2)
				if (get_user_health(id) < damage4)
					damage4 = (get_user_health(id) - 1)
				set_user_health(id, get_user_health(id) - damage4)
				special = 2.0
			}
		}
		new damage2
		if (special != 0){
			new damage5
			damage5 = floatround(float(damage) * vampiric)
			damage2 = floatround(float(damage5) * special)
		}
		else	damage2 = floatround(float(damage) * vampiric)

		set_user_health(attacker, get_user_health(attacker) + damage2)
		if (get_cvar_num("sv_stalkerxp")==1){
			new xtrahp = (slevel[attacker] * 5)
			if (get_user_health(attacker) > (get_cvar_num("sv_stalkerhealth") + xtrahp ))
				set_user_health(attacker,(get_cvar_num("sv_stalkerhealth") + xtrahp ))
		}
		else if (get_user_health(attacker) > (get_cvar_num("sv_stalkerhealth")))
				set_user_health(attacker, (get_cvar_num("sv_stalkerhealth")))
	}
	return PLUGIN_CONTINUE
}

public switchweapon(id){
	if (stalkeron[id] && get_cvar_num("sv_stalker")==1){
		if (read_data(2)==29){
			if (freezetime_ended == true)
				set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
			return PLUGIN_CONTINUE
		}
		else if (read_data(2)==6){
			if (freezetime_ended == true)
				set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
			return PLUGIN_CONTINUE
		}
		else if (read_data(2)==25){
			if (freezetime_ended == true)
				set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
			return PLUGIN_CONTINUE
		}
		else if (read_data(2)==4){
			if (freezetime_ended == true)
				set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
			return PLUGIN_CONTINUE
		}
		else if (read_data(2)==9){
			if (freezetime_ended == true)
				set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
			return PLUGIN_CONTINUE
		}
		engclient_cmd(id,"weapon_knife")
		if (freezetime_ended == true)
			set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
		client_print(id,print_chat,"Stalkers can only use knives and grenades")
	}
	return PLUGIN_CONTINUE
}

public upcraft(parm[1]){
	if (get_cvar_num("sv_stalker")==1){
		new id = parm[0]
		if (get_user_button(id)&IN_JUMP){
			new velocity[3]
			get_user_velocity(id,velocity)
			velocity[2] = velocity[2] + 105
			set_user_velocity(id,velocity)
		}
	}
}

//Added By AssKicR
public admin_stalk(id,level,cid){ 
   if (!cmd_access(id,level,cid,2)) 
      return PLUGIN_HANDLED 
   new arg[32], name2[32] 
   get_user_name(id,name2,31) 
   read_argv(1,arg,31) 
   
   if (arg[0]=='@'){ 
      new players[32], inum 
      get_players(players,inum,"ae",arg[1]) 
      if (inum==0){ 
         console_print(id,"No clients in such team") 
         return PLUGIN_HANDLED 
      } 
      for(new a=0;a<inum;++a) 
         admin_aktivate(players[a]) 
      switch(get_cvar_num("amx_show_activity")){ 
   case 2:   client_print(0,print_chat,"ADMIN %s: made all %s stalkers",name2,arg[1]) 
   case 1:   client_print(0,print_chat,"ADMIN: Maka all %s stalkers",arg[1]) 
      } 
      console_print(id,"All clients are now Stalkers") 
   } 
   else { 
      new player = cmd_target(id,arg,2) 
      if (!player) return PLUGIN_HANDLED
      admin_aktivate(player) 
      new name[32]
      get_user_name(player,name,31) 
      switch(get_cvar_num("amx_show_activity")){ 
   case 2:   client_print(0,print_chat,"ADMIN %s: Made %s a stalker",name2,name) 
   case 1:   client_print(0,print_chat,"ADMIN: Made %s a stalker",name) 
      } 
      console_print(id,"Client ^"%s^" is now a stalker",name) 
   } 
   return PLUGIN_HANDLED  
} 

//Added By AssKicR
public admin_unstalk(id,level,cid){ 
   if (!cmd_access(id,level,cid,2)) 
      return PLUGIN_HANDLED 
   new arg[32], name2[32] 
   get_user_name(id,name2,31) 
   read_argv(1,arg,31)
   
   if (arg[0]=='@'){ 
      new players[32], inum 
      get_players(players,inum,"ae",arg[1]) 
      if (inum==0){ 
         console_print(id,"No clients in such team") 
         return PLUGIN_HANDLED 
      }
      for(new a=0;a<inum;++a) 
         admin_deaktivate(players[a]) 
      switch(get_cvar_num("amx_show_activity")){ 
   case 2:   client_print(0,print_chat,"ADMIN %s: removed all %s stalkerabilities",name2,arg[1]) 
   case 1:   client_print(0,print_chat,"ADMIN: Removed all %s stalkerabilities",arg[1]) 
      }
      console_print(id,"No clients are now Stalkers") 
   }
   else {
      new player = cmd_target(id,arg,2) 
      if (!player) return PLUGIN_HANDLED
      admin_deaktivate(player) 
      new name[32] 
      get_user_name(player,name,31) 
      switch(get_cvar_num("amx_show_activity")){ 
   case 2:   client_print(0,print_chat,"ADMIN %s: Removed %s stalkerabilities",name2,name) 
   case 1:   client_print(0,print_chat,"ADMIN: Removed %s stalkerabilities",name) 
      } 
      console_print(id,"Client ^"%s^" is not a stalker",name) 
   } 
   return PLUGIN_HANDLED  
}

public admin_aktivate(id){
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_CONTINUE

	new sname[32]
	get_user_name(id,sname,32)
	if (get_cvar_num("sv_stalkershow")==1){
		set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
		show_hudmessage(0,"%s has become a stalker",sname)
		if (file_exists("sound/stalker/ghost.wav")==1)
			emit_sound(id,CHAN_STATIC, "stalker/ghost.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	new parm[1]
	parm[0] = id
	set_task(0.5,"upcraft",id,parm,1,"b")
	set_task(1.0,"check_speed",50+id,parm,1,"b")
	stalkeron[id]=true
	newplayer[id]=false
	oldspeed[id] = get_user_maxspeed(id)
	engclient_cmd(id,"weapon_knife")
	stalker_abilities(id)
	if (get_cvar_num("sv_stalkerrunspeed") > 400){
		client_cmd(id,"cl_forwardspeed 10000; cl_sidespeed 10000; cl_backspeed 10000")
		client_cmd(id,"cl_forwardspeed 10000")
		client_cmd(id,"cl_sidespeed 10000")
		client_cmd(id,"cl_backspeed 10000")
	}
	client_print(id,print_chat,"You are now a stalker!")
	return PLUGIN_HANDLED
}

public admin_deaktivate(id){
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_CONTINUE
		
	stalkeron[id]=false
	new sname[32]
	get_user_name(id,sname,32)
	if (get_cvar_num("sv_stalkershow")==1){
		set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
		show_hudmessage(0,"%s is not a stalker anymore",sname)
	}
	client_print(id,print_chat,"you are not a stalker!")
	remove_abilities(id)
	return PLUGIN_HANDLED
}

public stalker_abilities(id){
	if (is_user_alive(id)){
		if (get_cvar_num("sv_stalkerchangemodel")==1)
			CS_SetModel(id,"vip")
		else CS_ClearModel(id)
		if (freezetime_ended == true)
			set_user_maxspeed(id,(get_cvar_float("sv_stalkerrunspeed")))
		if (get_cvar_num("sv_stalkernohs")==1)
			set_user_hitzones(0,id, 255 - 2 )
		give_item(id,"item_assaultsuit")
		set_user_gravity(id,stalker_gravity)
		if (get_cvar_num("sv_stalkerxp")==1){
			new xtrahp = (slevel[id] * 5)
			set_user_health(id,(get_cvar_num("sv_stalkerhealth")) + xtrahp)
		}
		else set_user_health(id,(get_cvar_num("sv_stalkerhealth")))
		set_user_armor(id,(get_cvar_num("sv_stalkerhealth")))
		set_user_footsteps(id)
		set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderTransTexture,get_cvar_num("sv_stalkerinvisibility"))
	}
}

public remove_abilities(id){
	CS_ClearModel(id)
	remove_task(id)
	remove_task(50+id)
	set_user_hitzones(id)
	set_user_health(id,100)
	set_user_armor(id,0)
	set_user_footsteps(id,0)
	set_user_maxspeed(id,oldspeed[id])
	set_user_gravity(id,1.0)
	set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderTransTexture,255)
}

public aktivate_stalk(id){
	if (get_cvar_num("sv_stalker")!=1){
		if (usingmenu[id]){
			client_print(id,print_chat,"Stalkermode is not enabled")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo Stalkermode is not enabled")
		return PLUGIN_HANDLED
	}
	if (get_cvar_num("sv_stalkerselfallowed")!=1){
		if (usingmenu[id]){
			client_print(id,print_chat,"Stalkerself is not allowed")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo Stalkerself is not allowed")
		return PLUGIN_HANDLED
	}
	if (stalkeron[id]==true){
		if (usingmenu[id]){
			client_print(id,print_chat,"You are a stalker!")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo You are a stalker!")
		return PLUGIN_HANDLED
	}
	if (newplayer[id]==true){
		new sname[32]
		get_user_name(id,sname,32)
		if (get_cvar_num("sv_stalkershow")==1){
			set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
			show_hudmessage(0,"%s has become a stalker",sname)
			if (file_exists("sound/stalker/ghost.wav")==1)
				emit_sound(id,CHAN_STATIC, "stalker/ghost.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
		}
		new parm[1]
		parm[0] = id
		set_task(0.5,"upcraft",id,parm,1,"b")
		set_task(1.0,"check_speed",50+id,parm,1,"b")
		stalkeron[id]=true
		newplayer[id]=false
		oldspeed[id] = get_user_maxspeed(id)
		engclient_cmd(id,"weapon_knife")
		stalker_abilities(id)
		if (get_cvar_num("sv_stalkerrunspeed") > 400){
			client_cmd(id,"cl_forwardspeed 10000; cl_sidespeed 10000; cl_backspeed 10000")
			client_cmd(id,"cl_forwardspeed 10000")
			client_cmd(id,"cl_sidespeed 10000")
			client_cmd(id,"cl_backspeed 10000")
		}
		if (usingmenu[id]){
			client_print(id,print_chat,"You are now a stalker!")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo You are now a stalker!")
		return PLUGIN_HANDLED
	}
	new gametime
	gametime = floatround(get_gametime())
	if (sv_stalkerchangetimer >= gametime){
		new sname[32]
		get_user_name(id,sname,32)
		if (get_cvar_num("sv_stalkershow")==1){
			set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
			show_hudmessage(0,"%s has become a stalker",sname)
			if (file_exists("sound/stalker/ghost.wav")==1)
				emit_sound(id,CHAN_STATIC, "stalker/ghost.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
		}
		new parm[1]
		parm[0] = id
		set_task(0.5,"upcraft",id,parm,1,"b")
		set_task(1.0,"check_speed",50+id,parm,1,"b")
		oldspeed[id] = get_user_maxspeed(id)
		engclient_cmd(id,"weapon_knife")
		client_cmd(id,"echo You are now a stalker!")
		stalkeron[id]=true
		newplayer[id]=false
		stalker_abilities(id)
		if (get_cvar_num("sv_stalkerrunspeed") > 400){
			client_cmd(id,"cl_forwardspeed 10000; cl_sidespeed 10000; cl_backspeed 10000")
			client_cmd(id,"cl_forwardspeed 10000")
			client_cmd(id,"cl_sidespeed 10000")
			client_cmd(id,"cl_backspeed 10000")
		}
	}
	else{
		if (usingmenu[id]){
			client_print(id,print_chat,"It is toolate, try next round")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo It is toolate, try next round")
	}
	return PLUGIN_HANDLED
}

public deaktivate_stalk(id){
	if (get_cvar_num("sv_stalker")!=1){
		if (usingmenu[id]){
			client_print(id,print_chat,"Stalkermode is not enabled")
			usingmenu[id]=false
		}
		else client_cmd(id,"echo Stalkermode is not enabled")
		return PLUGIN_HANDLED
	}
	if (get_cvar_num("sv_stalkerselfallowed")!=1){
		if (usingmenu[id]){
			client_print(id,print_chat,"Stalkerself is not allowed")
			usingmenu[id]=false
		}
		else client_cmd(id,"echo Stalkerself is not allowed")
		return PLUGIN_HANDLED
	}
	new gametime
	gametime = floatround(get_gametime())
	if (sv_stalkerchangetimer >= gametime){
		stalkeron[id]=false
		new sname[32]
		get_user_name(id,sname,32)
		if (get_cvar_num("sv_stalkershow")==1){
			set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 3)
			show_hudmessage(0,"%s is not a stalker anymore",sname)
      	}
		remove_abilities(id)
		if (usingmenu[id]){
			client_print(id,print_chat,"you are not a stalker!")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo you are not a stalker!")
	}
	else{
		if (usingmenu[id]){
			client_print(id,print_chat,"It is toolate, try next round")
			usingmenu[id]=false
		}
		else	client_cmd(id,"echo It is toolate, try next round")
	}
	return PLUGIN_HANDLED
}

public who_is_stalker(id){
	if (get_cvar_num("sv_stalkershow")==1){
		if (get_cvar_num("sv_stalker")==1){
			new bool:works = false
			if (usingmenu[id]){
				client_print(id,print_chat,"Stalkers:")
			}
			else	client_print(id,print_console,"Stalkers:")
			new players[32]
			new player_num
			get_players(players, player_num)
			for (new i = 0; i < player_num; i++){
				if (stalkeron[players[i]]){
					new sname[32]
					get_user_name(players[i],sname,32)
					if (usingmenu[id]){
						client_print(id,print_chat,"%s is a stalker",sname)
					}
					else	client_print(id,print_console,"%s is a stalker",sname)
					works = true
				}
			}
			if (works == false){
				if (usingmenu[id]){
					client_print(id,print_chat,"None")
				}
				else	client_print(id,print_console,"None")
			}
		}
		else{
			if (usingmenu[id]){
				client_print(id,print_chat,"sv_stalker is not 1")
			}
			else	client_print(id,print_console,"sv_stalker is not 1")
		}
	}
	else{
		if (usingmenu[id]){
			client_print(id,print_chat,"sv_stalkershow is not 1")
		}
		else	client_print(id,print_console,"sv_stalkershow is not 1")
	}
	if (usingmenu[id])
		usingmenu[id]=false
	return PLUGIN_HANDLED
}

public reset_maxspeed(parm[1]){
	if (freezetime_ended == true)
		set_user_maxspeed(parm[0],(get_cvar_float("sv_stalkerrunspeed")))
}

public reset_fog(parm[1]){
	new id = parm[0]
	used_fog[id] = false
}

public make_fog(id){
	if (used_fog[id])
		return PLUGIN_HANDLED
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_HANDLED
	if (stalkeron[id]==false)
		return PLUGIN_HANDLED
	if (is_user_alive(id)!=1)
		return PLUGIN_HANDLED
	used_fog[id] = true
	new origin[3]
	get_user_origin(id,origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	fog_this_area(origin)
	new parm[1]
	parm[0] = id
	set_task(10.0,"reset_fog",0,parm,1)
	return PLUGIN_HANDLED
}

public fog_this_area(origin[3]){
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY,origin )
	write_byte( 5 )
	write_coord( origin[0] + random_num( -100, 100 ))
	write_coord( origin[1] + random_num( -100, 100 ))
	write_coord( origin[2] + random_num( -75, 75 ))
	write_short( smoke )
	write_byte( 60 )
	write_byte( 5 )
	message_end()
}

//Took this from a plugin made by Spacedude and added/changed stuff
public grenade_event(id){
	if (get_cvar_num("sv_stalker")!=1)
		return PLUGIN_CONTINUE
	if (get_cvar_num("sv_stalkernocrash")==1)
		return PLUGIN_CONTINUE
	new gname[32]
	read_data(3, gname, 31)
	if (id==find_player("a",gname)){
		if (stalkeron[id]){
			new parm[1]
			parm[0] = id
			set_task(0.1,"grenid",75,parm,1)
		}
	}
	return PLUGIN_CONTINUE
}

//Took this from a plugin made by Spacedude and added/changed stuff
public grenid(parm[]){
	new id = parm[0]
	new string[32], grenadeid = 0
	do{
		grenadeid = get_grenade_id(id, string, 31, grenadeid)
	}
	while (grenadeid &&!equali(HEGRENADE_MODEL,string))

	if (grenadeid){
		new parm2[2]
		parm2[0] = grenadeid
		set_task(1.55,"grenadecircle",75,parm2,1)
	}
}

//Took this from a plugin made by Spacedude and added/changed stuff
public grenadecircle(parm2[]){
	new grenadeid = parm2[0]
	new origin[3]
	get_entity_origin(grenadeid, origin)
	origin[2] = (origin[2] - 10)

	message_begin( MSG_PAS, SVC_TEMPENTITY, origin )
	write_byte( 21 )
	write_coord( origin[0])
	write_coord( origin[1])
	write_coord( origin[2] - 16)
	write_coord( origin[0])
	write_coord( origin[1])
	write_coord( origin[2] + 16 - 250)
	write_short( shockwave )
	write_byte( 0 )
	write_byte( 0 )
	write_byte( 6 )
	write_byte( 16 )
	write_byte( 0 )
	write_byte( 188 )
	write_byte( 220 )
	write_byte( 255 )
	write_byte( 255 )
	write_byte( 0 )
	message_end()

	message_begin( MSG_PAS, SVC_TEMPENTITY, origin )
	write_byte( 21 )
	write_coord( origin[0])
	write_coord( origin[1])
	write_coord( origin[2] - 16)
	write_coord( origin[0])
	write_coord( origin[1])
	write_coord( origin[2] + 16 - ( 250 / 2 ))
	write_short( shockwave )
	write_byte( 0 )
	write_byte( 0 )
	write_byte( 6 )
	write_byte( 16 )
	write_byte( 0 )
	write_byte( 188 )
	write_byte( 220 )
	write_byte( 255 )
	write_byte( 255 )
	write_byte( 0 )
	message_end()
}

public stalkermenu(id){
	show_stalkerplmenu(id)
	return PLUGIN_HANDLED
}

public show_stalkerplmenu(id){
	new Stalkerplmenu[256], name[32]
	get_user_name(id,name,31)
	format(Stalkerplmenu,255,"\yStalker Menu^n^n\w1. Stalker Info^n2. Change to Stalker^n3. Change back to normal^n4. List_stalkers^n^n\w0. Exit Menu")
	show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<9)),Stalkerplmenu)
}

public menu_option1(id,keys){
	saystalker_manual(id)
	return PLUGIN_HANDLED
}

public menu_option2(id,keys){
	usingmenu[id]=true
	aktivate_stalk(id)
	return PLUGIN_HANDLED
}

public menu_option3(id,keys){
	usingmenu[id]=true
	deaktivate_stalk(id)
	return PLUGIN_HANDLED
}

public menu_option4(id,keys){
	usingmenu[id]=true
	who_is_stalker(id)
	return PLUGIN_HANDLED
}

public player_spawn(id){
	if (get_cvar_num("sv_stalker")==1){
		if (get_cvar_num("sv_stalkertext")==1){
			client_print(id,print_chat,"This server is using Stalkermode plugin")
			client_print(id,print_chat,"For more info type stalkermenu in console or chat")
		}
		get_user_origin(id,player_origin1[id])
		if (get_cvar_num("sv_stalkerchance")!=0){
			new randomnumber = random_num(1,100) 
			if (randomnumber < get_cvar_num("sv_stalkerchance")){
				stalkeron[id] = true
				new parm[1]
				parm[0] = id
				set_task(0.4,"upcraft",id,parm,1,"b")
				set_task(1.0,"check_speed",50+id,parm,1,"b")
			}
			else{ 
				stalkeron[id] = false
				remove_task(id)
				remove_task(50+id)
			}
		}
		if (stalkeron[id]){
			stalker_abilities(id)
			engclient_cmd(id,"weapon_knife")
			used_fog[id] = false
		}
	}
	else if (stalkeron[id]){
		set_user_footsteps(id,0)
		CS_ClearModel(id)
	}
	hasgrenade[id]=false
	return PLUGIN_CONTINUE
}

public new_round(){
	sv_stalkerchangetimer = get_gametime() + get_cvar_float("sv_stalkerschangetime")
	remove_task(75)
	if (lastroundended){
		freezetime_ended = false
		lastroundended = false
	}
	return PLUGIN_CONTINUE
}

//Took this from a plugin made by Spacedude and added/changed stuff
public check_say(id){
	new said[32]
	read_args(said,31)
	if (equali(said,"^"stalkermenu^""))
		show_stalkerplmenu(id)
	else if (equali(said,"^"stalk^"") || equali(said,"^"unstalk^""))
		client_print(id,print_chat,"The command stalk/unstalk should be typped in console...")
	else if (containi(said,"stalkerhelp")!=-1)
		saystalker_manual(id)
	else if (containi(said,"stalkermanual")!=-1)
		saystalker_manual(id)
	else if (containi(said,"stalker")!=-1){
		if (containi(said,"help")!=-1)
			saystalker_manual(id)
		else if (containi(said,"become")!=-1)
			saystalker_manual(id)
		else if (containi(said,"list")!=-1){
			usingmenu[id]=true
			who_is_stalker(id)
		}
		else if (containi(said,"level")!=-1)
			mylevel(id)
		else if (containi(said,"xp")!=-1)
			mylevel(id)
	}
	return PLUGIN_CONTINUE
}

//Took this from a plugin made by Spacedude and added/changed stuff
public saystalker_manual(id){
	new message[1024]
	new temp[512]
	new title[64]
	format(title,63,"Stalkermode In-game Manual")
	temp = "This plugin is made for people that like to hide in dark places and kill their enemies with knife :)^n^nThis plugin lets people turn them self into stalkers. Stalkers get the following abilities:^nThey run faster, they can only use knife, grenades and C4, they get low gravity, they become almost invisible, they have no footstep sound and they get more health and armor. The also gain hp when killing enemies, and become more transparent when standing still.^n^n"
	add(message,1023,temp)
	temp = "Commands are:^nStalk (makes you a stalker)^nUnstalk(makes you normal again)^nFog(makes a shortlasting fog)^nwho_is_stalker(shows stalkers if sv_stalkershow is 1)^n^n^n"
	add(message,1023,temp)
	temp = "Made by Scarzzurs/The_Unbound"
	add(message,1023,temp)
	show_motd(id,message,title)
	return PLUGIN_CONTINUE
}

public plugin_precache(){
	if (file_exists("sound/stalker/ghost.wav"))
		precache_sound("stalker/ghost.wav")
	shockwave = precache_model("sprites/shockwave.spr")
	smoke = precache_model("sprites/steam1.spr")
	return PLUGIN_CONTINUE
}

public client_connect(id){
	if (get_cvar_num("sv_stalkertext")==1){
		client_print(id,print_console,"---------------------------------------------")
		client_print(id,print_console,"This server is using stalkermode by Scarzzurs")
		client_print(id,print_console,"To use it type stalkermenu")
		client_print(id,print_console,"---------------------------------------------")
	}
	firstround[id]=true
	usingmenu[id]=false
	newplayer[id]=true
	stalkeron[id]=false
	used_fog[id] = false
	hasgrenade[id]=false
	slevel[id]=0
	xp[id]=0
	return PLUGIN_CONTINUE
}

public roundtime(id){
	new remaining = read_data(1)
	if (remaining == get_cvar_float("mp_roundtime") * 60){
		freeze_time_stop()
	}
	return PLUGIN_CONTINUE
}

public freeze_time_stop(){
	freezetime_ended = true
	if (get_cvar_num("sv_stalker")==1){
		new players[32]
		new player_num
		get_players(players, player_num)
		for (new i = 0; i < player_num; i++){
			if (stalkeron[players[i]] && get_cvar_num("sv_stalker") && is_user_alive(players[i])==1){
				new id = players[i]
				stalker_abilities(id)
			 	new parm[1]
				parm[0] = players[i]
				set_task(0.1,"reset_maxspeed",0,parm,1)
			}
		}
	}
	return PLUGIN_CONTINUE
}

public check_speed(parm[1]){
	if (get_cvar_num("sv_stalker")==1){
		new id = parm[0]
		if (stalkeron[id] && is_user_alive(id)==1){
			new player_origin2[33][3]
			get_user_origin(id,player_origin2[id])
			if ((player_origin2[id][0] == player_origin1[id][0]) && (player_origin2[id][1] == player_origin1[id][1]) && (player_origin2[id][2] == player_origin1[id][2])){
				set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderTransTexture,get_cvar_num("sv_stalkerinvisibility") - 15)
			}
			else	set_user_rendering(id,kRenderFxNone, 0,0,0, kRenderTransTexture,get_cvar_num("sv_stalkerinvisibility"))
			get_user_origin(id,player_origin1[id])
		}
	}
}

public end_round(){
	lastroundended = true
	return PLUGIN_CONTINUE
}

public mylevel(id){
	if (get_cvar_num("sv_stalker")==1){
		if (get_cvar_num("sv_stalkerxp")==1)
			client_print(id,print_chat,"You are level %i",slevel[id])
		else client_print(id,print_chat,"Stalkerxp is off")
	}
	else client_print(id,print_chat,"Stalkermode is off")
}

//Took this from a plugin made by Spacedude and added/changed stuff
public menu_item(id,key){
	if (get_cvar_num("sv_stalker")==1){
		if (key==3 && get_cvar_num("mp_grenadeprotection")==1){
			if (hasgrenade[id]){
				engclient_cmd(id,"menuselect","10")
				set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 1)
				show_hudmessage(id,"No grenade spamming! One grenade per round maximum.")
			}
			else	hasgrenade[id]=true
		}
	}
	return PLUGIN_CONTINUE
}

public bomb_event(id){
	if (get_cvar_num("sv_stalker")==1)
		if (get_cvar_num("sv_stalkerxp")==1)
			givexp(id)
	switchweapon(id)
	return PLUGIN_CONTINUE
}

public bomb_defused(id){
	if (get_cvar_num("sv_stalker")==1)
		if (get_cvar_num("sv_stalkerxp")==1)
			givexp(id)
	switchweapon(id)
}

public plugin_init(){
	gmsgFade = get_user_msgid("ScreenFade")
	register_plugin("Stalkermode","2.05","Scarzzurs")
	register_cvar("Stalkermode","1",FCVAR_SERVER)
	register_concmd("amx_stalk","admin_stalk",ADMIN_SLAY,"<authid, nick, @team or #userid>")  
	register_concmd("amx_unstalk","admin_unstalk",ADMIN_SLAY,"<authid, nick, @team or #userid>")  
	register_clcmd("say","check_say")
	register_clcmd("say_team","check_say")
	register_clcmd("fog","make_fog")
	register_clcmd("stalk","aktivate_stalk",-1,"stalk")
	register_clcmd("unstalk","deaktivate_stalk",-1,"unstalk")
	register_clcmd("who_is_stalker","who_is_stalker",-1,"who_is_stalker")
	register_clcmd("mylevel","mylevel",-1,"mylevel")
	register_event("RoundTime", "roundtime", "bc")
	register_event("CurWeapon","switchweapon","be","1=1")
	register_event("DeathMsg","death","a")
	register_event("Damage", "damage_event", "b", "2!0")
	register_event("ResetHUD","new_round","bc")
	register_event("ResetHUD","player_spawn","b")
	register_event("TextMsg","grenade_event","b","2&#Game_radio", "4&#Fire_in_the_hole")
	register_event("SendAudio","end_round","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
	register_event("SendAudio", "bomb_event", "a", "2&%!MRAD_BOMBPL")
	register_event("SendAudio", "bomb_defused", "a", "2&%!MRAD_BOMBDEF")
	register_cvar("sv_stalker","1",0)
	register_cvar("sv_stalkershow","0",0)
	register_cvar("sv_stalkernohs","0",0)
	register_cvar("sv_stalkerhealth","150",0)
	register_cvar("sv_stalkerschangetime", "15")
	register_cvar("sv_stalkerrunspeed", "375",0)
	register_cvar("sv_stalkernocrash", "1",0)
	register_cvar("sv_stalkertext", "1",0)
	register_cvar("sv_stalkerselfallowed", "1",0)
	register_cvar("sv_stalkerchance", "0",0)
	register_cvar("sv_stalkerchangemodel", "1",0)
	register_cvar("sv_stalkerxp", "0",0)
	register_cvar("sv_stalkerinvisibility", "55",0)
	if (!cvar_exists("mp_grenadeprotection"))
		register_cvar("mp_grenadeprotection", "1",0)
	register_clcmd("stalkermenu","stalkermenu")
	StalkerMenu = register_menuid("\yStalker Menu")
	register_menucmd(StalkerMenu,(1<<0),"menu_option1")
	register_menucmd(StalkerMenu,(1<<1),"menu_option2")
	register_menucmd(StalkerMenu,(1<<2),"menu_option3")
	register_menucmd(StalkerMenu,(1<<3),"menu_option4")
	register_menucmd(register_menuid("BuyItem"),1023,"menu_item")
	register_menucmd(-34,1023,"menu_item")
	server_cmd("sv_maxspeed 10000")
	return PLUGIN_CONTINUE
}