Help, please - 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: Help, please (
/showthread.php?tid=315522)
Help, please -
Setkus - 03.02.2012
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.
Re: Help, please -
MP2 - 03.02.2012
You just have a tiny mistake in the if(). Change it to this:
pawn Код:
if(gTeam[playerid] == TEAM_BLUE || gTeam[playerid] == TEAM_GREEN)
Re: Help, please - T0pAz - 03.02.2012
pawn Код:
if( (gTeam[playerid] == TEAM_BLUE) || (gTeam[playerid] == TEAM_GREEN) )
Re: Help, please -
Setkus - 03.02.2012
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;
}
Re: Help, please -
Konstantinos - 03.02.2012
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;
}
Re: Help, please - T0pAz - 03.02.2012
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?
Re: Help, please -
Setkus - 03.02.2012
Here
pawn Код:
else //here is the error I dont know what is wrong
Re: Help, please - T0pAz - 03.02.2012
Quote:
Originally Posted by T0pAz
pawn Код:
if( (gTeam[playerid] == TEAM_BLUE) || (gTeam[playerid] == TEAM_GREEN) )
|
Have you used?
Re: Help, please -
AndreT - 03.02.2012
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
}
Re: Help, please -
Setkus - 03.02.2012
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!