Must be lvalue (non-constant)
#1

pawn Код:
static const oldmoney;
oldmoney = GetPlayerMoneyEx(playerid); //Line 1258
SetPlayerMoneyEx(playerid, oldmoney);
pawn Код:
(1258) : error 022: must be lvalue (non-constant)
Still trying to figure out what it means. Can anyone explain it to me please?
Reply
#2

const means that you cannot change oldmoney value in your code.
Reply
#3

I know that. Before I changed it to static, it was new const and it worked fine. I mean can you explain lvalue and why it is giving that error.
Reply
#4

From my understanding, static means 'the same'. That might be why it complains (sort of speak) when you attempt to change the value.
Reply
#5

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
From my understanding, static means 'the same'. That might be why it complains (sort of speak) when you attempt to change the value.
Yes, but I changed it to new const and it still gives back the same error.
Reply
#6

Howcome it isnt just new (without the const) ?
Reply
#7

Because its in OnPlayerUpdate which is called 6-10 times per second.
Reply
#8

Quote:

022 must be lvalue (non-constant)
The symbol that is altered (incremented, decremented, assigned
a value, etc.) must be a variable that can be modified (this kind
of variable is called an lvalue). Functions, string literals, arrays
and constants are no lvalues. Variables declared with the “const”
attribute are no lvalues either.

Код:
static const oldmoney;
oldmoney = GetPlayerMoneyEx(playerid);
Bad.

Код:
static const oldmoney = GetPlayerMoneyEx(playerid);
Good.
Reply
#9

Quote:
Originally Posted by klk
Посмотреть сообщение
Код:
static const oldmoney;
oldmoney = GetPlayerMoneyEx(playerid);
Bad.

Код:
static const oldmoney = GetPlayerMoneyEx(playerid);
Good.
pawn Код:
error 008: must be a constant expression; assumed zero
Reply
#10

On the same line? For me it works fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)