SA-MP Forums Archive
Invalid Function of declaration - 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: Invalid Function of declaration (/showthread.php?tid=449327)



Invalid Function of declaration - xganyx - 08.07.2013

hello again and if i spam i'm very sorry...

here the code:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_TRUCK:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKL,DIALOG_STYLE_LIST,"What do you want to transport?","{00F70C}Food & beverages\n{00F70C}Clothing\n{00F70C}24/7 Items", "Select", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKI,DIALOG_STYLE_LIST,"What do you want to transport?","{FF0606}Weapons         {FFFFFF}(Level 1 Bonus: Free Weapons)\n{FF0606}Drugs            {FFFFFF}(Level 1 Bonus: Free 10 pot, 10 crack)","Choose","Cance");
                    }
                }
            }
        }
        case DIALOG_TRUCKL:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 2;
                        SetPlayerCheckpoint(playerid,2264.3049,-1690.5104,13.6958,4.0);
                    }
                    case 1:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 3;
                        SetPlayerCheckpoint(playerid,786.7734,-1635.9037,13.3828,4.0);
                    }
                }
            }
        }
    }
    return 1;
    }
    return 0; // this is line 573
}
error:
pawn Код:
C:\Users\Admin\Desktop\NewServerss_2\filterscripts\Job.pwn(573) : error 010: invalid function or declaration



Re: Invalid Function of declaration - Konstantinos - 08.07.2013

Use either return 0; (if it's filterscript) or return 1; (if it's gamemode).

Change
pawn Код:
// ...
    }
    return 1;
    }
    return 0; // this is line 573
}
to:

either
pawn Код:
// ...
    }
    return 1;
}
or
pawn Код:
// ...
    }
    return 0;
}



Re: Invalid Function of declaration - Deathstalker - 08.07.2013

Try this:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_TRUCK:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKL,DIALOG_STYLE_LIST,"What do you want to transport?","{00F70C}Food & beverages\n{00F70C}Clothing\n{00F70C}24/7 Items", "Select", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKI,DIALOG_STYLE_LIST,"What do you want to transport?","{FF0606}Weapons         {FFFFFF}(Level 1 Bonus: Free Weapons)\n{FF0606}Drugs            {FFFFFF}(Level 1 Bonus: Free 10 pot, 10 crack)","Choose","Cance");
                    }
                }
            }
        }
        case DIALOG_TRUCKL:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 2;
                        SetPlayerCheckpoint(playerid,2264.3049,-1690.5104,13.6958,4.0);
                    }
                    case 1:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 3;
                        SetPlayerCheckpoint(playerid,786.7734,-1635.9037,13.3828,4.0);
                    }
                }
            }
        }
    }
    return 1;
}



Respuesta: Invalid Function of declaration - Xabi - 08.07.2013

You have one extra closing bracket, this would be the correct way to finish the callback:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_TRUCK:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKL,DIALOG_STYLE_LIST,"What do you want to transport?","{00F70C}Food & beverages\n{00F70C}Clothing\n{00F70C}24/7 Items", "Select", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKI,DIALOG_STYLE_LIST,"What do you want to transport?","{FF0606}Weapons         {FFFFFF}(Level 1 Bonus: Free Weapons)\n{FF0606}Drugs            {FFFFFF}(Level 1 Bonus: Free 10 pot, 10 crack)","Choose","Cance");
                    }
                }
            }
        }
        case DIALOG_TRUCKL:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 2;
                        SetPlayerCheckpoint(playerid,2264.3049,-1690.5104,13.6958,4.0);
                    }
                    case 1:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 3;
                        SetPlayerCheckpoint(playerid,786.7734,-1635.9037,13.3828,4.0);
                    }
                }
            }
        }
    }
    return 1;
}



Re: Invalid Function of declaration - xganyx - 09.07.2013

return 1; in my gamemode and return 0; in my filterscript but the filterscript not work please help
Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Use either return 0; (if it's filterscript) or return 1; (if it's gamemode).

Change
pawn Код:
// ...
    }
    return 1;
    }
    return 0; // this is line 573
}
to:

either
pawn Код:
// ...
    }
    return 1;
}
or
pawn Код:
// ...
    }
    return 0;
}



Re: Invalid Function of declaration - xganyx - 10.07.2013

help please


Re: Invalid Function of declaration - Sandiel - 10.07.2013

Quote:

Returns Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.

Taken from SAMP WIKI's OnDialogResponse - callback.
https://sampwiki.blast.hk/wiki/OnDialogResponse


Re: Invalid Function of declaration - xganyx - 10.07.2013

Quote:
Originally Posted by Sandiel
Посмотреть сообщение
Taken from SAMP WIKI's OnDialogResponse - callback.
https://sampwiki.blast.hk/wiki/OnDialogResponse
can u help me ?


Re: Invalid Function of declaration - xganyx - 10.07.2013

bump


Re: Invalid Function of declaration - iggy1 - 10.07.2013

Just delete the return 1 and extra closing bracket. You seem to have ignored xabi's/_zeus post.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_TRUCK:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKL,DIALOG_STYLE_LIST,"What do you want to transport?","{00F70C}Food & beverages\n{00F70C}Clothing\n{00F70C}24/7 Items", "Select", "Cancel");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid,DIALOG_TRUCKI,DIALOG_STYLE_LIST,"What do you want to transport?","{FF0606}Weapons         {FFFFFF}(Level 1 Bonus: Free Weapons)\n{FF0606}Drugs            {FFFFFF}(Level 1 Bonus: Free 10 pot, 10 crack)","Choose","Cance");
                    }
                }
            }
        }
        case DIALOG_TRUCKL:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 2;
                        SetPlayerCheckpoint(playerid,2264.3049,-1690.5104,13.6958,4.0);
                    }
                    case 1:
                    {
                        TogglePlayerControllable(playerid,1);
                        CP[playerid] = 3;
                        SetPlayerCheckpoint(playerid,786.7734,-1635.9037,13.3828,4.0);
                    }
                }
            }
        }
    }
    return 0; // this is line 573
}