Unreachable code
#1

I have been editing the lvrcr v1.8 game mode so that it includes menus. As of right now I have 3 menus, that when prompted, will come up. However, only the first menu under the 'public OnPlayerSelectedMenuRow' works. When I compile I receive 2 warning 225: unreachable code's on lines 21080 and 21130.
Line 21080 is the new Menu:PlayerMenu = GetPlayerMenu(playerid); above the adwepmenu,

and line 21130 is the new Menu:CurrentMenu = GetPlayerMenu(playerid); above the storemenu.

All of the menus do come up when they are supposed to, however making selections results in the menu closing properly, but no action is performed for the selected function.

If someone could lend some insight it would be greatly appreciated.

My code is as follows:
Код:
public OnPlayerSelectedMenuRow(playerid, row)
{

   new Menu:current;
		  current = GetPlayerMenu(playerid);
		  if(current == skillmenu)
		  {
		    switch(row)
		    {
		      case 0:{
		        SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x1E90FFAA, "RAPIST: You can rape other players and infect them with STDs that could kill them");

		        GivePlayerWeapon(playerid,5,1);
		        GivePlayerWeapon(playerid,22,100);
		        GivePlayerWeapon(playerid,14,1);
		        gTeam[playerid] = TEAM_RAPIST;
		        SetPlayerToTeamColour(playerid);
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 1:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x00FFFFAA, "DRUG DEALER: You will supply people with drugs for a price. Dont let people rip you off..");
		        SendClientMessage(playerid,0x00FFFFAA, "Keep a watch on the chat for players wanting drugs. Visit the drug house to replenish your stock");
		        GivePlayerWeapon(playerid,25,50);
		        GivePlayerWeapon(playerid,28,100);
		        GivePlayerWeapon(playerid,5,1);
		        gTeam[playerid] = TEAM_DRGDEL;
		        SetPlayerToTeamColour(playerid);
		        PlayerDrugs[playerid] = 500;
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 2:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x00FFFFAA, "GUN DEALER: If anyone needs weapons then you sell them some lead. Your prices are set by the game");
		        SendClientMessage(playerid,0x00FFFFAA, "You can also deliver guns to ammunations, just get in the PATRIOT car at ammunation stores in LV");
		        GivePlayerWeapon(playerid,29,500);
		        GivePlayerWeapon(playerid,30,50);
		        gTeam[playerid] = TEAM_GUNDEL;
		        SetPlayerToTeamColour(playerid);
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 3:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x00FFFFAA, "HITMAN: If anyone needs another player dead then they will contact you. Make sure you agree a price and get paid");
		        //SendClientMessage(playerid,0x00FFFFAA, "Look out for messages on the chat like **Hitmen: PsyKo wants Tyrone dead. Contact PsyKo to discuss**");
		        SendClientMessage(playerid,0x00FFFFAA, "Type /hits to see if there are any hit contracts available");
		        GivePlayerWeapon(playerid,27,250);
		        GivePlayerWeapon(playerid,23,100);
		        GivePlayerWeapon(playerid,31,250);
		        gTeam[playerid] = TEAM_HITMAN;
		        SetPlayerToTeamColour(playerid);
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 4:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x00FFFFAA, "PRIVATE MEDIC: If anyone needs medical attention for cuts and bruses or STDs then you can cure then and heal them");
		        SendClientMessage(playerid,0x00FFFFAA, "You can also infect them with STDs that could kill them DO NOT HIT/INFECT THEM JUST TO HEAL/CURE THEM");
		        GivePlayerWeapon(playerid,22,250);
		        gTeam[playerid] = TEAM_PVTMED;
		        SetPlayerToTeamColour(playerid);
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 5:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
				    SendClientMessage(playerid,0x00FFFFAA, "BOUNTY HUNTER: You have to help the cops take Escaped prisoners back into custody");
		        SendClientMessage(playerid,0x00FFFFAA, "Simply target RED players and type /ar (id) next to them to see if you have found an escaped convict");
		        SendClientMessage(playerid,0x00FFFFAA, "Type /bounty for details of Escaped Prisoners");
		        GivePlayerWeapon(playerid,27,250);
		        GivePlayerWeapon(playerid,23,100);
		        GivePlayerWeapon(playerid,31,250);
		        gTeam[playerid] = TEAM_BOUNTY;
		        SetPlayerToTeamColour(playerid);
		        canchooseskill[playerid] =0;
		        TextDrawHideForPlayer(playerid,txtTypeSkill);
		      }
		      case 6:{
		SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands.");
					  SendClientMessage(playerid,0x00FFFFAA, "Kidnapper: You have to get a passenger in your car.");
						SendClientMessage(playerid,0x00FFFFAA, "Tie them up using /tie, and then drive to a location which is out");
						SendClientMessage(playerid,0x00FFFFAA, "of the way and proceed to do what you wish.");
						GivePlayerWeapon(playerid,26,40);
						GivePlayerWeapon(playerid,32,200);
						GivePlayerWeapon(playerid,22,200);
						gTeam[playerid] = TEAM_KIDNAP;
						SetPlayerToTeamColour(playerid);
						canchooseskill[playerid] =0;
						TextDrawHideForPlayer(playerid,txtTypeSkill);
      }
    }
}
  return 1;

  new Menu:PlayerMenu = GetPlayerMenu(playerid);

    if(PlayerMenu == adwepmenu)

  {
    switch(row)
    {
      case 0:{
          SendClientMessage(playerid, 0xA9A9A9AA, "Hit a bitch with these Knucks");
        	GivePlayerWeapon(playerid,1,10000);
      }
      case 1:{
					GivePlayerWeapon(playerid,8,10000);
      }
      case 2:{
					GivePlayerWeapon(playerid,16,10000);
      }
      case 3:{
					GivePlayerWeapon(playerid,18,10000);
      }
      case 4:{
					GivePlayerWeapon(playerid,24,10000);
      }
      case 5:{
					GivePlayerWeapon(playerid,27,10000);
      }
      case 6:{
					GivePlayerWeapon(playerid,28,10000);
      }
      case 7:{
					GivePlayerWeapon(playerid,29,10000);
      }
      case 8:{
					GivePlayerWeapon(playerid,31,10000);
      }
      case 9:{
					GivePlayerWeapon(playerid,37,10000);
      }
      case 10:{
					GivePlayerWeapon(playerid,35,10000);
      }
      case 11:{
					GivePlayerWeapon(playerid,34,10000);
      }
    }
  }
  return 1;



  new Menu:CurrentMenu = GetPlayerMenu(playerid);
if(CurrentMenu == storemenu)
{
  switch(row)


			{
		case 0://chainsaw
			{
			  if(GetPlayerMoney(playerid) <= 1499) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($1500)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-1500);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
			  GivePlayerWeapon(playerid,9,1);

			}
		case 1://Flowers

			{
        if(GetPlayerMoney(playerid) <= 4) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy flowers ($5)");

			  return 1;
			}


			  GivePlayerMoney(playerid,-5);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought flowers. You were charged $5");
			  GivePlayerWeapon(playerid,14,1);
			}
		case 2://Bat

	 		{

        if(GetPlayerMoney(playerid) <= 99) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Baseball Bat ($100)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-100);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Baseball Bat. You were charged $100");
			  GivePlayerWeapon(playerid,5,1);

			}

		case 3://Beer

			{
        if(GetPlayerMoney(playerid) <= 19) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy Beer ($20)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-20);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought Beer. You were charged $20");
			  new Float:beerhealth;
		    GetPlayerHealth(playerid,beerhealth);
			  if(beerhealth <=95) {
        SetPlayerHealth(playerid,beerhealth+5);
  		  }

			}

		case 4://Wallet

			{
        if(GetPlayerMoney(playerid) <= 999) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Wallet ($1000)");
			  return 1;
			}
        if(HasWallet[playerid] >= 1) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You already have a Wallet");
			  return 1;
			}

			  GivePlayerMoney(playerid,-1000);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Wallet. You were charged $1000");
			  SendClientMessage(playerid, 0x00C7FFAA, "You can be robbed upto 3 times and not loose any cash");
			  HasWallet[playerid] =3;

		  }

		case 5://Parachute

			{
        if(GetPlayerMoney(playerid) <= 499) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Parachute ($500)");
			  return 1;
			}

			  GivePlayerMoney(playerid,-500);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Parachute. You were charged $500");
			  GivePlayerWeapon(playerid,46,1);
		  }

		case 6://rope

			{
			  if(GetPlayerMoney(playerid) <= 999) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy some rope ($1000)");
			  return 1;
			}
				if(gotRope[playerid] == 1) {
				SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
				SendClientMessage(playerid, 0x00C7FFAA, "You already have some rope.");
				}

			  GivePlayerMoney(playerid,-1000);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought some rope. You were charged $1000");
			  gotRope[playerid] =1;
			}

		case 7://Scissors

			{
			  if(GetPlayerMoney(playerid) <= 999) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a pair of rusty sissors. ($1000)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-1000);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought rusty sissors.. You were charged $1000");
			  gotSissors[playerid] =1;

}
}
}
	return 1;


}


public OnPlayerExitedMenu(playerid)
{
	return 1;
}
Reply
#2

The Unreachable code warning is usually a result of bad indention. It means you have 'finished' coding in a callback / function by returning a value, breaking a loop, etc. and then continued to add code which the compiler cannot reach because there is no way it can continue.

Try improving your indention, I haven't fully read through the code, but I'm pretty confident that the cause is the return statement just after case 6.
Reply
#3

Thank you, the return; 's after the last cases in the menus were the problem. I just deleted all the return; 's except for the one after the very last menu, and all my warnings went away and my menu's all work. Thank you very much for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)