Unreachable Code.
#1

Hello people!

I have a .... As the title says, It has an warning which called "Unreachable code." I want to fix that warning and so there is the code...

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
//------------------------------------------------------------------------------
	passenger[playerid] = ispassenger;
	if (GetPlayerSurfingVehicleID(playerid) == vehicleid)
	{
		ClearAnimations(playerid);
	}
	if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 592 && ispassenger == 1)
	{
		SetPlayerInterior(playerid,9);
		SetPlayerFacingAngle(playerid,0.0);
		SetPlayerPos(playerid, 315.856170,1024.496459,1949.797363);
		SetCameraBehindPlayer(playerid);
		InAndrom[playerid]=vehicleid;
	}
	if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 519 && ispassenger)
	{
		if (!ShamalExists(vehicleid))
		{
			CreateShamalInt(vehicleid, float(randomEx(3000)), float(randomEx(3000)), float(random(100)+800));
		}
		SetPlayerPosInShamal(playerid, vehicleid);
		InShamal[playerid] = vehicleid;
	}
	#if defined ENABLE_SPEC
	for(new xp=0; xp<MAX_PLAYERS; xp++) {
	    if(GetPlayerState(xp) == PLAYER_STATE_SPECTATING && PlayerInfo[xp][SpecID] == playerid) {
	        TogglePlayerSpectating(xp, 1);
	        PlayerSpectateVehicle(xp, vehicleid);
	        PlayerInfo[xp][SpecType] = ADMIN_SPEC_TYPE_VEHICLE;
		}
	}
	#endif
	if(onsys[vehicleid] == 1) {
		if(passenger[playerid] == 0) {
			if(PlayerInfo[playerid][LoggedIn] == 1) {
				if (strcmp(VehicleInfo[vehicleid][owner],PlayerInfo[playerid][name],false) == 0) {
					new string[128];
					format(string, sizeof(string), "~n~~n~~n~~g~Welcome to your %s %s, please drive carefully!", VehicleInfo[vehicleid][name], PlayerInfo[playerid][name]);
					GameTextForPlayer(playerid, string, 3000, 4);
					format(string, sizeof(string), "Welcome to your %s %s, please drive carefully!", VehicleInfo[vehicleid][name], PlayerInfo[playerid][name]);
					SendClientMessage(playerid, green, string);
					return 1;
				}
				if (strcmp(VehicleInfo[vehicleid][owner],DEFAULT_OWNER,false) == 0) {
					if(VehicleInfo[vehicleid][buybar] == 1) {
						new string[128];
						format(string,sizeof(string),"~n~~n~~n~~r~This %s has been set as non-buyable by server administration!", VehicleInfo[vehicleid][name]);
						GameTextForPlayer(playerid, string, 3000, 4);
						format(string,sizeof(string),"This %s has been set as non-buyable by server administration!", VehicleInfo[vehicleid][name]);
						SendClientMessage(playerid, red, string);
						return 1;
					}
					new string[128];
					format(string, sizeof(string), "~n~~n~~n~~y~This %s is for sale and costs $%d, type /vmenu to see vehicle options.",VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][vehiclecost]);
					GameTextForPlayer(playerid, string, 3000, 4);
					format(string, sizeof(string), "This %s is for sale and costs $%d, type /vmenu to see vehicle options.",VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][vehiclecost]);
					SendClientMessage(playerid, COLOR_YELLOW, string);
					return 1;
				}
				else {
					new string[128];
					format(string, sizeof(string), "~n~~n~~n~~r~This %s belongs to %s, and cannot be purchased.", VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][owner]);
					GameTextForPlayer(playerid, string, 3000, 4);
					format(string, sizeof(string), "This %s belongs to %s, and cannot be purchased.", VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][owner]);
					SendClientMessage(playerid, red, string);
					return 1;
				}
			}
			else {
			    new playername[128];
			    GetPlayerName(playerid,playername,sizeof(playername));
			    if (strcmp(VehicleInfo[vehicleid][owner],playername,false) == 0) {
					new string[128];
					format(string, sizeof(string), "Welcome to your %s %s, please drive carefully! ~n~Remember, you must be logged in to access vehicle controls.", VehicleInfo[vehicleid][name], playername);
					return GameTextForPlayer(playerid, string, 3000, 4);
					format(string, sizeof(string), "Welcome to your %s %s, please drive carefully! Remember, you must be logged in to access vehicle controls.", VehicleInfo[vehicleid][name], playername);
					SendClientMessage(playerid, green, string);
				}
		       	if (strcmp(VehicleInfo[vehicleid][owner],DEFAULT_OWNER,false) == 0) {
					if(VehicleInfo[vehicleid][buybar] == 1) {
		           		new string[128];
			        	format(string,sizeof(string),"~n~~n~~n~~r~This %s has been set as non-buyable by server administration!", VehicleInfo[vehicleid][name]);
			        	return GameTextForPlayer(playerid, string, 3000, 4);
			        	format(string,sizeof(string),"This %s has been set as non-buyable by server administration!", VehicleInfo[vehicleid][name]);
			        	SendClientMessage(playerid, red, string);
				   	}
				   	new string[128];
		   	       	format(string, sizeof(string), "~n~~n~~n~~y~This %s is for sale and costs $%d, ~n~You must be logged in to purchase a vehicle.",VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][vehiclecost]);
		   	       	return GameTextForPlayer(playerid, string, 3000, 4);
		   	       	format(string, sizeof(string), "This %s is for sale and costs $%d, You must be logged in to purchase a vehicle.",VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][vehiclecost]);
		   	       	SendClientMessage(playerid, yellow, string);
				}
				else {
		        	new string[128];
		          	format(string, sizeof(string), "~n~~n~~n~~r~This %s belongs to %s, and cannot be purchased.", VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][owner]);
		          	return GameTextForPlayer(playerid, string, 3000, 4);
		          	format(string, sizeof(string), "This %s belongs to %s, and cannot be purchased.", VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][owner]);
		          	SendClientMessage(playerid, red, string);
				}
			}
		}
	}
	return 1;
}
So, and the warning (Also the line) are below.

Код:
C:\Users\ўггелпт\Desktop\НЭпт цЬкелпт\Gamemodes\NFTDM.pwn(25790) : warning 225: unreachable code
C:\Users\ўггелпт\Desktop\НЭпт цЬкелпт\Gamemodes\NFTDM.pwn(25798) : warning 225: unreachable code
C:\Users\ўггелпт\Desktop\НЭпт цЬкелпт\Gamemodes\NFTDM.pwn(25804) : warning 225: unreachable code
C:\Users\ўггелпт\Desktop\НЭпт цЬкелпт\Gamemodes\NFTDM.pwn(25811) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Warnings.
The Lines.

Код:
25790 LINE: format(string, sizeof(string), "Welcome to your %s %s, please drive carefully! Remember, you must be logged in to access vehicle controls.", VehicleInfo[vehicleid][name], playername);

25798 LINE: format(string,sizeof(string),"This %s has been set as non-buyable by server administration!", VehicleInfo[vehicleid][name]);

25804 LINE: format(string, sizeof(string), "This %s is for sale and costs $%d, You must be logged in to purchase a vehicle.",VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][vehiclecost]);

AND THE 25811 LINE: format(string, sizeof(string), "This %s belongs to %s, and cannot be purchased.", VehicleInfo[vehicleid][name], VehicleInfo[vehicleid][owner]);
Please, by reading them carefully, i will be thankful if you could help me a little bit!
Reply
#2

Please clarify to me what you think "return" means.
Reply
#3

Could you help me a little bit? If so, Thank you.
Reply
#4

Unreachable code means that some code is not reachable by the script it is mostly caused when you use return like popcorn.

The code after the warning lines is not reached why? Check the return definition.
Reply
#5

Can you fix my code right there? Cause i dont have much time to see it, Please. Thank you !
Reply
#6

They told you the solution, that's all you need to know.

You have to move your own ass a bit!
Reply
#7

Quote:
Originally Posted by Knowinne
Посмотреть сообщение
Can you fix my code right there? Cause i dont have much time to see it, Please. Thank you !
It doesn't take time to see it, it takes knowledge, if you have none there is no point in you "fixing warnings" of a released GM and creating a server. Take your time and learn how to code by baby steps.

This is a scripting help section, not script request.
Reply
#8

None of you helped me anyway. Fixed by myself.
Reply
#9

Nice job you probably got it yourself hence that's why you asked us for help in the first place.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)