public change_race(id,saychat){
	 #if ADVANCED_DEBUG == 1
		writeDebugInfo("change_race",id)
	#endif

	if (warcraft3==false)
		return PLUGIN_CONTINUE

	if (iCvar[FT_CD]) {
		if (!WAR3_CD_installed(id)){
			client_print(id,print_chat,"%L",id,"CHEATING_DEATH_NOT_INSTALLED",g_MOD)
			return PLUGIN_CONTINUE
		}
	}

	save_xp_info(id,0)

	WAR3_chooserace(id)

	return PLUGIN_CONTINUE

}

public player_skills(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("player_skills",id)
	#endif

	if (warcraft3==false)
		return PLUGIN_CONTINUE
		
	if (iCvar[FT_CD]) {
		if (!WAR3_CD_installed(id)){
			client_print(id,print_chat,"%L",id,"CHEATING_DEATH_NOT_INSTALLED",g_MOD)
			return PLUGIN_CONTINUE
		}
	}

	new name[32], message[2048], temp[1024]
	
	new race_name[RACE_NAME_LENGTH]
	new players[32], numberofplayers, i, j, playerid, pos, found
	new skill1[64], skill2[64], skill3[64], skill4[64]

	get_players(players, numberofplayers)

	if(iCvar[FT_STEAM])
		add(message, 2047, "<body bgcolor=#000000><font color=#FFB000>")

	for(j=1;j<(iCvar[FT_RACES]+1);j++){
		pos = 0
		found = 0
		temp = ""
		race_name=""
		racename(j,id,race_name,RACE_NAME_LENGTH_F)
		
		if(iCvar[FT_STEAM])
			pos += format(temp[pos],1024-pos, "<font color='green'><b>%s</b></font><ul>",race_name)
		else
			pos += format(temp[pos],1024-pos, "^n%s",race_name)

		for (i = 0; i < numberofplayers; ++i){
			skill1 = ""
			skill2 = ""
			skill3 = ""
			skill4 = ""
			playerid=players[i]
			get_user_name(playerid,name,31)

			replace(name, 127, "<", "&lt;")
			replace(name, 127, ">", "&gt;")

			if(p_data[playerid][P_RACE] == j){
				found++

				new race_skill[4][RACE_SKILL_LENGTH]

				for(new k=0;k<4;k++){
					raceskill(p_data[playerid][0],k+1,id,race_skill[k],RACE_SKILL_LENGTH_F)
				}

				if(p_data[playerid][P_SKILL1])
					format(skill1,63,", %s %d",race_skill[0],p_data[playerid][P_SKILL1])
				if(p_data[playerid][P_SKILL2])
					format(skill2,63,", %s %d",race_skill[1],p_data[playerid][P_SKILL2])
				if(p_data[playerid][P_SKILL3])
					format(skill3,63,", %s %d",race_skill[2],p_data[playerid][P_SKILL3])
				if(p_data[playerid][P_ULTIMATE])
					format(skill4,63,", %s",race_skill[3],p_data[playerid][P_ULTIMATE])
				
				if(pos<1024){
					if (iCvar[FT_STEAM])
						pos += format(temp[pos],1024-pos,"<li>%s - %d%s%s%s%s</li>",name,p_data[playerid][P_LEVEL],skill1,skill2,skill3,skill4)
					else
						pos += format(temp[pos],1024-pos,"/t%s - %d%s%s%s%s^n",name,p_data[playerid][P_LEVEL],skill1,skill2,skill3,skill4)
				}
			}
		}
		if(found > 0 && pos < 1018)
			pos += format(temp[pos],1024-pos,"</ul>")
		else
			format(temp[1018],1024-1018,"</ul>")
	
		if(found > 0){
			if(strlen(message) < 2048)
				add(message, 2047, temp)
		}
	}

	new motdmessage[128]
	format(motdmessage, 127, "%L",id,"PLAYER_SKILLS","","")
	show_motd(id,message,motdmessage)

	return PLUGIN_CONTINUE
}

public cmd_Shield(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Shield",id)
	#endif

	if (!WAR3_check())
		return PLUGIN_CONTINUE

	new parm[1]
	parm[0] = id
	set_task(0.1,"_cmd_Shield",TASK_SHIELD+id,parm,1)
	
	return PLUGIN_CONTINUE
}

public _cmd_Shield(parm[1]){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("_cmd_Shield",parm[0])
	#endif

	new id = parm[0]

	if(!p_data_b[id][PB_ISCONNECTED])
		return PLUGIN_CONTINUE

	new seq = entity_get_int(id,EV_INT_sequence)
	
	if(seq == 89){
		p_data_b[id][PB_SHIELD] = true
	}
	else if(seq == 94){
		p_data_b[id][PB_SHIELD] = true
	}
	else if(seq == 98){
		p_data_b[id][PB_SHIELD] = true
	}
	else{
		p_data_b[id][PB_SHIELD] = false
	}

	return PLUGIN_CONTINUE
}

public cmd_Drop(id) { 
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Drop",id)
	#endif

	if (!WAR3_check())
		return PLUGIN_CONTINUE

	cmd_Shield(id)
	
	return PLUGIN_CONTINUE 
}

public cmd_Teamselect(id,key) {
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Teamselect",id)
	#endif

	// key+1 is the team they choose
	p_data_b[id][PB_CHANGINGTEAM] = true
	if(!p_data_b[id][PB_JUSTJOINED])
		p_data_b[id][PB_DIEDLASTROUND] = true

}

public cmd_Jointeam(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Jointeam",id)
	#endif

	//new arg[2]
	//read_argv(1,arg,1)	//This is the command they pressed
	p_data_b[id][PB_CHANGINGTEAM] = true

	if(!p_data_b[id][PB_JUSTJOINED])
		p_data_b[id][PB_DIEDLASTROUND] = true
}

public cmd_Level(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Level",id)
	#endif

	WAR3_Display_Level(id, DISPLAYLEVEL_SHOWRACECHAT)
}

public cmd_Say(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Say",id)
	#endif

	new said[32]
	read_args(said,31) 

	if (equali(said,"^"/changerace^"") || equali(said,"^"changerace^""))
		change_race(id,1)
	else if (equali(said,"^"/selectskill^"") || equali(said,"^"selectskill^""))
		select_skill(id,1)
	else if (equali(said,"^"/playerskills^"") || equali(said,"^"playerskills^""))
		player_skills(id)
	else if (equali(said,"^"/skillsinfo^"") || equali(said,"^"skillsinfo^""))
		skills_info(id,1)
	else if (equali(said,"^"/war3vote^"") || equali(said,"^"war3vote^""))
		war3_vote(id,1)
	else if (equali(said,"^"/war3_vote^"") || equali(said,"^"war3_vote^""))
		war3_vote(id,1)
	else if (equali(said,"^"/war3help^"") || equali(said,"^"war3help^""))
		war3_info(id,1)
	else if (equali(said,"^"/icons^"") || equali(said,"^"icons^""))
		say_Icons(id)
	else if (equali(said,"^"/level^"") || equali(said,"^"level^""))
		WAR3_Display_Level(id,DISPLAYLEVEL_SHOWRACECHAT)
	else if (equali(said,"^"/shopmenu^"") || equali(said,"^"shopmenu^""))
		Menu_Shopmenu_One(id)
	else if (equali(said,"^"/resetxp^"") || equali(said,"^"resetxp^""))
		amx_resetxp(id,1)
	else if (equali(said,"^"/itemsinfo^"") || equali(said,"^"itemsinfo^""))
		items_info(id,1)
	else if (equali(said,"^"/war3menu^"") || equali(said,"^"war3menu^""))
		WC3_Menu(id)
	else if (equali(said,"^"/savexp^"") || equali(said,"^"savexp^""))
       	save_xp_info(id,1)  
	if(iCvar[FT_RACES] > 4){
		if (equali(said,"^"/itemsinfo2^"") || equali(said,"^"itemsinfo2^""))
			items_info2(id,1)
		else if (equali(said,"^"/rings^"") || equali(said,"^"rings^""))
			cmd_Rings(id)
		else if (equali(said,"^"/ability^"") || equali(said,"^"ability^""))
			ability(id)
		else if (equali(said,"^"/shopmenu2^"") || equali(said,"^"shopmenu2^""))
			Menu_Shopmenu_Two(id)
	}
	if (equali(said,"^"/reset_skills^"") || equali(said,"^"reset_skills^""))
		resetSkills(id,1)
	else if (equali(said,"^"/resetskills^"") || equali(said,"^"resetskills^""))
		resetSkills(id,1)

	return PLUGIN_CONTINUE
}

public say_Icons(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("say_Icons",id)
	#endif

	if (!g_spritesEnabled){
		set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 1)
		show_hudmessage(id,"%L",id,"ICONS_ARE_DISABLED")
		client_print(id,print_chat,"%s %L",g_MODclient,id,"ICONS_ARE_DISABLED_DO")
		return PLUGIN_CONTINUE
	}

	set_hudmessage(200, 100, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 1)
	if(iCvar[FT_RACE_ICONS] || iCvar[FT_LEVEL_ICONS]){
		if(p_data[id][P_SHOWICONS]){
			p_data[id][P_SHOWICONS]=false

			show_hudmessage(id,"%L",id,"NO_LONGER_SEE_ICONS")
		}
		else{
			p_data[id][P_SHOWICONS]=true

			show_hudmessage(id,"%L",id,"NOW_SEE_ICONS")
		}
	}
	else
		show_hudmessage(id,"%L",id,"ICONS_DISABLED_THIS_SERVER")

	return PLUGIN_HANDLED
}

public cmd_Rings(id){
	#if ADVANCED_DEBUG == 1
		writeDebugInfo("cmd_Rings",id)
	#endif

	if (!is_user_alive(id))
		return PLUGIN_HANDLED

	if (iCvar[FT_CD]) {
		if (!WAR3_CD_installed(id)){
			return PLUGIN_CONTINUE
		}
	}

	if(iCvar[FT_RACES]<5)
		return PLUGIN_CONTINUE

	new usermoney
	new parm[2]
	parm[0]=id

	if (p_data[id][P_ITEM2]==ITEM_AMULET)
		p_data_b[id][PB_SILENT] = false
	if (p_data[id][P_ITEM2]==ITEM_HELM)
		Item_Set_Helm(id,1)
	if (p_data[id][P_ITEM2]==ITEM_CHAMELEON)
		changeskin(id,SKIN_RESET)
	
	while(p_data[id][P_RINGS]<5){
		usermoney = get_user_money(id)
		if(usermoney<itemcost2[ITEM_RING-1])
			break
		set_user_money(id,usermoney-itemcost2[ITEM_RING-1],1)
		++p_data[id][P_RINGS]
		p_data[id][P_ITEM2]=ITEM_RING
		if(!task_exists(TASK_ITEM_RINGERATE+id))
			regenerate(parm)
	}

	WAR3_Display_Level(id,DISPLAYLEVEL_NONE)

	return PLUGIN_HANDLED
}
