Warning 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)
+--- Thread: Warning Unreachable Code? (
/showthread.php?tid=575526)
Warning Unreachable Code? -
jremi - 27.05.2015
http://gyazo.com/9428fa4d21f5ca0b2c94c63bfefb30f8
Fix for this?
Thanks
Re: Warning Unreachable Code? -
Sledgehammer - 27.05.2015
Mind coping that code here? Line 2317 -- 2326 so I can correct it for you?
Re: Warning Unreachable Code? -
jremi - 27.05.2015
Код:
if(dialogid == 8)
{
if(!response){ RemoveDriverFromVehicle(playerid); return 1; }
{
GameTextForPlayer(playerid, "Please Wait...", 3000, 1);
ShowPlayerDialog(playerid,8,DIALOG_STYLE_MSGBOX,"Hotwire Vehicle","You don't have the keys to this vehicle, But this can be hotwired!","Hotwire","Cancel");
return 1;
}
if(engine[GetPlayerVehicleID(playerid)-1] == 0)
{
Re: Warning Unreachable Code? -
Vince - 27.05.2015
Indentation, identation, identation. What a horrible mess this is. Let's write that out, shall we? This is YOUR code, I have changed nothing, but the formatting.
PHP код:
if(dialogid == 8)
{
if(!response)
{
RemoveDriverFromVehicle(playerid);
return 1;
}
{ // <-- this block is unconditional, so it always gets executed
GameTextForPlayer(playerid, "Please Wait...", 3000, 1);
ShowPlayerDialog(playerid,8,DIALOG_STYLE_MSGBOX,"Hotwire Vehicle","You don't have the keys to this vehicle, But this can be hotwired!","Hotwire","Cancel");
return 1; // <-- hence, this return always gets executed
}
if(engine[GetPlayerVehicleID(playerid)-1] == 0) // <-- hence, this code can never be reached
{
Re: Warning Unreachable Code? -
jremi - 28.05.2015
Quote:
Originally Posted by Vince
Indentation, identation, identation. What a horrible mess this is. Let's write that out, shall we? This is YOUR code, I have changed nothing, but the formatting.
PHP код:
if(dialogid == 8)
{
if(!response)
{
RemoveDriverFromVehicle(playerid);
return 1;
}
{ // <-- this block is unconditional, so it always gets executed
GameTextForPlayer(playerid, "Please Wait...", 3000, 1);
ShowPlayerDialog(playerid,8,DIALOG_STYLE_MSGBOX,"Hotwire Vehicle","You don't have the keys to this vehicle, But this can be hotwired!","Hotwire","Cancel");
return 1; // <-- hence, this return always gets executed
}
if(engine[GetPlayerVehicleID(playerid)-1] == 0) // <-- hence, this code can never be reached
{
|
So.. What, it works now? Or..?
Re: Warning Unreachable Code? -
Vince - 28.05.2015
No, I am trying to show you your mistake and the importance of proper indentation. If I (or someone else) fixes your code now you learn nothing and you'll be back here with another problem before you know it, and that doesn't help you, nor us.
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.