SA-MP Forums Archive
warning 225: 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 225: unreachable code (/showthread.php?tid=449433)



warning 225: unreachable code - Lyksus - 08.07.2013

pawn Код:
case DIALOG_QUIZ3:
            {
                if(!response) return Kick(playerid);
                else
                {
                    switch(listitem)
                    {
                        case 0:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                        case 1:
                        {
                            return cmd_quizcontinuecommand(playerid, "");
                            QuizStep[playerid] = 4;                    
                        }
                        case 2:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                        case 3:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                    }              
                }
                return 1;
            }
Can someone help me with this?
I will really thank you for it.


Re: warning 225: unreachable code - CAR - 08.07.2013

Which line is the warning?


Re: warning 225: unreachable code - Lyksus - 08.07.2013

QuizStep[playerid] = 4;


Re: warning 225: unreachable code - CAR - 08.07.2013

pawn Код:
case DIALOG_QUIZ3:
            {
                if(!response) return Kick(playerid);
                else
                {
                    switch(listitem)
                    {
                        case 0:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                        case 1:
                        {
                            cmd_quizcontinuecommand(playerid, "");
                            QuizStep[playerid] = 4;
                            return 1;                  
                        }
                        case 2:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                        case 3:
                        {
                            KickWithMessage(playerid, RED, "You have answered an incorrect answer and you have been kicked.");
                        }
                    }              
                }
                return 1;
            }



Re: warning 225: unreachable code - Lyksus - 08.07.2013

What did you change in it?


Re: warning 225: unreachable code - [MG]Dimi - 08.07.2013

pawn Код:
case 1:
                        {
                            return cmd_quizcontinuecommand(playerid, "");
                            QuizStep[playerid] = 4;                    
                        }
QuizStep[playerid] = 4; is unreachable since return ends callback processing right away. So:
pawn Код:
case 1:
                        {
                            return cmd_quizcontinuecommand(playerid, ""); //cmd quiz command continue will occur and callback process will stop
                            QuizStep[playerid] = 4; //this will never be called.
                        }
While his code executes bot 'functions' and then ends callback.


Re: warning 225: unreachable code - Lyksus - 09.07.2013

Now, the thing is that, when I go in-game and do the quiz, I need to enter the command /quizcontinuecommand to get it to work. And when I use it, I need to press on each answer twice. Can someone help me?