SA-MP Forums Archive
If statement error! - 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: If statement error! (/showthread.php?tid=333575)



If statement error! - linuxthefish - 11.04.2012

Long time since i scripted, WTF is wrong!?

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(event(playerid)) == 1) continue; //if playerid has event = 1 they are in the race and stuff below applies to them
            DisablePlayerCheckpoint(i);
            SetPlayerVirtualWorld(playerid, 0);
            SpawnPlayer(playerid);
            FreezePlayerForTime(playerid, 3);
            event[playerid] = 0;
        }



Re: If statement error! - The__ - 12.04.2012

Try changing to :
pawn Код:
if(event(i)) == 1) continue;
Or :
pawn Код:
if(event(i)) == 1)
{
    continue;
}



Re: If statement error! - linuxthefish - 12.04.2012

Quote:
Originally Posted by The__
Посмотреть сообщение
Try changing to :
pawn Код:
if(event(i)) == 1) continue;
Or :
pawn Код:
if(event(i)) == 1)
{
    continue;
}
Thanks, i'm such a idiot!


Re: If statement error! - MP2 - 12.04.2012

Helps if you show the errors.


Re: If statement error! - Marco_Valentine - 12.04.2012

where abouts is this in your script?

Quote:

for(new i = 0; i < MAX_PLAYERS; i++)
{
if(event[playerid] == 1) { //if playerid has event = 1 they are in the race and stuff below applies to them
DisablePlayerCheckpoint(i);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
FreezePlayerForTime(playerid, 3);
event[playerid] = 0;
}
}

??


Re: If statement error! - Ash. - 12.04.2012

You have an extra bracket in your if statement.

Код:
if(event(playerid)) == 1)
//Remove the second bracket after 'playerid'.
if(event(playerid) == 1)
You should also change all "playerid" names to "i"!


Re: If statement error! - The__ - 12.04.2012

Quote:
Originally Posted by linuxthefish
Посмотреть сообщение
Thanks, i'm such a idiot!
No problem, sometimes I do that problem too.
It's I'm* btw .

EDIT:
Quote:
Originally Posted by funky1234
Посмотреть сообщение
You have an extra bracket in your if statement.

Код:
if(event(playerid)) == 1)
//Remove the second bracket after 'playerid'.
if(event(playerid) == 1)
You should also change all "playerid" names to "i"!
You are wrong, It's
if(event(playerid))
The "i" is correct, told him already.


Re: If statement error! - The__ - 12.04.2012

Sorry for double post.


Re: If statement error! - linuxthefish - 12.04.2012

Still getting a shitload of errors

Код:
C:\Documents and Settings\Admin\Desktop\The Way of Life\gamemodes\WoL.pwn(16313) : error 012: invalid function call, not a valid address
C:\Documents and Settings\Admin\Desktop\The Way of Life\gamemodes\WoL.pwn(16313) : warning 215: expression has no effect
C:\Documents and Settings\Admin\Desktop\The Way of Life\gamemodes\WoL.pwn(16313) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Admin\Desktop\The Way of Life\gamemodes\WoL.pwn(16313) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Admin\Desktop\The Way of Life\gamemodes\WoL.pwn(16313) : fatal error 107: too many error messages on one line
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(event(i) == 1) //if playerid has event = 1 they are in the race and stuff below applies to them
            {
                DisablePlayerCheckpoint(i);
                SetPlayerVirtualWorld(i, 0);
                SpawnPlayer(i);
                FreezePlayerForTime(i, 3);
                event[i] = 0;
            }
            else return 1;
        }



Re: If statement error! - Marco_Valentine - 12.04.2012

Quote:
Originally Posted by The__
Посмотреть сообщение
No problem, sometimes I do that problem too.
It's I'm* btw .

EDIT:

You are wrong, It's
if(event(playerid))
The "i" is correct, told him already.
if(event(playerid)) == 1)
isn't green the extra bracket?