How is this an unreachable code??
#1

SORRY IT LOOKS MESSED UP
Код:
if(strcmp(cmd, "/givelicense", true) == 0)
	{
	  	if (PlayerInfo[playerid][pAdmin] >= 3)
		{
	  	if(IsPlayerConnected(playerid))
	  	{
   {
	        //SendClientMessage(playerid, COLOR_GREY, "  Only Rank 2 or higher can give away a License !");
         return 1;
	      }

	            new x_nr[256];            //..............THIS IS WHERE IT SAYS UNREACHABLE...............
				x_nr = strtok(cmdtext, idx);
				if(!strlen(x_nr))
				{
				  SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givelicense [name] [playerid/PartOfName] [price]");
				  SendClientMessage(playerid, COLOR_WHITE, "Available names: Driving, Flying, Sailing, Fishing.");
					return 1;
				}
			  if(strcmp(x_nr,"driving",true) == 0)
				{
		      tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
					  SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givelicense driverslicense [playerid/PartOfName] [price]");
					  return 1;
					}
					giveplayerid = ReturnUser(tmp);
					if(IsPlayerConnected(giveplayerid))
					{
					  if(giveplayerid != INVALID_PLAYER_ID)
					  {

							tmp = strtok(cmdtext, idx);
							if(!strlen(tmp))
							{
								SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /givelicense driving [playerid/ParOfName] [price]");
								return 1;
							}
							new price;
							price = strval(tmp);
							if(price < 50 || price > 500) { SendClientMessage(playerid, COLOR_GREY, "  Price not lower then 50, or above 500!"); return 1; }
					    GetPlayerName(playerid, sendername, sizeof(sendername));
					    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				        format(string, sizeof(string), "* You've given a Drivers License to %s.",giveplayer);
					    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					    format(string, sizeof(string), "* Instructor %s has given you a Drivers License.",sendername);
					    SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
					    PlayerInfo[giveplayerid][pCarLic] = 1;
					    format(string, sizeof(string), "* You offerd %s to buy drivers license for $%d .", giveplayer, price);
						SendClientMessage(playerid, COLOR_WHITE, string);
						format(string, sizeof(string), "* School instructor %s wants to sell you drivers license for $%d,(type /accept license) to buy.", sendername, price);
						SendClientMessage(giveplayerid, COLOR_WHITE, string);
						LicenseOffer[giveplayerid] = playerid;
							LicensePrice[giveplayerid] = price;
							LicenseType[giveplayerid] = 1;
					    return 1;
				    }
					}
					else
					{
					  SendClientMessage(playerid, COLOR_GREY, "  That player is Offline !");
					  return 1;
					}
				}
EDIT: it does compile but it says unreachable code so idk please help
Reply
#2

Unreachable code is when the script says that a certain piece of code is impossible to get to.

pawn Код:
public OnPlayerConnect(playerid)
{
if(gTeam[playerid] == 1)
{
   SendClientMessage(playerid, color, "Welcome");
   return 1;
}
else
{
   SendClientMessage(playerid, color, "Your not team 1");
   return 1;
}
return 1;
}
The last return is unreachable. Since the else statement HAS to happen and it has a return in it.

From what it looks like in your code, is your checking to see if there admin level is Greater then 3, and then return the function. I don't see any other conditions met, which means the code underneath it can't be reached.
Reply
#3

yup i got it now cheerz dude lol thanks alot bro

an do you know about 0.3 menus like when you login an stuff so its not like the old /register password
but a box that you just put password in
Reply
#4

Ya I saw it before, not to good with menus, I did see something like it though. You might have luck searching it. Or post it in questions thread which is stickied.

Also did you fix the other problem?? When players spawned on your server?
Reply
#5

o the hospital bug yea thanks dude lol it was a right pain lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)