ERROR: "for" STATEMENT CANNOT BE FOLLOWED BY A NULL STATEMENT

I cant solve this error: “for” STATEMENT CANNOT BE FOLLOWED BY A NULL STATEMENT on this line: for (z = d4();(z == y || z == x);z = d4());

Someone can understand what’s happening here?

Full script is here:
void main()
{
object oPC = GetEnteringObject();
if (GetIsPC(oPC))
{
int FA = GetLocalInt(OBJECT_SELF,“attempt”);
SetLocalInt(OBJECT_SELF,“attempt”,FA+1);
object oArea = OBJECT_SELF;
if (GetLocalInt(oArea,“time”) == 0)
SetLocalInt(oArea,“time”,37+GetLocalInt(oPC,“handicap”)+(FA*3));
else
SetLocalInt(oArea,“time”,-1);
SetLocalInt(oArea,“kills”,0);
SetLocalInt(oArea,“total”,24);
SetLocalLocation(oArea,“exitWP”,GetLocation(GetObjectByTag(“TrialReturn”)));
ExploreAreaForPlayer(oArea,oPC);
int x = d4();
int y;
int z;
for (y = d4();y == x;y = d4());
for (z = d4();(z == y || z == x);z = d4());
int w = 10-(x+y+z);
CreateItemOnObject(“timetrialtarget”,GetObjectByTag(“CHEST”+IntToString(x)));
CreateItemOnObject(“key”+IntToString(x),GetObjectByTag(“CHEST”+IntToString(y)));
CreateItemOnObject(“key”+IntToString(y),GetObjectByTag(“CHEST”+IntToString(z)));
CreateItemOnObject(“key”+IntToString(z),GetObjectByTag(“CHEST”+IntToString(w)));
x = d4();
CreateItemOnObject(“key”+IntToString(w),GetObjectByTag(“CHEST”+IntToString(4+x)));
for (y = 1;y <= 4; y++)
if (y != x)
CreateItemOnObject(“key”+IntToString(4+y),GetObjectByTag(“CHEST”+IntToString(4+y)));
string sTemp;
object oWP;
object Enemy;
for (x = 1;x <= 24;x++)
{
sTemp = “training”+IntToString(d4());
oWP = GetWaypointByTag(“WP”+IntToString(x));
Enemy = CreateObject(OBJECT_TYPE_CREATURE,sTemp,GetLocation(oWP));
if (GetCreatureSize(oPC)==CREATURE_SIZE_SMALL && GetRacialType(Enemy) == RACIAL_TYPE_OUTSIDER)
AssignCommand(Enemy,ActionEquipItem(GetItemPossessedBy(Enemy,“traininghelper”),INVENTORY_SLOT_BELT));
}
ExecuteScript(“timetrialhb”,oPC);
}
}

NWScript compiler does not allow null statement (the semicolon, ;) after loop statement. But you can circumvent that by writing this:

for(...) {}

instead of

for(...);

Same goes for while and do while loops.


EDIT: this is also a feasible oneliner:

do y = d4(); while(y == x);
1 Like

When formatting your post, its easier to read if blocks of code are put into Code brackets such as this using (code) (/code) but with [ ] instead of ( ).

This means I have to modify from this:

for (y = d4();y == x;y = d4());
for (z = d4();(z == y || z == x);z = d4());

to this?
do y = d4(); while(y == x);
for (z = d4();(z == y || z == x);z = d4{});

more like

```nwscript

do y = d4(); while(y == x);
for (z = d4();(z == y || z == x);z = d4()){}

```
or

```nwscript

do y = d4(); while(y == x);
do z = d4(); while(z == y || z == x);

```

2 Likes