error 078: function uses both "return" and "return <value>"
#1

Hello to all,

I have this error
PHP код:
error 078: function uses both "return" and "return <value>" 
And i dont have idea how to fixed, i tryed to put return 1; but it didnt work

PHP код:
        if(dialogid == DIALOG_DRIVELIC)
        {
           if(!
response) return 1;
            switch(
listitem)
            {
                case 
0
                {
                    if(
PlayerInfo[playerid][pCarLic] >= 1) return SCM(playeridG_CRVENA,"[Greska]"S_BJELA" Vec posjedujete dozvolu za motor!");
                    if(
PlayerInfo[playerid][pCash] < price) return SCMF(playerid,G_CRVENA,"[Greska]:"S_BJELA" Nemate dovoljno novca kod sebe (%d$)",price);
                    new 
str[350];
                     
format(str,sizeof(str),""S_TZELENA"D"S_BJELA"obro dosli u moto skolu!\n"S_TZELENA"P"S_BJELA"olaganje se sastoji samo iz teoriskog dijela!\n"S_TZELENA"D"S_BJELA"a krenete sa polaganjem kliknite "S_TZELENA"\"Kreni\" \n\n\n"S_TZELENA"NAPOMENA: "S_BJELA"Na testu smijete pogrijesiti samo na 1 pitanja!\n\n\n"S_TZELENA"C"S_BJELA"ijena polaganja je %d$",price);
                    
SPD(playerid,42,DIALOG_STYLE_MSGBOX,""S_TZELENA"Informacije",str,"Kreni","Ponisti");
                }
            }
        } 
Thanks to all in advance
Reply
#2

You provide us with very little information.
Which line gives you this error?
This error describes the error quite exactly actually. Try to understand it literally. Function uses both return and return value.
My assumption is that you have this under ondialogresponse:
Код:
return;

return 1;
Changing this to ( most likely 1 but could be 0 depending on the code) return x; (e.g return 1 will probably fix this issue.

If the above does not solve this, my second guess would be that the problem above could be found under the following functions:
SPD
SCM
SCMF
Reply
#3

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
You provide us with very little information.
Which line gives you this error?
This error describes the error quite exactly actually. Try to understand it literally. Function uses both return and return value.
My assumption is that you have this under ondialogresponse:
Код:
return;

return 1;
Changing this to ( most likely 1 but could be 0 depending on the code) return x; (e.g return 1 will probably fix this issue.

If the above does not solve this, my second guess would be that the problem above could be found under the following functions:
SPD
SCM
SCMF
PHP код:

      
if(dialogid == DIALOG_DRIVELIC
        { 
           if(!
response) return 1
            switch(
listitem
            { 
                case 
0:  
                { 
                    if(
PlayerInfo[playerid][pCarLic] >= 1) return SCM(playeridG_CRVENA,"[Greska]"S_BJELA" Vec posjedujete dozvolu za motor!"); //Errored line 1
                    
if(PlayerInfo[playerid][pCash] < price) return SCMF(playerid,G_CRVENA,"[Greska]:"S_BJELA" Nemate dovoljno novca kod sebe (%d$)",price);  //Errored line 2
                    
new str[350]; 
                     
format(str,sizeof(str),""S_TZELENA"D"S_BJELA"obro dosli u moto skolu!\n"S_TZELENA"P"S_BJELA"olaganje se sastoji samo iz teoriskog dijela!\n"S_TZELENA"D"S_BJELA"a krenete sa polaganjem kliknite "S_TZELENA"\"Kreni\" \n\n\n"S_TZELENA"NAPOMENA: "S_BJELA"Na testu smijete pogrijesiti samo na 1 pitanja!\n\n\n"S_TZELENA"C"S_BJELA"ijena polaganja je %d$",price); 
                    
SPD(playerid,42,DIALOG_STYLE_MSGBOX,""S_TZELENA"Informacije",str,"Kreni","Ponisti"); 
                } 
            } 
        } 
Errored lines:
PHP код:
                    if(PlayerInfo[playerid][pCarLic] >= 1) return SCM(playeridG_CRVENA,"[Greska]"S_BJELA" Vec posjedujete dozvolu za motor!"); //Errored line 1
                    
if(PlayerInfo[playerid][pCash] < price) return SCMF(playerid,G_CRVENA,"[Greska]:"S_BJELA" Nemate dovoljno novca kod sebe (%d$)",price);  //Errored line 2 
Reply
#4

Quote:
Originally Posted by RoX123
Посмотреть сообщение
PHP код:

      
if(dialogid == DIALOG_DRIVELIC
        { 
           if(!
response) return 1
            switch(
listitem
            { 
                case 
0:  
                { 
                    if(
PlayerInfo[playerid][pCarLic] >= 1) return SCM(playeridG_CRVENA,"[Greska]"S_BJELA" Vec posjedujete dozvolu za motor!"); //Errored line 1
                    
if(PlayerInfo[playerid][pCash] < price) return SCMF(playerid,G_CRVENA,"[Greska]:"S_BJELA" Nemate dovoljno novca kod sebe (%d$)",price);  //Errored line 2
                    
new str[350]; 
                     
format(str,sizeof(str),""S_TZELENA"D"S_BJELA"obro dosli u moto skolu!\n"S_TZELENA"P"S_BJELA"olaganje se sastoji samo iz teoriskog dijela!\n"S_TZELENA"D"S_BJELA"a krenete sa polaganjem kliknite "S_TZELENA"\"Kreni\" \n\n\n"S_TZELENA"NAPOMENA: "S_BJELA"Na testu smijete pogrijesiti samo na 1 pitanja!\n\n\n"S_TZELENA"C"S_BJELA"ijena polaganja je %d$",price); 
                    
SPD(playerid,42,DIALOG_STYLE_MSGBOX,""S_TZELENA"Informacije",str,"Kreni","Ponisti"); 
                } 
            } 
        } 
Errored lines:
PHP код:
                    if(PlayerInfo[playerid][pCarLic] >= 1) return SCM(playeridG_CRVENA,"[Greska]"S_BJELA" Vec posjedujete dozvolu za motor!"); //Errored line 1
                    
if(PlayerInfo[playerid][pCash] < price) return SCMF(playerid,G_CRVENA,"[Greska]:"S_BJELA" Nemate dovoljno novca kod sebe (%d$)",price);  //Errored line 2 
Have you even tried what i said? show me SCM and SCMF.
Reply
#5

SCM and SCMF are shortcuts (using #define) or functions?
Reply
#6

Quote:
Originally Posted by Variable™
Посмотреть сообщение
SCM and SCMF are shortcuts (using #define) or functions?
SCM is Define (#define SCM SendClientMessage)

SCMF is function

SCMF:
PHP код:
stock SCMF(playerid,color,fstring[],{Float_}:...)
{
   new 
n=(numargs()-3)*4;
   if(
n)
   {
      new 
message[128],arg_start,arg_end;
      
#emit CONST.alt                fstring
      #emit LCTRL                    5
      #emit ADD
      #emit STOR.S.pri               arg_start
      #emit LOAD.S.alt               n
      #emit ADD
      #emit STOR.S.pri               arg_end
      
do
      {
         
#emit LOAD.I
         #emit PUSH.pri
         
arg_end-=4;
         
#emit LOAD.S.pri           arg_end
      
}
      while(
arg_end>arg_start);
      
#emit PUSH.S                   fstring
      #emit PUSH.C                   255
      #emit PUSH.ADR                 message
      
n+=4*3;
      
#emit PUSH.S                   n
      #emit SYSREQ.C                 format
      
n+=4;
      
#emit LCTRL                    4
      #emit LOAD.S.alt               n
      #emit ADD
      #emit SCTRL                    4
      
return SCM(playerid,color,message);
   }
   else return 
SCM(playerid,color,fstring);

I tryed with return 0; but its same
Reply
#7

The problem is definitely not related to the functions.

Check OnDialogResponse well, and find:

Код:
return;
or

Код:
return 1/0/whatever;
You have a 'return' with a value and another that is empty. If you set it a value it would return 'unreachable' code for the rest of the code below it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)