SA-MP Forums Archive
unreachable code - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: unreachable code (/showthread.php?tid=91587)



unreachable code - Typhome - 15.08.2009

Error:
Код:
(1343) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

1 Warning.
Error line:
Код:
1343: 	return 1;
Full code:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	new string[MAX_PLAYER_NAME];
 	new plname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, plname, sizeof(plname));
	format(string, sizeof(string), "mg/%s.ini", plname);
	if(fexist(string))
	{
		gPlayerAccount[playerid] = 1;
		SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are a registered citizen of San Andreas.");
		SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /login [password] to log in to your account.");
		return 1;
	}
	else
	{
		gPlayerAccount[playerid] = 0;
		SendClientMessage(playerid,COLOR_WHITE,"SERVER: Your'e are not registered,type to register, /register [password]");
		return 1;
	}
	return 1;
}



Re: unreachable code - James_Alex - 15.08.2009

try this
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    new string[MAX_PLAYER_NAME];
    new plname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, plname, sizeof(plname));
    format(string, sizeof(string), "mg/%s.ini", plname);
    if(fexist(string))
    {
        gPlayerAccount[playerid] = 1;
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are a registered citizen of San Andreas.");
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /login [password] to log in to your account.");
        return 1;
    }
    else
    {
        gPlayerAccount[playerid] = 0;
        SendClientMessage(playerid,COLOR_WHITE,"SERVER: Your'e are not registered,type to register, /register [password]");
    }
    return 1;
}



Re: unreachable code - dice7 - 15.08.2009

a 'return' breaks the code immediatly, so your code will never reach the last return 1;. But the last one also isn't needed so you can remove it. But you also don't need to 2 returns in the 'if' if you have the one at the end


Re: unreachable code - Typhome - 15.08.2009

ty m8.