SA-MP Forums Archive
Big problem. Should return a value - 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: Big problem. Should return a value (/showthread.php?tid=522456)



Big problem. Should return a value - prooftzm - 27.06.2014

Hi guys. i have a big problem ( i think so )
pawn Код:
CMD:takejob(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1030.9374,-1442.4918,13.5546))
        {
            if(PlayerInfo[playerid][pJob] == 0)
            {
                SendClientMessage(playerid,COLOR_AQUA, "***Felicitari!*** Acum ai jobul Deliver.***");
                SendClientMessage(playerid,COLOR_AQUA, "***Comenzile jobului: /work, /quitjob.***");
                PlayerInfo[playerid][pJob] = 1;
            }
            else
            {
                SendClientMessage(playerid,0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }

        else if(IsPlayerInRangeOfPoint(playerid, 3.0, 2093.7031,-2032.5769,13.5469))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Garbage Man.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /garbage, /quitjob.**");
                PlayerInfo[playerid][pJob] = 2;
            }
            else
            {
                SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
            return 1;
        }
    }
    else if(IsPlayerInRangeOfPoint(playerid, 3.0, -401.3627,-1419.2340,25.7209))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Fermier.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /recolteaza, /quitjob.**");
                PlayerInfo[playerid][pJob] = 3;
            }
            else
            {
                SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
            return 1;
        }
    }
    return 1;
}
when i compile, it says
C:\Users\Cristi\Desktop\server\gamemodes\gm.pwn(10 49) : warning 209: function "cmd_takejob" should return a value
C:\Users\Cristi\Desktop\server\gamemodes\gm.pwn(10 50) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.



Line 1049: }
line 1050: return 1;
pls help


Re: Big problem. Should return a value - luis_mendoza - 27.06.2014

It says that you need another return .


Re: Big problem. Should return a value - iOxide - 27.06.2014

Why do you have return 1; in each else statement? Remove it. Thats the reason its showing the error. You don't need to return a value after using else statement to send a client message.


Re: Big problem. Should return a value - prooftzm - 27.06.2014

Oh ma' nab mistake. thx man


Re: Big problem. Should return a value - prooftzm - 27.06.2014

UP: i have a nasty problem example: i'm in the spot where I CAN type /takejob to take that job but is not working. "Nu poti lua jobul de aici" means You cannot take the job from here. BUT I'M in the correct place. where is the problem ?
first time i see this problem.


Re: Big problem. Should return a value - prooftzm - 27.06.2014

UP. someone can help me?


Re: Big problem. Should return a value - Dziugsas - 27.06.2014

pawn Код:
CMD:takejob(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1030.9374,-1442.4918,13.5546))
        {
            if(PlayerInfo[playerid][pJob] == 0)
            {
                SendClientMessage(playerid,COLOR_AQUA, "***Felicitari!*** Acum ai jobul Deliver.***");
                SendClientMessage(playerid,COLOR_AQUA, "***Comenzile jobului: /work, /quitjob.***");
                PlayerInfo[playerid][pJob] = 1;
                return 1;
            }
            else
            {
                SendClientMessage(playerid,0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }

        else if(IsPlayerInRangeOfPoint(playerid, 3.0, 2093.7031,-2032.5769,13.5469))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Garbage Man.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /garbage, /quitjob.**");
                PlayerInfo[playerid][pJob] = 2;
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
            return 1;
        }
    }
    else if(IsPlayerInRangeOfPoint(playerid, 3.0, -401.3627,-1419.2340,25.7209))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Fermier.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /recolteaza, /quitjob.**");
                PlayerInfo[playerid][pJob] = 3;
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
            return 1;
        }
    }
    return 1;
}
if you wont type return in every statement system will look for closiest return point (return 1 - means everything okay , your code was executed | return 0 - means something is wrong your code cannot be executed)


Re: Big problem. Should return a value - prooftzm - 27.06.2014

is not working dziugsas
C:\Users\Cristi\Desktop\server\gamemodes\gm.pwn(10 53) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Line 1053: return 1;


Re: Big problem. Should return a value - Dziugsas - 27.06.2014

Can you highlight which return causing error?


Re: Big problem. Should return a value - Dignity - 27.06.2014

Quote:
Originally Posted by iOxide
Посмотреть сообщение
Why do you have return 1; in each else statement? Remove it. Thats the reason its showing the error. You don't need to return a value after using else statement to send a client message.
While the return 1;'s aren't necessary, they did not cause the error.

@OP:

You don't need to add callbacks for a single function after a "else" statement. (as iOxide already mentioned) I fixed your indentation and shortened your command, please tell me if it works. Also, if your "you cannot take the job" messages persist after this, you need to fix your coordinates.

pawn Код:
CMD:takejob(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1030.9374,-1442.4918,13.5546))
        {
            if(PlayerInfo[playerid][pJob] == 0)
            {
                SendClientMessage(playerid,COLOR_AQUA, "***Felicitari!*** Acum ai jobul Deliver.***");
                SendClientMessage(playerid,COLOR_AQUA, "***Comenzile jobului: /work, /quitjob.***");
                PlayerInfo[playerid][pJob] = 1;
            }

            else SendClientMessage(playerid,0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
        }

        else if(IsPlayerInRangeOfPoint(playerid, 3.0, 2093.7031,-2032.5769,13.5469))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Garbage Man.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /garbage, /quitjob.**");
                PlayerInfo[playerid][pJob] = 2;
            }

            else SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");
        }
       
        else SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
   
        else if(IsPlayerInRangeOfPoint(playerid, 3.0, -401.3627,-1419.2340,25.7209))
        {
            if(PlayerInfo[playerid][pJob] < 1)
            {
                SendClientMessage(playerid, COLOR_AQUA, "***Felicitari! Acum ai jobul Fermier.**");
                SendClientMessage(playerid, COLOR_AQUA, "***Comenzile jobuli: /recolteaza, /quitjob.**");
                PlayerInfo[playerid][pJob] = 3;
            }
            else SendClientMessage(playerid, 0x6A6A6AFF, "Ai deja un job. Foloseste /quitjob intai.");

        }
        else SendClientMessage(playerid, 0x6A6A6AFF, "Nu poti lua jobul de aici.");
    }

    return 1;
}