Big problem. Should return a value
#1

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
Reply
#2

It says that you need another return .
Reply
#3

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.
Reply
#4

Oh ma' nab mistake. thx man
Reply
#5

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.
Reply
#6

UP. someone can help me?
Reply
#7

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)
Reply
#8

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;
Reply
#9

Can you highlight which return causing error?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)