Help, please
#1

hey, guys!
Whats wrong whit this code? I dont understand...

pawn Код:
if(gTeam[playerid] == TEAM_BLUE || TEAM_GREEN)
       {
       if(Checkpoint)
            {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Wait 20 seconds.");
                        captureTimer = SetTimerEx("SetZone",20000,false,"i",playerid);
                  else
                  {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Your team has captured this flag, you dont need to do this again.");
                        }
             }
             }
        return 1;
        }
here is the error:

pawn Код:
D:\GTASA~1\USAVS~1.MEC\GAMEMO~1\dykuma.pwn(820) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

You just have a tiny mistake in the if(). Change it to this:

pawn Код:
if(gTeam[playerid] == TEAM_BLUE || gTeam[playerid] == TEAM_GREEN)
Reply
#3

pawn Код:
if( (gTeam[playerid] == TEAM_BLUE) || (gTeam[playerid] == TEAM_GREEN) )
Reply
#4

Still the same problem. The error is in this line:

pawn Код:
if(gTeam[playerid] == TEAM_BLUE || TEAM_GREEN)
       {
       if(Checkpoint)
            {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Wait 20 seconds.");
                        captureTimer = SetTimerEx("SetZone",20000,false,"i",playerid);
                  else //here is the error I dont know what is wrong
                  {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Your team has captured this flag, you dont need to do this again.");
                        }
             }
             }
        return 1;
        }
Reply
#5

You don't close the bracket before else "}"
pawn Код:
// Code above..
        if(gTeam[playerid] == TEAM_BLUE || gTeam[playerid] == TEAM_GREEN)
        {
            if(Checkpoint)
            {
                SendClientMessage(playerid,OBJECTIVE_COLOR,"Wait 20 seconds.");
                captureTimer = SetTimerEx("SetZone",20000,false,"i",playerid);
            } // <-
            else
            {
                SendClientMessage(playerid,OBJECTIVE_COLOR,"Your team has captured this flag, you dont need to do this again.");
            }
        }
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Setkus
Посмотреть сообщение
Still the same problem. The error is in this line:

pawn Код:
if(gTeam[playerid] == TEAM_BLUE || TEAM_GREEN)
       {
       if(Checkpoint)
            {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Wait 20 seconds.");
                        captureTimer = SetTimerEx("SetZone",20000,false,"i",playerid);
                  else //here is the error I dont know what is wrong
                  {
                        SendClientMessage(playerid,OBJECTIVE_COLOR,"Your team has captured this flag, you dont need to do this again.");
                        }
             }
             }
        return 1;
        }
Which line is your error?
Reply
#7

Here
pawn Код:
else //here is the error I dont know what is wrong
Reply
#8

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
pawn Код:
if( (gTeam[playerid] == TEAM_BLUE) || (gTeam[playerid] == TEAM_GREEN) )
Have you used?
Reply
#9

There's some stuff you still need to learn about PAWN and coding in general as it seems. First of all, if statements do not work like that, a working use would be:
pawn Код:
if(gTeam[playerid] == TEAM_BLUE || gTeam[playerid] == TEAM_GREEN)
Also, a curly bracket starts or ends a scope. You cannot use the else keyword if you have not closed the last scope.
pawn Код:
if(Checkpoint)
{
    // this scope
else // <-- invalid!
{
You need to use a closing bracket first!
pawn Код:
if(Checkpoint)
{
    // code
}
else
{
    // code
}
Reply
#10

Quote:
Originally Posted by AndreT
Посмотреть сообщение
There's some stuff you still need to learn about PAWN and coding in general as it seems. First of all, if statements do not work like that, a working use would be:
pawn Код:
if(gTeam[playerid] == TEAM_BLUE || gTeam[playerid] == TEAM_GREEN)
Also, a curly bracket starts or ends a scope. You cannot use the else keyword if you have not closed the last scope.
pawn Код:
if(Checkpoint)
{
    // this scope
else // <-- invalid!
{
You need to use a closing bracket first!
pawn Код:
if(Checkpoint)
{
    // code
}
else
{
    // code
}
Thanks, man, works fine!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)