SA-MP Forums Archive
Small Error 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: Small Error Unreachable code (/showthread.php?tid=357332)



Small Error Unreachable code - Zach7 - 06.07.2012

pawn Код:
if(strcmp( cmd, "/help", true ) == 0 )
    {
    ShowPlayerDialog(playerid, DIACMDS, DIALOG_STYLE_LIST,
    "Comandos", "{00FF00}[*]{0094FF} /CMDS  -  {267F00}Shows server commands\n\
    {00FF00}[*]{0094FF} /KILL  -  {267F00}Kill your player\n\
    {00FF00}[*]{0094FF} /JETPACK  -  {267F00}Get a Jetpack\n\
    {00FF00}[*]{0094FF} /TELES  -  {267F00}List teletransportations\n\
    {00FF00}[*]{0094FF} /GOTO [ID] -  {267F00}Teleport a player\n\
    {00FF00}[*]{0094FF} CLOSE  -  {267F00}Close the dialog.\
    "
, "[[O]]", ">>");
    return 1;
    }



Re: Small Error Unreachable code - Roko_foko - 06.07.2012

Show us what is before this code.


Re: Small Error Unreachable code - SA-MPDrifter - 06.07.2012

Worked for me when I compiled, had to change 2 things though.

pawn Код:
if(strcmp( cmdtext, "/help", true ) == 0 )
    {
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,
    "Comandos", "{00FF00}[*]{0094FF} /CMDS  -  {267F00}Shows server commands\n\
    {00FF00}[*]{0094FF} /KILL  -  {267F00}Kill your player\n\
    {00FF00}[*]{0094FF} /JETPACK  -  {267F00}Get a Jetpack\n\
    {00FF00}[*]{0094FF} /TELES  -  {267F00}List teletransportations\n\
    {00FF00}[*]{0094FF} /GOTO [ID] -  {267F00}Teleport a player\n\
    {00FF00}[*]{0094FF} CLOSE  -  {267F00}Close the dialog.\
    "
, "[[O]]", ">>");
    return 1;
    }
Meaning that this code is unreachable because of the code before it.


Re: Small Error Unreachable code - Zach7 - 06.07.2012

It says unreachable code still here is what is before it
pawn Код:
{
    if (strcmp("/cmds", cmdtext, true, 10) == 0)
    {
        new dialog[500];
        strcat(dialog,"{FF0000}/v-Spawn a vehicle of your choice.\n");
        strcat(dialog,"{FF0000}/w-List of Weapons.\n");
        strcat(dialog,"{FF0000}/pm [ID][TEXT]- to PM a player.\n");
        strcat(dialog,"{FF0000}/change-hide the blue bar at bottom of screen.\n{");
        strcat(dialog,"{FF0000}/FLY [0-1]- 0(off) 1(on).\n");
        strcat(dialog,"{FF0000}/infernus-Spawn an infernus.\n");
        strcat(dialog,"{FF0000}/PCJ- Spawn a PCJ-600.\n");
        strcat(dialog,"{FF0000}/CHANGENAME- Change name in server without having to leave.\n");
        strcat(dialog,"{FF0000}/TIME-Switch to Day or night.\n");
        strcat(dialog,"{FF0000}/PJY-Attach objects to your player.\n");
        strcat(dialog,"{FF0000}/ACTIONS- list of animations.\n");
        strcat(dialog,"{FF0000}/MUSIC-Listen to music.\n");
        strcat(dialog,"{FF0000}/MINIGAMES-Do minigames.\n");
        strcat(dialog,"{FF0000}/COLORS-Change color of username on CHAT.");
        ShowPlayerDialog(playerid, DIAREGLAS, DIALOG_STYLE_MSGBOX, "Commands",dialog,"OK","CLOSE");
        return 1;
    }
    return 0;
}



Re: Small Error Unreachable code - SA-MPDrifter - 06.07.2012

There must be something above all of this that isn't correctly scripted, since both of these are unreachable. Just keep testing, also look for parts of the script that look unfinished or incorrect.


Re: Small Error Unreachable code - Zach7 - 06.07.2012

that's the thing idk if anything is correct or not cuz ive never done this before?


Re: Small Error Unreachable code - Roko_foko - 06.07.2012

Quote:
Originally Posted by Zach7
Посмотреть сообщение
pawn Код:
{
    if (strcmp("/cmds", cmdtext, true, 10) == 0)
    {
        new dialog[500];
        strcat(dialog,"{FF0000}/v-Spawn a vehicle of your choice.\n");
        strcat(dialog,"{FF0000}/w-List of Weapons.\n");
        strcat(dialog,"{FF0000}/pm [ID][TEXT]- to PM a player.\n");
        strcat(dialog,"{FF0000}/change-hide the blue bar at bottom of screen.\n{");
        strcat(dialog,"{FF0000}/FLY [0-1]- 0(off) 1(on).\n");
        strcat(dialog,"{FF0000}/infernus-Spawn an infernus.\n");
        strcat(dialog,"{FF0000}/PCJ- Spawn a PCJ-600.\n");
        strcat(dialog,"{FF0000}/CHANGENAME- Change name in server without having to leave.\n");
        strcat(dialog,"{FF0000}/TIME-Switch to Day or night.\n");
        strcat(dialog,"{FF0000}/PJY-Attach objects to your player.\n");
        strcat(dialog,"{FF0000}/ACTIONS- list of animations.\n");
        strcat(dialog,"{FF0000}/MUSIC-Listen to music.\n");
        strcat(dialog,"{FF0000}/MINIGAMES-Do minigames.\n");
        strcat(dialog,"{FF0000}/COLORS-Change color of username on CHAT.");
        ShowPlayerDialog(playerid, DIAREGLAS, DIALOG_STYLE_MSGBOX, "Commands",dialog,"OK","CLOSE");
        return 1;
    }
    //HERE POSTION 0?
    return 0;
//HERE Position 1?
}
//HERE POSITION 2?
Where comes /help command in this Positon 0 or Position 1 or Position 2 or another position?


Re: Small Error Unreachable code - SA-MPDrifter - 06.07.2012

Look go here: http://pastebin.com/

And copy - paste your script into the text box, but please for the love of God select syntax highlighting as PAWN...


Re: Small Error Unreachable code - Zach7 - 06.07.2012

position 2


Re: Small Error Unreachable code - Roko_foko - 06.07.2012

Quote:
Originally Posted by Zach7
Посмотреть сообщение
position 2
Then delete that " return 0" thing

or

Copy the code that is unreachable and paste it on Position 0<---- I suggest you to do this.