Hello! Can i get a bit of help here?
#1

Hello, I get these errors when compiling my script
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(254) : error 014: invalid statement; not in switch
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(254) : warning 215: expression has no effect
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(254) : error 001: expected token: ";", but found ":"
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(254) : error 029: invalid expression, assumed zero
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(254) : fatal error 107: too many error messages on one line

This is line 254
pawn Код:
case 1:
But i know that is not enough so here is the WHOLE Callback
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        case 1:
        {
        SetPlayerFightingStyle(playerid, 4);
        }
        case 2:
        {
        SetPlayerFightingStyle(playerid, 5);
        }
        case 3:
        {
        SetPlayerFightingStyle(playerid, 6);
        }
        case 4:
        {
        SetPlayerFightingStyle(playerid, 7);
        }
        case 5:
        {
        SetPlayerFightingStyle(playerid, 15);
        }
        case 6:
        SetPlayerFightingStyle(playerid, 26);
        }
    }
}
    return 1;
}
Here is the ShowPlayerDialog
pawn Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Fighting Style", "1. Normal\r\n2. Boxing\r\n3. Kung Fu\r\n4. Knee Head\r\n5. Grab Kick\r\n5. Elbow","Accept", "Cancel");
    return 1;
Reply
#2

you have to add
pawn Код:
switch(listitem)
how can you use cases without knowing what you are switching them for?
you also miss one bracket
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        switch(listitem)
        {
            case 1:
            {
                SetPlayerFightingStyle(playerid, 4);
            }
            case 2:
            {
                SetPlayerFightingStyle(playerid, 5);
            }
            case 3:
            {
                SetPlayerFightingStyle(playerid, 6);
            }
            case 4:
            {
                SetPlayerFightingStyle(playerid, 7);
            }
            case 5:
            {
                SetPlayerFightingStyle(playerid, 15);
            }
            case 6:
            { // <-- missing bracket
                SetPlayerFightingStyle(playerid, 26);
            }
        }

    }
    return 1;
}
this should be the correct one.
also, try to indent codes better.
Reply
#3

Thanks for the assistance, Although the return says Loose indentation an even though i backspace and tab my life out it still says it.
Awkward moment when you realise your a retard,
Reply
#4

Quote:
Originally Posted by Sal
Посмотреть сообщение
Thanks for the assistance, Although the return says Loose indentation an even though i backspace and tab my life out it still says it.
Awkward moment when you realise your a retard,
Indentation works kind of like so: http://pastebin.com/8L8hSKJk.
Reply
#5

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case 1: // dialog id 1
        {
            switch(listitem)
            {
                case 1: SetPlayerFightingStyle(playerid, 4); //1st option

                case 2: SetPlayerFightingStyle(playerid, 5); //2nd

                case 3: SetPlayerFightingStyle(playerid, 6);// so on

                case 4: SetPlayerFightingStyle(playerid, 7);

                case 5: SetPlayerFightingStyle(playerid, 15);

                case 6: SetPlayerFightingStyle(playerid, 26);
            }
        }
        case 2: //dialog id 2
        {
            //code
        }
    }
    return 1;
}
just made it easier
Reply
#6

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:SetPlayerFightingStyle(playerid, 4);
                case 1:SetPlayerFightingStyle(playerid, 5);
                case 2:SetPlayerFightingStyle(playerid, 6);
                case 3:SetPlayerFightingStyle(playerid, 7);
                case 4:SetPlayerFightingStyle(playerid, 15);
                case 5:SetPlayerFightingStyle(playerid, 26);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)