Invalid Statement; not in switch
#1

Hey, would appreciate it if someone could help me


pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                new HashPass[129];
                WP_Hash(HashPass,sizeof(HashPass),inputtext);
                new INI:file = INI_Open(Path(playerid));
                INI_SetTag(file,"Player's Data");
                INI_WriteString(file,"Password",HashPass);
                INI_WriteInt(file,"AdminLevel",0);
                INI_WriteInt(file,"Banned",0);
                INI_WriteInt(file,"VIPLevel",0);
                INI_WriteInt(file,"Money",5000);
                INI_WriteInt(file,"Scores",1);
                INI_WriteInt(file,"Kills",0);
                INI_WriteInt(file,"Deaths",0);
                INI_WriteInt(file,"Skin",0);
                INI_WriteInt(file,"Frozen",0);
                INI_Close(file);
               
                SetSpawnInfo(0, 0, 299, 1743.0520,-1863.3153,13.5752,1.8252,0,0,0,0,0,0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_REGISTER_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully registered\n Please procceed with clicking 'OK' to continue!", "Ok", "");
            }
            case DIALOG_LOGIN: // Line 474
            {
                if(!response) return Kick(playerid);
                if(response)
                {
                    new HashPass[129];
                    WP_Hash(HashPass,sizeof(HashPass),inputtext);
                    if(!strcmp(HashPass,pInfo[playerid][pPass]))
                   
                    INI_ParseFile(Path(playerid),"LoadAccount_%s", .bExtra = true, .extra = playerid);
                   
                    SetPlayerScore(playerid,pInfo[playerid][pScores]);
                    GivePlayerMoney(playerid,pInfo[playerid][pMoney]);
                   
                    ShowPlayerDialog(playerid, DIALOG_LOGIN_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully logged in\n Please procceed with clicking 'OK'", "Ok", "");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Код:
ki.pwn(474) : error 014: invalid statement; not in switch
ki.pwn(474) : warning 215: expression has no effect
ki.pwn(474) : error 001: expected token: ";", but found ":"
ki.pwn(474) : error 029: invalid expression, assumed zero
ki.pwn(474) : fatal error 107: too many error messages on one line
Reply
#2

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                new HashPass[129];
                WP_Hash(HashPass,sizeof(HashPass),inputtext);
                new INI:file = INI_Open(Path(playerid));
                INI_SetTag(file,"Player's Data");
                INI_WriteString(file,"Password",HashPass);
                INI_WriteInt(file,"AdminLevel",0);
                INI_WriteInt(file,"Banned",0);
                INI_WriteInt(file,"VIPLevel",0);
                INI_WriteInt(file,"Money",5000);
                INI_WriteInt(file,"Scores",1);
                INI_WriteInt(file,"Kills",0);
                INI_WriteInt(file,"Deaths",0);
                INI_WriteInt(file,"Skin",0);
                INI_WriteInt(file,"Frozen",0);
                INI_Close(file);

                SetSpawnInfo(0, 0, 299, 1743.0520,-1863.3153,13.5752,1.8252,0,0,0,0,0,0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_REGISTER_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully registered\n Please procceed with clicking 'OK' to continue!", "Ok", "");
            }
        }
        case DIALOG_LOGIN: // Line 474
        {
            {
                if(!response) return Kick(playerid);
                if(response)
                {
                    new HashPass[129];
                    WP_Hash(HashPass,sizeof(HashPass),inputtext);
                    if(!strcmp(HashPass,pInfo[playerid][pPass]))

                    INI_ParseFile(Path(playerid),"LoadAccount_%s", .bExtra = true, .extra = playerid);

                    SetPlayerScore(playerid,pInfo[playerid][pScores]);
                    GivePlayerMoney(playerid,pInfo[playerid][pMoney]);

                    ShowPlayerDialog(playerid, DIALOG_LOGIN_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully logged in\n Please procceed with clicking 'OK'", "Ok", "");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
It's not in the switch that you started just earlier, you need to make sure the cases are aligned, which is the reason to use proper indention like you've done.
Reply
#3

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                new HashPass[129];
                WP_Hash(HashPass,sizeof(HashPass),inputtext);
                new INI:file = INI_Open(Path(playerid));
                INI_SetTag(file,"Player's Data");
                INI_WriteString(file,"Password",HashPass);
                INI_WriteInt(file,"AdminLevel",0);
                INI_WriteInt(file,"Banned",0);
                INI_WriteInt(file,"VIPLevel",0);
                INI_WriteInt(file,"Money",5000);
                INI_WriteInt(file,"Scores",1);
                INI_WriteInt(file,"Kills",0);
                INI_WriteInt(file,"Deaths",0);
                INI_WriteInt(file,"Skin",0);
                INI_WriteInt(file,"Frozen",0);
                INI_Close(file);

                SetSpawnInfo(0, 0, 299, 1743.0520,-1863.3153,13.5752,1.8252,0,0,0,0,0,0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_REGISTER_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully registered\n Please procceed with clicking 'OK' to continue!", "Ok", "");
            }
        }
        case DIALOG_LOGIN: // Line 474
        {
            {
                if(!response) return Kick(playerid);
                if(response)
                {
                    new HashPass[129];
                    WP_Hash(HashPass,sizeof(HashPass),inputtext);
                    if(!strcmp(HashPass,pInfo[playerid][pPass]))

                    INI_ParseFile(Path(playerid),"LoadAccount_%s", .bExtra = true, .extra = playerid);

                    SetPlayerScore(playerid,pInfo[playerid][pScores]);
                    GivePlayerMoney(playerid,pInfo[playerid][pMoney]);

                    ShowPlayerDialog(playerid, DIALOG_LOGIN_S, DIALOG_STYLE_MSGBOX, "Ok", "You have successfully logged in\n Please procceed with clicking 'OK'", "Ok", "");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Try this.
Reply
#4

Thanks to both of you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)