"error 029: invalid expression, assumed zero" on the line "else"
#1

Can somebody help me? When i compile, pawno return me this error: "error 029: invalid expression, assumed zero"
Код:
CMD:courier(playerid,params[])
{
    if(Corriere[playerid] == 1) return SendClientMessage(playerid, BIANCO, "You are already in courier mission!");
	{
	StatoCorriere[playerid]=1;
    Corriere[playerid]=1;
    NienteGod[playerid]=1;
	GodTemp[playerid]=1;
	VeicoliNo[playerid]=1;
	VeicoliNo2[playerid]=1;
	DisabilitaBoost[playerid]=1;
	SetPlayerHealth(playerid, 100);
    SetPlayerCheckpoint(playerid,1110.5992,-1327.9216,13.7145,10);
    new nome[MAX_PLAYER_NAME], stringa[48];
    GetPlayerName(playerid, nome, sizeof(nome));
    format(stringa, sizeof(stringa), "%s is now a Courier", nome);
    SendClientMessageToAll(GIALLO, stringa);
    }
	else // This is the error line <<<<<<<<<<---------
	{
 	SendClientMessage(playerid, ROSSO,"You have to be in a courier truck to start the job! (Type /v benson");
 	SendClientMessage(playerid, ROSSO,"and then type again /courier)");
	}
    return 1;
}
I have tried to delete the else but pawno return warnings and other errors: "function "cmd_courier" should return a value".
Can you help me?
Reply
#2

pawn Код:
CMD:courier(playerid,params[])
{
    if(Corriere[playerid] == 1)
    {
        StatoCorriere[playerid]=1;
        Corriere[playerid]=1;
        NienteGod[playerid]=1;
        GodTemp[playerid]=1;
        VeicoliNo[playerid]=1;
        VeicoliNo2[playerid]=1;
        DisabilitaBoost[playerid]=1;
        SetPlayerHealth(playerid, 100);
        SetPlayerCheckpoint(playerid,1110.5992,-1327.9216,13.7145,10);
        new nome[MAX_PLAYER_NAME], stringa[48];
        GetPlayerName(playerid, nome, sizeof(nome));
        format(stringa, sizeof(stringa), "%s is now a Courier", nome);
        SendClientMessageToAll(GIALLO, stringa);
    }
    else // This is the error line <<<<<<<<<<---------
    {
        SendClientMessage(playerid, ROSSO,"You have to be in a courier truck to start the job! (Type /v benson");
        SendClientMessage(playerid, ROSSO,"and then type again /courier)");
    }
    return 1;
}
Reply
#3

Can i see the error line please?
Reply
#4

Your adding code between the if & else statment.
Reply
#5

This
pawn Код:
CMD:courier(playerid,params[])
{
    if(Corriere[playerid] != 1)
    {
        StatoCorriere[playerid]=1;
        Corriere[playerid]=1;
        NienteGod[playerid]=1;
        GodTemp[playerid]=1;
        VeicoliNo[playerid]=1;
        VeicoliNo2[playerid]=1;
        DisabilitaBoost[playerid]=1;
        SetPlayerHealth(playerid, 100);
        SetPlayerCheckpoint(playerid,1110.5992,-1327.9216,13.7145,10);
        new nome[MAX_PLAYER_NAME], stringa[48];
        GetPlayerName(playerid, nome, sizeof(nome));
        format(stringa, sizeof(stringa), "%s is now a Courier", nome);
        SendClientMessageToAll(GIALLO, stringa);
    }
    else if(Corriere[playerid] == 1) return SendClientMessage(playerid, BIANCO, "You are already in courier mission!");
     else
    {
        SendClientMessage(playerid, ROSSO,"You have to be in a courier truck to start the job! (Type /v benson");
        SendClientMessage(playerid, ROSSO,"and then type again /courier)");
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Laurey
Посмотреть сообщение
This
pawn Код:
CMD:courier(playerid,params[])
{
    if(Corriere[playerid] != 1)
    {
        StatoCorriere[playerid]=1;
        Corriere[playerid]=1;
        NienteGod[playerid]=1;
        GodTemp[playerid]=1;
        VeicoliNo[playerid]=1;
        VeicoliNo2[playerid]=1;
        DisabilitaBoost[playerid]=1;
        SetPlayerHealth(playerid, 100);
        SetPlayerCheckpoint(playerid,1110.5992,-1327.9216,13.7145,10);
        new nome[MAX_PLAYER_NAME], stringa[48];
        GetPlayerName(playerid, nome, sizeof(nome));
        format(stringa, sizeof(stringa), "%s is now a Courier", nome);
        SendClientMessageToAll(GIALLO, stringa);
    }
    else if(Corriere[playerid] == 1) return SendClientMessage(playerid, BIANCO, "You are already in courier mission!");
     else
    {
        SendClientMessage(playerid, ROSSO,"You have to be in a courier truck to start the job! (Type /v benson");
        SendClientMessage(playerid, ROSSO,"and then type again /courier)");
    }
    return 1;
}
Wouldn't work properly. If value != 1, else if value == 1, what would 'else' be? It either has to be 1 or not be 1, it can't be anything else.

This is a bad statement and it needs to be fixed, because the way you're doing it, Corriere[playerid] is playing two parts.

pawn Код:
if(Corriere[playerid] == 1) return SendClientMessage(playerid, -1, "You need to be a courier...");
//Will only execute when Corriere[playerid] is 1.
Anything under that line will execute when Corriere[playerid] is NOT 1. However, then you have 'else' which means:
pawn Код:
if(Corriere[playerid] != 1)
It's kind of hard to explain this, but you have:

//CODE TO EXECUTE IF CORRIERE == 1
//CODE TO EXECUTE IF CORRIERE != 1
//ELSE EXECUTE THIS CODE IF CORRIERE != 1

So you have two parts of your code that will execute when they're not meant to execute at the same time.
(My brain hurts just from trying to explain this to you...)

Just... look over your code a bit more.
Reply
#7

To be simple, it goes through to check if its equal to , If its equal to one then it returns a client message, if not there's a case with else if to send its client message and if its not any of the both then it sends the messages at the bottom, wont mess at all. I even learnt this in my classes.
Reply
#8

@Laurey there is a problem: when I am in a mission courier, and during the mission I type /courier, the message "You are already in courier mission!" doesn't appear. Doesn't appear any message.
Reply
#9

Mate try this:

pawn Код:
CMD:courier(playerid,params[])
{
    if(Corriere[playerid] != 1)
    {
        StatoCorriere[playerid]=1;
        Corriere[playerid]=1;
        NienteGod[playerid]=1;
        GodTemp[playerid]=1;
        VeicoliNo[playerid]=1;
        VeicoliNo2[playerid]=1;
        DisabilitaBoost[playerid]=1;
        SetPlayerHealth(playerid, 100);
        SetPlayerCheckpoint(playerid,1110.5992,-1327.9216,13.7145,10);
        new nome[MAX_PLAYER_NAME], stringa[48];
        GetPlayerName(playerid, nome, sizeof(nome));
        format(stringa, sizeof(stringa), "%s is now a Courier", nome);
        SendClientMessageToAll(GIALLO, stringa);
    }
    else // This is the error line <<<<<<<<<<---------
    {
        SendClientMessage(playerid, ROSSO,"You have to be in a courier truck to start the job! (Type /v benson");
        SendClientMessage(playerid, ROSSO,"and then type again /courier)");
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Laurey
Посмотреть сообщение
To be simple, it goes through to check if its equal to , If its equal to one then it returns a client message, if not there's a case with else if to send its client message and if its not any of the both then it sends the messages at the bottom, wont mess at all. I even learnt this in my classes.
It's either ''== 1' or '!= 1'... there is no 'else'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)