SA-MP Forums Archive
must be lvalue (non-constant) - 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: must be lvalue (non-constant) (/showthread.php?tid=479015)



must be lvalue (non-constant) - batonsa - 02.12.2013

Hey there!

If anyone has expressed this kind of error before and knows how get their way around of it, please share the knowledge. Have never tangled with checkpoints before so I'm not quite sure what I am doing.

What i am trying to do though - easily explained is adding a name to the checkpoint so i could use it later in the OnPlayerEnterDynamicCP callback - case, for example.

Код:
        for(new h = 0; h < sizeof(HouseInfo); h++)
	{
            CHECKPOINT_HOUSE = CreateDynamicCP(HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez], 2, -1, -1, -1, 2);
	}
The line in bold is returning 'error 022: must be lvalue (non-constant)'

Thanks in advance!


Re: must be lvalue (non-constant) - Emmet_ - 02.12.2013

I'm presuming that CHECKPOINT_HOUSE is a definition.

It's best to remove that definition and place this above the script:

pawn Код:
static CHECKPOINT_HOUSE;
You can't change definitions upon run-time since they're all handled by the pre-processor.


Re: must be lvalue (non-constant) - batonsa - 02.12.2013

Thanks for that, got me one step forward.

Though, now I'm getting 'error 008: must be a constant expression; assumed zero' under the

OnPlayerEnterDynamicCP callback, under 'case: CHECKPOINT_HOUSE'. It is in switch though.

Edit: Seems like a vicious circle to me :P


Re: must be lvalue (non-constant) - Vince - 02.12.2013

Case values must be known at compile time to prevent runtime errors. This is one of those cases (no pun intended) where you must resort to an old-fashioned if-if-if structure, however illogical that may seem.


Re: must be lvalue (non-constant) - batonsa - 02.12.2013

Gotcha, thanks both, appreciated !