SA-MP Forums Archive
Hello! Can i get a bit of help here? - 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: Hello! Can i get a bit of help here? (/showthread.php?tid=320220)



Hello! Can i get a bit of help here? - Sal - 22.02.2012

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;



Re: Hello! Can i get a bit of help here? - emokidx - 22.02.2012

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.


Re: Hello! Can i get a bit of help here? - Sal - 22.02.2012

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,


Re: Hello! Can i get a bit of help here? - 2KY - 22.02.2012

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.


Re: Hello! Can i get a bit of help here? - emokidx - 22.02.2012

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


Re: Hello! Can i get a bit of help here? - Andi_Evandy - 22.02.2012

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;
}